****************** Aurdino DH11 Hardware ************************** #include // Include Adafruit DHT11 Sensors Library #define DHTPIN 7 // DHT11 Output Pin connection #define DHTTYPE DHT11 // DHT Type is DHT11 DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor void setup () { dht.begin(); pinMode(6,OUTPUT); Serial.begin(9600); // To see data on serial monitor } void loop (){ float H = dht.readHumidity(); //Read Humidity float T = dht.readTemperature(); // Read temperature as Celsius // Check if any reads failed and if exit if (isnan(H) || isnan(T)) { Serial.println("Failed to read from DHT sensor!"); return; } // Combine Humidity and Temperature into single string String dhtData = String(H) + "," + String(T); Serial.println(dhtData); if(H > 50){ digitalWrite(6,HIGH); // LED is now ON } else{ } digitalWrite(6,LOW); // LED is now OFF delay(2000); // Wait two seconds between measurements } **************** Gas Sensor **************************** int LED = 13; int MQ2pin = A0; void setup() { Serial.begin(9600); } void loop() { float sensorValue; sensorValue = analogRead(MQ2pin); if(sensorValue >= 250) { digitalWrite(LED,HIGH); Serial.print(sensorValue); Serial.println("GAS DETECTED"); } else { digitalWrite(LED,LOW); Serial.print("Air quality in ppm is : "); Serial.println(sensorValue); } delay (1000); } ******************* TINKER CAD SMART STREET LIGHT , SOIL MOISTURE LEVEL ***************** SMART LIGHT ----------------------> int ldr_pin = A5; int ldr_value; int light = 3; void setup() { pinMode(light, OUTPUT); pinMode(ldr_pin, INPUT); } void loop() { ldr_value = analogRead(ldr_pin); if (ldr_value > 512) digitalWrite(light, 0); else digitalWrite(light, 1); } SOIL MOISTURE --------------------> int moisture_data = 0; void setup() { pinMode(A0, INPUT); Serial.begin(9600); pinMode(12, OUTPUT); pinMode(6, OUTPUT); } void loop() { moisture_data = analogRead(A0); Serial.println(moisture_data); if (moisture_data < 21) { digitalWrite(12, HIGH); digitalWrite(6, HIGH); } else { digitalWrite(12, LOW); digitalWrite(6, LOW); } delay(10); // Delay a little bit to improve simulation performance } ************************** SOIL MOISTURE SENSORE - IR LDR ******************* intasensor=A2; //Define pin for A0 pin of the sensor intdsensor=4; //Define pin for D0 pinof the sensor voidsetup(){ Serial.begin(9600); //Set baud rate for serial communication }voidloop(){ intasensorData=analogRead(asensor); //Read analog datat from the sensor intdsensorData=digitalRead(dsensor); //Read digital data from the sensor Serial.print(" A Sensor Data:"); Serial.println(asensorData); //Print analog data on the serial monitor Serial.print(" D Sensor Data:"); Serial.println(dsensorData); //Print digital data on the serial monitor delay(1000);} var m = msg.playload.split(",") var H = {payload: parseFloat(m[0])}; var T = {payload: parseFloat(m[1])}; return [H, T]; #include #define DHTPIN 7 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); void setup () { dht.begin(); Serial.begin(9600); } void loop (){ float H = dht.readHumidity(); float T = dht.readTemperature(); if (isnan(H) || isnan(T)){ Serial.println("Failed to read from DHT sensor!"); return; } String dhtData = String(H) + "," + String(T); Serial.println(dhtData); delay(2000); } int red1=8; int green1=6; int yellow1=7; int red2=3; int green2=5; int yellow2=4; const int pingPin = 10; // Trigger Pin of Ultrasonic Sensor const int echoPin = 9; // Echo Pin of Ultrasonic Sensor const int pingPin2 = 12; // Trigger Pin of Ultrasonic Sensor const int echoPin2 = 11; // Echo Pin of Ultrasonic Sensor void setup() { // put your setup code here, to run once: pinMode(red1,OUTPUT); pinMode(red2,OUTPUT); pinMode(yellow1,OUTPUT); pinMode(yellow2,OUTPUT); pinMode(green1,OUTPUT); pinMode(green2,OUTPUT); } void loop() { // put your main code here, to run repeatedly: int distance1,distance2; distance1=calculatedistance(pingPin , echoPin); distance2=calculatedistance(pingPin2 , echoPin2); if(distance1>=distance2){ digitalWrite(red1,LOW); digitalWrite(green2,LOW); digitalWrite(red2,LOW); digitalWrite(green1,LOW); digitalWrite(yellow1,HIGH); digitalWrite(yellow2,HIGH); delay(200); while(distance1>distance2){ distance1=calculatedistance(pingPin , echoPin); distance2=calculatedistance(pingPin2 , echoPin2); digitalWrite(red1,HIGH); digitalWrite(green2,HIGH); digitalWrite(red2,LOW); digitalWrite(green1,LOW); digitalWrite(yellow1,LOW); digitalWrite(yellow2,LOW); } } if(distance2>distance1){ digitalWrite(red1,LOW); digitalWrite(green2,LOW); digitalWrite(red2,LOW); digitalWrite(green1,LOW); digitalWrite(yellow1,HIGH); digitalWrite(yellow2,HIGH); delay(200); while(distance2>distance1){ distance1=calculatedistance(pingPin , echoPin); distance2=calculatedistance(pingPin2 , echoPin2); digitalWrite(red1,LOW); digitalWrite(green2,LOW); digitalWrite(red2,HIGH); digitalWrite(green1,HIGH); digitalWrite(yellow1,LOW); digitalWrite(yellow2,LOW); } } } long microsecondsToCentimeters(long microseconds) { return microseconds / 29 / 2; } int calculatedistance(int pingPin , int echoPin){ long duration, inches, cm,meter; pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(10); digitalWrite(pingPin, LOW); pinMode(echoPin, INPUT); duration = pulseIn(echoPin, HIGH); cm = microsecondsToCentimeters(duration); meter = cm/100; return meter; }