LDR Light Sensor realtime Cloud Data Update and
Analysis on Formulation of Weather Condition
___________________________________________________________________________________________________________________
#1 Cloud Registration and IOT Web Panel
Elins Technolgies is providing cloud services to create IIOT based applications. These services are free, in order to use these services, register on Elins Cloud Server page as discussed in steps below:
Step1: Click on this icon to register :
Step2: For Registration enter your "Name" and your "email ID".
Step3: Click on "Submit" button.
This is Services page of Elins Cloud Server. Here You can select which Sensor based IIOT Ecosystem Service you wants to use, on this page, you can click on any Icon to open its IIOT Web Panel:
Watch this Video to see the Registration Process:
If you are already Registered User then Login directly through process explained below:
Step1: Click on this icon to Login :
Step2: For Login enter your "Id" which you have recieved after Registration.
Step3: Click on "Submit" button.
This is IIOT Web Panel to see Real-Time Weather Condition using LDR Sensor :
Watch this Video to see the Login process:
___________________________________________________________________________________________________________________
#1 Hardware Connections
___________________________________________________________________________________________________________________
#3 Code Explain
NodeMCU required a code to communicate with the cloud server. Let us discuss this code in detail.
Cloud Arduino code: elins_edu_ldr_code1.zip, Download it from link below:
Unzip the file and open the .INO file
Tutorial for LDR sensor Code Explain | IOT Learning Kit | Elins Cloud |
This is the Code of NodeMCU to communicate with Elins Cloud Server.
#include < Arduino.h >
#include < ESP8266HTTPClient.h >
#include < ESP8266WiFi.h >
#include < SoftwareSerial.h >
#include < DHT.h >
#include < DHT_U.h >
#define LED D0 // DECLARE LED TO PIN D0 (ON BOARD LED)
#define DHTPIN D7 // DECLARE DHTPIN TO PIN D7 (DHT11 SENSOR IS CONNECTED AT D7)
#define DHTTYPE DHT11 // SELECT DHT 11 SENSOR OF DHT SERIES
DHT_Unified dht(DHTPIN, DHTTYPE); // CREATE OBJECT dht WITH DHTPIN AND DHTTYPE
#define LDR A0 // DECLARE LDR TO PIN A0 (ANALOG PIN)
const char* ssid = "Elins Tech."; // PUT SSID OF YOUR WIFI HERE
const char* password = "jaimatadi21"; // PUT PASSWORD OF YOUR WIFI HERE
void setup() {
delay(5000);
Serial.begin(9600); // INITIALIZE UART SERIAL MONITOR TO DISPLAY EVENTS
pinMode(LED,OUTPUT); // DECLARE LED PIN AS OUTPUT PIN
pinMode(DHTPIN,INPUT); // DECLARE DHT PIN AS INPUT PIN
digitalWrite(LED,0); // INITIALIZE LED PIN WITH 0 - ON LED
// CODE TO INITIALISE DHT11 SENSOR FOR TEMPERATURE MEASUREMENT
dht.begin();
sensor_t sensor;
dht.temperature().getSensor(&sensor);
dht.humidity().getSensor(&sensor);
Serial.println();
Serial.println();
Serial.println();
WiFi.begin(ssid,password); // START WIFI CONNECTION WITH SSID PASSWORD
Serial.print("[CONNECTING] WAIT ...");
while (WiFi.status() != WL_CONNECTED) // WAIT TILL WIFI IS CONNECTED
{
delay(100);
Serial.print(".");
}
Serial.println("WIFI CONNECTED SUCCESSFULLY");
}
String payload="";
String DeviceId="juvinagrawal651"; // CHANGE IT WITH DEVICE ID RECEIVED FROM CLOUD
HTTPClient http;
int t,h;
int ldr=0;
void loop(){
// CODE TO CALCULATE TEMPERATURE FROM DHT11 SENSOR
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
t = event.temperature; // HERE TEMPERATURE IS STORED IN t VARIABLE
}
Serial.println(t);
// CODE TO CALCULATE HUMIDITY FROM DHT11 SENSOR
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
h = event.relative_humidity;
}
// CODE TO MEASURE INTENSITY OF LIGHT FROM LDR SENSOR
ldr = analogRead(LDR);
delay(100);
// CODE TO UPLOAD SENSOR DATA ON ELINS CLOUD
String URL = "";
URL = URL + "http://elinstechnologies.com/netobox_v1/http_dht_device.php?id=" + DeviceId + "&t=" + t + "&h=" + h + "&ldr=" + ldr; // CLOUD URL
http.begin(URL); // MAKE HTTP CONNECTION WITH CLOUD
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); // SPECIFY CONTENT-TYPE HEADER
int httpCode = http.GET(); // SEND HTTP GET REQUEST TO CLOUD
payload = http.getString(); // RESPONSE FROM CLOUD
Serial.println(payload); // PRINT PAYLOAD
http.end(); // Close connection
// BLINK LED TO INDICATE ONE CYCLE OF HTTP REQUEST
digitalWrite(LED,1);
delay(500);
digitalWrite(LED,0);
delay(500);
digitalWrite(LED,1);
delay(500);
digitalWrite(LED,0);
delay(500);
delay(5000);
// END OF CODE
}
___________________________________________________________________________________________________________________
#4 Working Demo
We have completed following steps upto now:
# Elins Cloud Registration (Got IIOT Web Panel from it).
# Cloud Arduino Device Code (NodeMCU is ready and communicating with Elins Cloud)
Now Let us RUN the complete IOT Ecosystem all together. For this follow the steps below:
Step1: Click on this icon to Login :
Step2: For Login enter your "Id" which you have recieved after Registration.
Step3: Click on "Submit" button.
This is IIOT Web Panel to see Real-Time Weather Condition using LDR Sensor :
Step4: Give Power supply to IOT Kit, Now device LED is blinking, it means device connected with internet.Now real-time data will be displayed on this IIOT Web Panel. To see How this IIOT Ecosystem Work all together, watch this video :
Working Demo LDR Sensor with Elins Cloud | IOT Learning Kit Extension Board | Elins Technologies
Step5: So in this way, real time data will be displayed on this IIOT Web Panel.
For next tutorial, Click NEXT.
We hope you enjoyed and learn properly how to create
complete IOT Ecosystem.
for any doubt or query email us at info@elinstechnologies.com
or Whatsapp us
# IOT LEARNING KIT
IOT Learning Kit is a development board based on NodeMCU. IOT Learning Kit Includes:
1. NodeMCU.
2. NodeMCU Board with Relay.
3. Extension Board.
4. DHT11 Temperature and Humidity Sensor.
5. Infrared Sensor.
6. SR04 Ultrasonic Sensor.
7. LDR Sensor
Actual Price : Rs.2999
For Now : Rs.1999 Only
Free Delivery
For Details: Whatsapp at +91-8750853539