












































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













































































INDUSTRIAL INTERNET OF THINGS(20EC52I)
Aim: Interfacing LED using NODEMCU ESP Apparatus Required:
pinMode(LED_PIN, OUTPUT); // Set D1 (GPIO 5) as an output } void loop() { digitalWrite(LED_PIN, HIGH); // Turn the LED on delay(1000); // Delay for 1 second (1000 milliseconds) digitalWrite(LED_PIN, LOW); // Turn the LED off delay(1000); // Delay for 1second (1000 milliseconds) } Result:-interfacing of LED using NODEMCU ESP8266 is completed successfully.
void loop() { int buttonState = digitalRead(BUTTON_PIN); // Read the state of the button if (buttonState == LOW) { // Button is pressed (LOW) digitalWrite(LED_PIN, HIGH); // Turn on the LED } else { // Button is released (HIGH) digitalWrite(LED_PIN, LOW); // Turn off the LED } } Procedure:-
INDUSTRIAL INTERNET OF THINGS(20EC52I)
Aim:- Interfacing LED with NODEMCU to display Binary number from 0 to 7 Apparatus Required:
delay(1000); digitalWrite(D5, HIGH); digitalWrite(D6,HIGH); digitalWrite(D7,HIGH); delay(1000); } Procedure:-
INDUSTRIAL INTERNET OF THINGS(20EC52I)
Aim: To send and receive messages from long distances using the LoRa module. Apparatus Required:
Circuit Diagram: Transmitter section:
PIN configuration: 1 GND-GND. 2 NSS-D8. 3 MOSI-D7. 4 MOS0-D6. 5 SCK-D5. 6 GND-GND. 7 3.3v-3.3v. 8 GND-GND. 9 RESET-D0. 10 DIO0-D
Serial.println(data); LoRa.beginPacket(); LoRa.print(data); LoRa.endPacket(); delay(3000); } Code of Reciever section: #include <LoRa.h> #define SS 15 #define RST 16 #define DIO0 2 void setup() { Serial.begin(9600); while (!Serial); Serial.println("Receiver Host"); LoRa.setPins(SS, RST, DIO0); if (!LoRa.begin(433E6)) { Serial.println("LoRa Error"); while (1); } } void loop () { int packetSize = LoRa.parsePacket(); if (packetSize) { Serial.print("Receiving Data: "); while (LoRa.available()) { String data = LoRa.readString(); Serial.println(data); } } }
Procedure:
Serial.begin(9600); gsm.begin(9600); gsm.println("AT+CMGF=1"); delay(1000); gsm.println("AT+CMGS="+919880466676"\r"); //replace x by your number delay(1000); gsm.println("Good afternoon sir"); delay(100); gsm.println((char)26); delay(1000); } void loop(){ } PROCEDURE: Make the connections as per the circuit diagram. Connect arduino uno gnd to GSM gnd. Connect GSM TX to arduino pin2. Connect GSM RX to arduino pin3. Insert the SIM in GSM SIM socket. Give the power supply to GSM,and connect the Arduino to the laptop via data cable. Go to Arduino ide software, copy the sketch and paste in a new file. Replace your phone number and SMS in the sketch.(where you want to have the SMS) Compile and upload the sketch to Arduino uno. Result : hence ,SMS is received in the device via GSM.
INDUSTRIAL INTERNET OF THINGS(20EC52I) Experiment- Design a simple MQTT protocol-based system. The Cloud application should blink the LED & monitor the temperature using the MQTT protocol. Aim: To demonstrate an experiment on and off NodeMCU led using mqtt lens. Apparatus required:
unsigned long lastMsg = 0; #define MSG_BUFFER_SIZE(50) char msg[MSG_BUFFER_SIZE]; int value = 0; void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } randomSeed(micros()); Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void callback(char* topic, byte* payload, unsigned int length) { Serial.print("Message arrived ["); Serial.print(topic); Serial.print("] "); for (int i = 0; i < length; i++) { Serial.print((char)payload[i]); } Serial.println(); // Switch on the LED if an 1 was received as first character if ((char)payload[0] == '1') { digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because // it is active low on the ESP-01) } else { digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH } } void reconnect() { // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); // Create a random client ID String clientId = "ESP8266Client-"; clientId += String(random(0xffff), HEX); // Attempt to connect if (client.connect(clientId.c_str())) { Serial.println("connected"); // Once connected, publish an announcement... client.publish("MQTT", "hello world"); // ... and resubscribe client.subscribe("TEMP"); } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } } void setup() { pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output Serial.begin(115200); setup_wifi(); client.setServer(mqtt_server, 1883);
should get off. In the same way, type 1 in message and publish, the NodeMCU led should get on. We can also monitor and control the LED using MYMQTT app.
INDUSTRIAL INTERNET OF THINGS(20EC52I)
Aim: To simulate peer to peer communication Apparatus required: