Components and supplies
1
Jumper wires (generic)
1
Breadboard (generic)
1
Gravity: Analog Soil Moisture Sensor For Arduino
1
Arduino UNO
1
DHT11 Temperature & Humidity Sensor (3 pins)
1
ESP8266 ESP-01
Apps and platforms
1
Arduino Web Editor
1
Arduino IDE
Project description
Code
code
arduino
upload the code arduino
1#include <SoftwareSerial.h> 2#include <dht11.h> 3#define ldrPIN 1 4String agAdi = "Your network name"; 5String agSifresi = "Your network password "; 6 7const int prob = A0; 8int rxPin = 10; 9int txPin = 11; 10int dht11Pin = 2; 11int olcum_sonucu; 12int light = 0; 13 14String ip = "184.106.153.149"; //please dont change ip 15float sicaklik, nem; 16 17dht11 DHT11; 18 19SoftwareSerial esp(rxPin, txPin); 20 21void setup() { 22 23 Serial.begin(9600); 24 Serial.println("Started"); 25 esp.begin(115200); 26 esp.println("AT"); 27 Serial.println("AT send "); 28 while (!esp.find("OK")) { 29 esp.println("AT"); 30 Serial.println("ESP8266 Not find."); 31 } 32 Serial.println("ok command received"); 33 esp.println("AT+CWMODE=1"); 34 while (!esp.find("OK")) { 35 esp.println("AT+CWMODE=1"); 36 Serial.println("setting ..."); 37 } 38 Serial.println("Set as client"); 39 Serial.println("connecting to network"); 40 esp.println("AT+CWJAP=\\"" + agAdi + "\\",\\"" + agSifresi + "\\""); 41 while (!esp.find("OK")); 42 Serial.println("Connected to the Network."); 43 delay(1000); 44} 45void loop() { 46 esp.println("AT+CIPSTART=\\"TCP\\",\\"" + ip + "\\",80"); 47 if (esp.find("Error")) { 48 Serial.println("AT+CIPSTART Error"); 49 } 50 DHT11.read(dht11Pin); 51 sicaklik = (float)DHT11.temperature; 52 nem = (float)DHT11.humidity; 53 olcum_sonucu = (float)analogRead(prob); 54 light = map(analogRead(ldrPIN), 1023, 0, 0, 100); 55 String veri = "GET https://api.thingspeak.com/update?api_key=YOUR Api Key here"; 56 veri += "&field1="; 57 veri += String(sicaklik); 58 veri += "&field2="; 59 veri += String(nem); 60 veri += "&field3="; 61 veri += String(olcum_sonucu); 62 veri += "\ \ 63\ \ 64"; 65 esp.print("AT+CIPSEND="); 66 esp.println(veri.length() + 2); 67 delay(2000); 68 if (esp.find(">")) { 69 esp.print(veri); 70 Serial.println(veri); 71 Serial.println("data send."); 72 delay(1000); 73 } 74 Serial.println("Connection Closed."); 75 esp.println("AT+CIPCLOSE"); 76 delay(1000); 77} 78
code
arduino
upload the code arduino
1#include <SoftwareSerial.h> 2#include <dht11.h> 3#define ldrPIN 1 4String agAdi = "Your network name"; 5String agSifresi = "Your network password "; 6 7const int prob = A0; 8int rxPin = 10; 9int txPin = 11; 10int dht11Pin = 2; 11int olcum_sonucu; 12int light = 0; 13 14String ip = "184.106.153.149"; //please dont change ip 15float sicaklik, nem; 16 17dht11 DHT11; 18 19SoftwareSerial esp(rxPin, txPin); 20 21void setup() { 22 23 Serial.begin(9600); 24 Serial.println("Started"); 25 esp.begin(115200); 26 esp.println("AT"); 27 Serial.println("AT send "); 28 while (!esp.find("OK")) { 29 esp.println("AT"); 30 Serial.println("ESP8266 Not find."); 31 } 32 Serial.println("ok command received"); 33 esp.println("AT+CWMODE=1"); 34 while (!esp.find("OK")) { 35 esp.println("AT+CWMODE=1"); 36 Serial.println("setting ..."); 37 } 38 Serial.println("Set as client"); 39 Serial.println("connecting to network"); 40 esp.println("AT+CWJAP=\\"" + agAdi + "\\",\\"" + agSifresi + "\\""); 41 while (!esp.find("OK")); 42 Serial.println("Connected to the Network."); 43 delay(1000); 44} 45void loop() { 46 esp.println("AT+CIPSTART=\\"TCP\\",\\"" + ip + "\\",80"); 47 if (esp.find("Error")) { 48 Serial.println("AT+CIPSTART Error"); 49 } 50 DHT11.read(dht11Pin); 51 sicaklik = (float)DHT11.temperature; 52 nem = (float)DHT11.humidity; 53 olcum_sonucu = (float)analogRead(prob); 54 light = map(analogRead(ldrPIN), 1023, 0, 0, 100); 55 String veri = "GET https://api.thingspeak.com/update?api_key=YOUR Api Key here"; 56 veri += "&field1="; 57 veri += String(sicaklik); 58 veri += "&field2="; 59 veri += String(nem); 60 veri += "&field3="; 61 veri += String(olcum_sonucu); 62 veri += "\ \ 63\ \ 64"; 65 esp.print("AT+CIPSEND="); 66 esp.println(veri.length() + 2); 67 delay(2000); 68 if (esp.find(">")) { 69 esp.print(veri); 70 Serial.println(veri); 71 Serial.println("data send."); 72 delay(1000); 73 } 74 Serial.println("Connection Closed."); 75 esp.println("AT+CIPCLOSE"); 76 delay(1000); 77} 78
Downloadable files
shematic
shematic

shematic file
shematic file
shematic file
shematic file
shematic
shematic

Comments
Only logged in users can leave comments