Introduction
Many time we need to turn ON the circuit manually(or by a sensor) and turn OFF it automatically. In this tutorial, we will see how to turn ON microcontroller based circuit and then how to turn OFF it by the microcontroller itself.This type of circuit is useful for battery operated circuit where circuit turns ON by your decision and turn OFF by the controller's decision i.e controller turn OFF itself by sensing any condition to save the power.
Caution: following ckt is for Arduino and NodeMCU but if you want to use it for ESP8266 then you need to connect 3.3V regulator for ESP8266 supply. Remaining ckt remains the same.
Components Required:
1) Momentary switch
2) IR transmitter
3) IR receiver
4) Resistor R1=3.3k
5) Resistor R2=10k
6) IR transmitter
7) IR receiver
8) Capacitor 100nF
9) MOSFET bs170
10) Voltage regulator 780
11) Capacitor 1000nF
Ckt1: Circuit Diagram |
IR Transmitter Receiver Pair
In above ckt, IR transmitter-receiver pair is shown. Ambient light should not be incident on IR receiver so I wrapped Transmitter and receiver heading towards each other using black tap.
![]() |
image1: IR transmitter-receiver pair |
HOW IT WORKS?
1)Turning ON
S1 is pressed
|
Q1 turns ON
|
the controller turns ON
|
The controller will turn the digital output pin D3 high
|
IR Tx turns ON
|
IR Rx starts conducting
|
Gate of Q1 pulled up by IR Rx
Now, to turn OFF the controller, pin D3 (Digital Pin)is pulled LOW by the controller
2) Turning OFF
2) Turning OFF
when controller senses any condition where the controller needs to be turned OFF to save the power the
the controller will pull Pin D3 to LOW
|
IR Tx turned OFF
|
IR Rx non-conducting
|
Q1gate pulled down to ground
|
Q1 turned OFF
|
Controller Turn OFF
Program (Arduino/NodeMCU)
Following program will blink BuiltIn LED for 5 times and then turn OFF the controller by pulling D3 pin LOW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Vivekanand Dhakane | |
//Uploaded on: 2 March 2020 | |
#include <ESP8266WiFi.h> | |
#define ctr 0 //D3 of NodeMCU | |
int count=0; | |
void setup() { | |
WiFi.disconnect(); | |
WiFi.forceSleepBegin(); | |
// initialize digital pin LED_BUILTIN as an output. | |
pinMode(LED_BUILTIN, OUTPUT); | |
pinMode(ctr, OUTPUT); | |
digitalWrite(ctr, HIGH); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(1000); // wait for a second | |
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW | |
delay(1000); // wait for a second | |
count++; | |
if(count==5) | |
{ | |
WiFi.forceSleepWake(); | |
digitalWrite(ctr, LOW); | |
} | |
} |
See the video of implementation and Please subscribe to my Youtube channel
If you have any doubt , Please Write it in comment :-)