Introduction: 8 Relay Control With NodeMCU and IR Receiver Using WiFi and IR Remote and Android App
Controlling 8 relay switches using nodemcu and ir receiver over wifi and ir remote and android app.
the ir remote works independent of wifi connection.
Step 1: Grab the Parts
Things you required for this project
- 4 channel Relay Module x 2
- IC7805 x 2 (1 IC7805 doesnot provide enough current to power on 8 relays at same time)
- IR Receiver (VS1838)
- LED Red x 1
- Resistance 1K x 1
- Push Button x 1
- Jumper Wires
- Power Supply
Step 2: The Code
THIS CODE IS FOR NODEMCU BOARD NOT ARDUINO
I have written the code in a way so that if WiFi gets disconnected or not available, the LED will glow, and the relay control from IR Remote will go on independent of WiFi.
When WiFi is available press the push button or press the dedicated button on IR Remote and wait for 5sec to connect to wifi. If the LED doesn't turns off then the wifi is not connected.
First download Arduino IDE from HERE.
Then go to File -> Preferences, then on additional board manager urls, add this
Then go to Board manager and install esp8266 by ESP8266 Community.
go to library manager and install IRRemoteESP8266.
First connect the ir receiver to nodemcu board, 3.3v to 3.3v, gnd to gnd, output to gpio2(D4).
upload the sketch IRRemote Value given below, open serial monitor and press remote key to get the values of each key, write it down somewhere. Note at least 9 key values, (8 values for 8 relays and 1 for reconnect wifi).
Then make the circuit as the schematic given above and upload the code My_Room.
Don't forget to modify the ir codes in the my_room sketch with the ir code you got for each button on the remote and the wifi ssid and password.
NOTE: WHILE UPLOADING THE SKETCH MAKE SURE NOT TO CONNECT ANYTHING TO THE PIN D0, D8, TX, RX. OR SIMPLY PULL OFF THE JUMPER WIRES FROM THOSE PINS.
Step 3: Schematic
Follow the schematic and make the circuit.
IC7805 doesnot have enough power to run 8 relays at same time. So, we are using two 4ch Relay module and two IC7805.
Any IR Receiver will work.
Power Supply can be 24V max.
Step 4: Android App
I have made the Android App using MIT APP Inventor.
You can upload the aia file to App Inventor and edit it.
Step 5: You Did It
Go to your router admin panel and get the IP Address of the NodeMCU.
Also assign a particular IP to the Mac Address of nodemcu, so that it gets the same ip, every time and you dont have to check it every time.
YOU CAN USE IR REMOTE, ANDROID APP AND INTERNET BROWSER ON SAME NETWORK, OR YOU CAN USE PORT FORWARDING IN YOUR ROUTER TO ACCESS OVER INTERNET FROM ANYWHERE IN THE WORLD.
In case of problem, contact me on fb, www.fb.com\amit.s.samanta , i will help as far as i can.