Code execution stalls when trying to initialize more than one DHT object dynamically.
std::vector<DHT> am2301;
for (uint8_t i = 0; i < 8; i++) {
am2301.emplace_back(SENSORS[i], DHT_TYPE);
am2301[i].begin();
}
If the for loop is run just once, the code runs as it should, but on a second iteration, the code stalls at the am2301.emplace_back(...) line. The result is the same when using any other way to declare iterable objects, for example:
DHT **am2301;
am2301 = new DHT* [8];
uint8_t i;
for (i=0; i<8; i++){
am2301[i] = new DHT(SENSORS[i], DHT_TYPE);
am2301[i]->begin();
}
in which case it stalls at am2301[i] = new DHT(SENSORS[i], DHT_TYPE); on the second iteration.
Code execution stalls when trying to initialize more than one DHT object dynamically.
If the for loop is run just once, the code runs as it should, but on a second iteration, the code stalls at the
am2301.emplace_back(...)
line. The result is the same when using any other way to declare iterable objects, for example:in which case it stalls at
am2301[i] = new DHT(SENSORS[i], DHT_TYPE);
on the second iteration.