ATTiny - Wake on timer or ADC

Hi, I am creating a weather station, and want to use as least power as possible.

I have an ATTiny85 to monitor the tipping bucket rain gauge, which is connected to pin PB4.
I have an ESP8266 which wakes every 5 minutes, reads the rain gauge tip from the ATTiny via i2c, and then sends the data via MQTT to homeassistant.
This all works and gets its power from a 18650 battery.

At the moment I use the following code from a similar project to put the ATTiny into sleep mode

  ADCSRA = 0;
  set_sleep_mode(SLEEP_MODE_IDLE);   // sleep mode is set here
  sleep_enable();          // enables the sleep bit in the mcucr register
  sleep_mode();            // here the device is put to sleep!!
  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
  sleep_disable();         // first thing after waking from sleep:

However I want to decrease the power consumption of the ESP and sensors to 0 when not in use.

I now want to us pin PB1 on the ATTiny to connect to a latching circuit (pulls latching circuit high for 100 millis), this is used to power on the ESP8288 and sensors (temp/humidity/pressure/light). The ESP then pulls the latching circuit to high to keep itself powered on, reads the amount of bucket tips from the ATTiny and sensors, sends data to home assistant, before pulling the latching circuit low to switch itself off and the sensor/s so that no power is used.

I want the ATTiny85 to sleep, and only wake up if the rain bucket tips, or every 5 minutes to start the ESP or when the ESP is reading the i2c data from ATTiny.

Can this be done with sleep, and if so how ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.