I'm new to Node-Red. The project I'm working on is a thermostat circuit using arduino. Currently, I have two gauges, one reads temperature, the other reads humidity. But they both read the same result. How can I filter it so the temp gauge reads the temperature result, and humidity reads humidity? Also I will share the code I have, and a screenshot of the circuit.
#include <DHT11.h>
int in3 = 7;
int in4 = 8;
int enb = 9;
int threshold_temp = 25;
int chk;
float temperature; //Stores humidity value
float humidity; //Stores temperature value
DHT11 dht11(2);
void setup() {
Serial.begin(9600);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(enb, OUTPUT);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
String temperature;
String humidity;
}
void loop() {
int temperature = 0;
int humidity = 0;
//Attempt to read the temperature and humidity values from the DHT11 sensor.
int result = dht11.readTemperatureHumidity(temperature, humidity);
//If reading is successful, print the temperature and humidity values.
//If there are errors, print the appropriate error messages
if (result == 0){
Serial.print("Temperature: ");
Serial.print(temperature );
Serial.print("\tHumidity: ");
Serial.print(humidity);
Serial.println("%");
}else{
//Print error messages based on error code
Serial.print(DHT11::getErrorString(result));
}
if (temperature > threshold_temp) {
analogWrite(enb, 255);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}else{
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
}