Best way to combine two sketches using interrupt and sleep time?



  • I want to combine the soil-moisture and the temp sketch into one. But they use different methods to sleep between redings. The soil-moisture-sketch uses interrupt and the temp sleeps for a specific time.

    What would be the best way to combine those two to be able to save as much battery power as possible? If I would be fine with them both reading the sensor-values for example every 5 min, can I just copy the loop block from the moisture sketch into the bottom of the loop of the temp sensor sketch?


  • Hardware Contributor

    You can actually combine both I think. Search for sleep. There is a sleep function

    bool sleep(int interrupt, int mode, unsigned long ms=0);
    

    that both listenes to an interrupt and wakes up after a certain time. The return boolean value indicates which one.


Log in to reply
 

Suggested Topics

  • 4
  • 20
  • 8
  • 9
  • 4
  • 9

54
Online

11.4k
Users

11.1k
Topics

112.6k
Posts