Hello, I am trying to make an application that sends the temperature and humidity of a room via telegram. I have a telegram bot in another node, but I can't seem to get the basics right.
I used this code for getting the values from the DHT11 sensor with Arduino:
#include <DHT.h>
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11 (AM2302)
// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
}
String hum1;
String temp1;
void loop()
{
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
hum1 = String(hum);
temp1 = String(temp);
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum1);
Serial.print("\n");
Serial.print(temp1);
Serial.println(" Celsius");
Serial.print("\n");
delay(2000); //Delay 2 sec.
}
Then, I set up node-red for reading the values from the computer port I plugged my Arduino, but I don't know which function to write to fix these strings show in the debugger and show only the content of the humidity and the temperature.
The picture attached shows my node and the result in the debugger:
Any help will be welcome. Thanks