Writing Multiple Fields with My API Key and DHT11
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
ack = 0;
int chk = DHT.read11(DHTXXPIN);
switch (chk)
{
case DHTLIB_ERROR_CONNECT:
ack = 1;
break;
}
if (ack == 0)
{
Serial.print("Temperature(*C) = ");
Serial.println(DHT.temperature, 0);
Serial.print("Humidity(%) = ");
Serial.println(DHT.humidity, 0);
Serial.println("-------------------------");
//------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
//------------------------------------//
delay(2000);
}
if (ack == 1)
{
Serial.print("NO DATA");
Serial.print("\n\n");
delay(2000);
}
}
//-------------Electronics-project-hub>com-------------//
0 comentarios
Respuestas (1)
Christopher Stapels
el 21 de Dic. de 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?
0 comentarios
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Ver también
Categorías
Más información sobre Write Data to Channel en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!