Writing Multiple Fields with My API Key and DHT11

3 views (last 30 days)
MATTHEW SKVASIK on 17 Dec 2020
Hello, I am new at all of this. I am using the Example Sketch from THinkspeak Library. I have a ESP8266 ESP-01, and a DHT11 sensor that I am trying to write to a Thinkspeak Dashboard. From the example code, I have all Keys working, and the wifi connecting. From the example code in the library , I do not know how to get the Arduino Uno's code with the DHT11 to talk to the wifi code that is loaded from the Thinkspeak Library onto the wifi board.
As far as I can tell the example code is telling it to write random numbers to my channels, which it is successfully doing! However, how do I get the sensor's data to be loaded instead. Below is the code for the DHT11 that I am loading onto the Uno. How do I get it to talk to the wifi Board to then write it to the field/channels on the Thinkspeak site?
My apologies if this is a basic question.
#include <dht.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
dht DHT;
#define DHTXXPIN 2
int ack;
void setup()
void loop()
ack = 0;
int chk = DHT.read11(DHTXXPIN);
switch (chk)
ack = 1;
if (ack == 0)
Serial.print("Temperature(*C) = ");
Serial.println(DHT.temperature, 0);
Serial.print("Humidity(%) = ");
Serial.println(DHT.humidity, 0);
//------Sending Data to ESP8266--------//
mySerial.print('*'); // Starting char
mySerial.print(DHT.temperature, 0); //2 digit data
mySerial.print(DHT.humidity, 0); //2 digit data
mySerial.println('#'); // Ending char
if (ack == 1)
Serial.print("NO DATA");

Answers (1)

Christopher Stapels
Christopher Stapels on 21 Dec 2020
Do you need the Uno to take your data? I would reccomend directly programming the ESP to conenct and write to thringspeak (using the UNO to program the esp).
If you still want to use the esp as a bridge to thingspeak, can you share the code that is running on the esp please?


More Answers in the  ThingSpeak Community


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!