How to send sensor dat to thingspeak server using ESP and Arduino.

preview_player
Показать описание
#Thingspeak #SendingDataToServer #IoT

Set the Baud Rate of ESP to 9600 using AT Command (AT+CIOBAUD=9600) or you can use (AT+UART_DEF=9600,8,1,0)

Before downloading please watch the full video to know about the procedure of how to send data because it will help you to understand the protocol and you can build many more things.
In this tutorial, I am explaining how to test the ESP8266-01 module using Arduino UNO and
send sensor data into thingspeak server.

Requirements:
#1. Arduino UNO
#2. ESP8266-01 wifi module
#3. DHT-11 sensor
#4. Thingspeak server.

IoT projects Arduino
esp8266 wifi module Arduino
esp8266 wifi module
IoT projects ideas
IoT projects with Arduino
IoT projects esp8266
what are iot projects

Best Cloud Hosting:

Email Marketing tool:

Download Source Code:

🪔 Please help to grow my channel by subscribing to my channel:
👉 You can visit my website and find interesting projects.
🚮💲 if you want to contribute:

⚡🌟⚡🌟 More Projects below🌟⚡🌟⚡

🧸 Game using Arduino

📡 Notice board projects

🏡 Home Automation Projects
🔥 Firebase Based Home Automation
☁ Google Assistance Home Automation

⏱ RTC Projects
🕜 Schedule ON/OFF devices using RTC

🕜 Timer, Stopwatch, and Alarm

🔌💡 AC voltage controlling Projects

👉 ⛅🌈Weather Monitoring Project

👉🖨️ Thermal Printing Machine DIY

⚠️Disclaimer: It contains Amazon affiliate links. which means I can get a small commission on the sale.
This might be your indirect help to me.

🌟 Material Requirements:
Рекомендации по теме
Комментарии
Автор

*Updated Code Edited Code*

Before uploading my code.
Step 1: remove the ic ATmega328 of arduino.
Step 2: connect Rx of arduino to Rx of ESP and Tx of arduino to Tx of ESP.
Step 3: Open serial monitor of arduino and set baud at 115200 and Both NL&CR
Step 4: Send AT it should return OK then AT+CIOBAUD=9600 it should return OK if not then write AT+UART_DEF=9600, 8, 1, 0 it should return OK.
Step 5: change the serial monitor setting to baud rate at 9600 and Both NL&CR.
Step 6: change the mode of ESP by sending AT+CWMODE=3 it should return OK
Step 7: upload my code and test




#include <dht.h>
#include <SoftwareSerial.h>
String apiKey =

dht DHT;
#define DHT11_PIN 4
int humi, temp;
SoftwareSerial ser(2, 3); // RX, TX
void setup(){
ser.begin(9600);
Serial.begin(9600);
unsigned char check_connection=0;
unsigned char times_check=0;
Serial.println("Connecting to Wifi");
while(check_connection==0)
{
Serial.print("..");
ser.print("AT+CWJAP=\"SSID\", \"PASSWORD\"\r\n");
ser.setTimeout(5000);
if(ser.find("WIFI CONNECTED\r\n")==1 )
{
Serial.println("WIFI CONNECTED");
break;
}
times_check++;
if(times_check>3)
{
times_check=0;
Serial.println("Trying to Reconnect..");
}
}
delay(5000);
}
void loop()
{
DHT.read11(DHT11_PIN);
humi=DHT.humidity;
temp=DHT.temperature;
Serial.print("H:");
Serial.print(humi);
Serial.println("%");
Serial.print("T:");
Serial.print(temp);
Serial.println("C");
// TCP connection
String cmd = "AT+CIPSTART=\"TCP\", \"";
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\", 80";
ser.println(cmd);
if(ser.find("Error")){
Serial.println("AT+CIPSTART error");
return;
}
// prepare GET string
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr +="&field1=";
getStr += String(10);
getStr +="&field2=";
getStr += String(10);
getStr += "\r\n\r\n";

// send data length
cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
ser.println(cmd);

if(ser.find(">")){
ser.print(getStr);
Serial.println(getStr);
}
else{
ser.println("AT+CIPCLOSE");
Serial.println("CIPCLOSE");
}

// thingspeak needs 15 sec delay between updates
delay(16000);
}

MyEngineeringStuffs
Автор

Excellent tutorial....Thank you very much for creating such an informative tutorial. appreciated.

sameerk
Автор

This has been very helpful! Thank You!

collabcostarica
Автор

Thank you for sharing valuable information 🙏🏽

cattyom
Автор

I am using ACS 712 voltage sensor and ZMPT101B current sensor I will have to upload the data to thingspeak. I am doing this for my small electricity monitoring system but I don't have any prior knowledge of it. I need your help.

zeeshaniqbal
Автор

Sir, what if I use an MQ-2 gas sensor? What codes should I replace or on this current code then?

vonchristianmartycabel
Автор

Hey! I have issues with fetching data FROM api on web on my arduino. Can you tell me what to program on arduino and what to program on esp8266? Can i upload the code just to arduino and then communicate with esp?
Thank you.
M

MatthewScope
Автор

thank you so much for the video, you really gave me the hint for doing my project.

elijahturatsinze
Автор

Thank you very much my friend, you really helped me.

Sebastian-wjgy
Автор

i tried this in IDE 1.8.9 but the code is failing in all kinds of ways.
dht.begin does not work, and after trying that to solve i bump into
warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] on if(ESP8266.find(">"))

sheeva
Автор

Hey i am using nodemcu for the same project but everytime i open my serial monitor it just shows trying to reconnect.

amishverma
Автор

How did you get the datas uploaded to ThingSpeak. I tried the same code. It is not working . But tried without any codes with AT command. It worked . But with this code. It doesn't

sumaiyatabasum
Автор

I m trying to upload the ultrasonic sensor data but its not getting upload.

ashishranjan
Автор

Hello,

I am trying to connect it with the wifi, but its getting failed. I have checked all the connections upto ic pins. Checked tge ssid and password through ip also. But the problem still persists. Could u plz suggest how to solve it? I have designed the circuit without the resistors.

soudeepsil
Автор

is that a resitor on that wifi module? why did ypu solder it? if you soldered whats the resistence value and what pins you connected?

subinkrishnakt
Автор

it is showing "'writeThingSpeak' was not declared in this scope" What to do now

ajayupadhyay
Автор

Nice detailed video.. I have a query.. how can I insert an rf module data instead of the DHT/. any help will be really appreciated

hrisaris
Автор

hi nice video but i m new in arduino and i cant look clearly where you put wire into ESP8266
i want to know, can you help me

linyukcheung
Автор

Can you develop code for resistance measurement instead of temp and humidity measurement

turulob
Автор

thanks a ton sir for uploading this video

sruthimolt