IoT Wifi Board With SMPS & Relay (2 O/P & 2 I/P)
IoTLABZ introduce a new Relay IOT board that can be easily used for industrial or home automation projects and experiments. This is a Two Relay board which has esp8266 on board chip and also has 100-230VAC to 5V DC converter on the same board.Relay has three connections – Common – C, Normally Open-NO, Normally Closed-NC brought out to 3 pin screw terminals which makes it easy to make and remove connections.The board can be programmed using FTDI/CP2102. The board is manufactured with Automatic Pick and place machine with high quality standard. We can control the on-board relay from the cloud using wifi connectivity or develop your own firmware
The wifi module used to receive commands from network and activate load through relay by executing the program written in wifi module(esp8266). The onboard SMPS module is mounted on the board so that you can supply 5V DC from 120V AC – 230V AC and has a power rating of 3 Watt. This make it perfect for small projects that needed a 5V supply from mains.
There is an option for 2 inputs (2 pin RMC connector) which can be used as switch to control relay and a 3 pin RMC connector which you can interface with analog input.
FEATURES
- Based on ESP-07 ESP8266 Wifi Board.
- Onboard SMPS module is used to convert 120V-230V AC to 5V DC.
- The relay board uses one AC input and a Two relay AC output.
- Relay Specification:YL303H-S-5VDC.
- Three pin RMC connector for connecting Sensor(ADC pin).
- Two pin Screw terminals are used to connect Input AC .
- Three pin Screw terminals are used to connect Output AC .
- Two pin RMC connector to give Input.
CONNECTORS
PINS USED
Before programming in Arduino IDE, we want to first install third party package using board manager.
- Install Arduino from Arduino website.
- Start Arduino and open ‘PREFERENCES‘ from ‘FILE‘ menu.
- Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into additional board manager URL field. We can add multiple URL separating them with commas.
- Open Board Manager from Tools and install esp8266 platform in the board menu.
- Select the Board and COM port of the device to be connected.
In this post an android application to control the IOT relay board. An Application running on Android phone will get the sensor value from IOT device and it will be displayed on the Application. The relay on the board are controlled using the Android Application.
HARDWARE CONNECTIONS
- Connect the devices to NC (Normally Closed)/NO (Normally Open) screw terminal connector (K4,K5) and connect the Input voltage to Common C.
- Power the module by connecting the Line and Neutral to screw terminal connector K6.
- Connect the sensor(ADC) to RMC connector (K7).
- Connect the Input devices (Switch) to K1 and K2
- Upload the code by connecting FTDI/CP2102 to K3.
How to Upload code to IOT Relay board
- Put J1 jumper .
- Connect the FTDI on the connector(K3).
- Press the Reset button on the board.
- Press the Upload button on Arduino IDE.
How to connect the board to android application
- In our examples the IOT Relay board is set as Server and it is connected to a router. The mobile is connected to the same router.The Android Application is connected to the IOT Relay board using TCP/IP protocol (Here we are using Connection terminal and Wifi automation APP).
- Enter the IP and Port number and press connect button.
- After connecting open terminal (If you want to send data to server enter data and press send button. You can see the response in Data Received terminal).
- Upload the following codes given below to control board.
Sample code for checking Relay
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#include <ESP8266WiFi.h> const char* ssid = "******"; const char* password = "**********"; WiFiServer server(2050); #define RELAY1 13 #define RELAY2 12 char Rx_data=0; void setup() { pinMode(RELAY1,OUTPUT); pinMode(RELAY2,OUTPUT); Serial.begin(115200); delay(10); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Print the IP address Serial.println(WiFi.localIP()); // Start the server server.begin(); Serial.println("Server started"); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("new client"); while(client.connected()) { while( client.available() ) // while client is connected { Rx_data = client.read(); // Relay 1 if( Rx_data =='A') //Checking the incoming data { digitalWrite(RELAY1, HIGH); //Relay 1 ON Serial.println("Relay1 On"); } if( Rx_data =='a') //Checking the incoming data { digitalWrite(RELAY1, LOW); //Relay 1 OFF Serial.println("Relay1 Off"); } if( Rx_data =='B') //Checking the incoming data { digitalWrite(RELAY2, HIGH); //Relay 2 ON Serial.println("Relay2 On"); } if( Rx_data =='b') //Checking the incoming data { digitalWrite(RELAY2, LOW); //Relay 2 OFF Serial.println("Relay2 Off"); } } } } |
Click on Buttons in app to control the devices
Sample code for Reading Sensor(ADC pin)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#include <ESP8266WiFi.h> const char* ssid = "***********"; const char* password = "************"; WiFiServer server(2050); const int analogInPin = A0; int sensorValue = 0; void setup() { Serial.begin(115200); delay(10); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Print the IP address Serial.println(WiFi.localIP()); // Start the server server.begin(); Serial.println("Server started"); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("new client"); while(client.connected()) { sensorValue=analogRead(analogInPin); client.println(sensorValue); delay(500); while( client.available() ) // while client is connected { char Rx_data= client.read(); client.print(Rx_data); } } } |
OUTPUT
Sample code for checking digital pins
Power the board and upload the code using FTDI/CP2102(Put J1 jumper while uploading the code.After uploading remove the jumber and press reset button) . Connect the android app with the IOT board as described above.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
#include <ESP8266WiFi.h> const char* ssid = "***********"; const char* password = "************"; WiFiServer server(2050); const int buttonPin1 = 4; // the number of the pushbutton pin const int buttonPin2 = 5; // the number of the pushbutton pin void setup() { pinMode(buttonPin1,INPUT); pinMode(buttonPin2,INPUT); Serial.begin(115200); delay(10); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Print the IP address Serial.println(WiFi.localIP()); // Start the server server.begin(); Serial.println("Server started"); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("new client"); while(client.connected()) { if(digitalRead(buttonPin1)==LOW) {client.println("Button 1 Pressed");while(digitalRead(buttonPin1)==LOW);} //Checking if pin is low or high if(digitalRead(buttonPin2)==LOW) {client.println("Button 2 Pressed");while(digitalRead(buttonPin2)==LOW);} //Checking if pin is low or high while( client.available() ) // while client is connected { char Rx_data= client.read(); client.print(Rx_data); } } } |
OUTPUT
Resources
How to Buy
Click here to buy IoTLabz IoT Wifi Board With SMPS & Relay (2 O/P & 2 I/P).
Leave a Reply
You must be logged in to post a comment.