I have a code for two DHT sensors but for some reason the serial print adds "1" before the temperature and humidity values in the case of both sensors (e.g. 123.25 C, 148.12 %).
I assume that I should use the string.remove command but I'm kinnda new in this programming field so I don't know how to put it there correctly to make it work. I tried a lot after reading the general arduino string.remove tutorials and syntax but it still does not work...
My code:
#include <DHT.h>;
#define DHTPIN1 7
#define DHTPIN2 6
DHT dht[] = {
{DHTPIN1, DHT11},
{DHTPIN2, DHT22},
};
float humidity[2];
float temperature[2];
void setup()
{
Serial.begin(9600);
for (auto& sensor : dht) {
sensor.begin();
}
}
void loop()
{
for (int i = 0; i < 2; i++) {
temperature[i] = dht[i].readTemperature();
humidity[i] = dht[i].readHumidity();
}
for (int i = 0; i < 2; i++) {
Serial.print(F("Temperature "));
Serial.print(i);
Serial.println(temperature[i]);
Serial.print(F("Humidity "));
Serial.print(i);
Serial.println(humidity[i]);
}
delay(5000);
}