
What I would like to do is to use a RTC to drive the latching power circuit so that I can be sure the the ESP8266s are awake at the correct time and enhance the battery life at the same time. I initially them set them up well spaced apart but some are now converging, this can be because of delays in making the connection to ThingSpeak which in tern delays the next DeepSleep period. One thing that I have noticed is that the timing of the readings is drifting. I have remote ESP8266s monitoring room temperatures in a remote house, and reporting their readings to ThingSpeak. Thank you for another great project just what I am looking for, but I need help with a small change. When motion is detected, the PIR motion sensor sends a HIGH signal, and there’s power coming to the ESP32 that can be confirmed by the LED remaining lit. Your task can be making an HTTP request, publish an MQTT Message, datalogging, etc… Demonstrationįinally let’s test this setup, and see it in action. digitalWrite(powerLatch, LOW) Īdd the task you want to perform after setting the powerLatch pin to HIGH and before setting it to LOW. When it is set to LOW, the power is cut off, and the microcontroller turns off. delay(10000) Īfter that, we set the powerLatch pin to LOW. Next, for demonstration purposes we keep the LED on for ten seconds. Turn ON the LED connected to GPIO 4 (after the powerLatch pin is set to LOW, your board powers off and it also turns off this LED automatically) When we set it to HIGH, we ensure that there is power coming to feed the microcontroller.

In the setup(), define the powerLatch and led pins as outputs. In this case, it’s the on-board LED of the auto power off PCB. const int powerLatch = 5 įor testing purposes we’ll turn on an LED connected to GPIO 4. We’re using GPIO 5, but you can use any other pin. ADD YOUR TASK HERE (HTTP REQUEST, MQTT Message, Datalogger, etc) (after the powerLatch pin is set to LOW, your board powers off and it also turns off this LED automatically) Define power latch pin for ESP32 (GPIO 5) / ESP8266 (GPIO 5) / Arduino (Digital 5) Notice shall be included in all copies or substantial portions of the Software. The above copyright notice + link to project page and this permission
#Icircuit arduino software
Permission is hereby granted, free of charge, to any person obtainingĪ copy of this software and associated documentation files.
#Icircuit arduino code
The following code is compatible with ESP32, ESP8266 and Arduino. Also, in the future if you want to change the LED from pin 8 to pin 11 for example, you can modify this line without touching anything else in the code.To test the circuit, you can upload a sample code that keeps your board powered on for 10 seconds after a trigger signal. That way, if you have used different pins than I, you just need to modify those 2 lines. Setup #define LED_PIN 8įirst, as a best practice, we use some defines to keep the pin number for the LED and push button. And when we press the button the LED should be on. What we want to achieve is simple: when the button is not pressed, the LED is off. Turn on the LED when button is pressed, turn it off otherwise Finally, connect a leg of the button (same side as the pull down resistor) to a digital pin (here 7).Īll right your circuit is now finished.Add a red wire between another leg of the button and VCC (5V).This resistor will act as a “pull down” resistor, which means that the default button’s state will be LOW. Connect one leg of the button to the ground, and put a 10k Ohm resistor in between.Add the push button to the breadboard, like in the picture.Add a 220 Ohm resistor in between to limit the current going through the LED. Connect the longer leg of the LED to a digital pin (here pin no 8, you can change it).Plug this shorter leg to the ground (blue line here) of the circuit. You can notice that the LED has a leg shorter than the other. Plug a black wire between the blue line of the breadboard and a ground (GND) pin on the Arduino board.First, make sure to power off your Arduino – remove any USB cable.Step by step instructions to build the circuit ( more info about Arduino pins here):

A bunch of male to male wires (including if possible black, red, and other colors).If you don’t have, you can go until 20k-50k Ohm.

If you don’t have this specific value, any resistor from 330 to 1k Ohm will do.
