https://toitlang.org/ logo
too many DHTXX devices ?
# help
k
For plant cultivation, I would like to use several DHTxx sensors to check the favorable germination environment. The prototype uses an ESP32 'wroom'. Four sensors can be configured in the application. An exception error is generated when initializing the fifth sensor:
Copy code
EXCEPTION error.
ALREADY_IN_USE
   0: gpio-use_                 <sdk>\gpio\gpio.toit:855:5
The Toit DHTxx package uses RMT-devices. ESP32 shout provide 8 RMT channels. Is it possible to use more than 4 devices on an ESP32-Wroom ?
f
We are using two RMT channels per device. One for reading and one for writing. And they have to run at the same time...
You could just close the ones you are currently not using and just run through them one by one
k
that explains it💡
f
The protocol of the dht is also slow enough that it works in software. Not super reliably, but still.
Fwiw I prefer the ds18b20 (temperature only) and the bmw280 (i2c).
k
👍🏻 Thank You, I will try to close the channels after use.
It works !
Copy code
close: //driver.close: not implemented
    driver.channel-in_.close
    driver.channel-out_.close
has caused it:
Copy code
- DHTXX-1: T:22.4 °C, H:28.1 %, Habs: 5.6 g/m^3
 - DHTXX-2: T:23.3 °C, H:29.7 %, Habs: 6.2 g/m^3
 - DHTXX-3: T:19.7 °C, H:92.1 %, Habs:15.6 g/m^3
 - DHTXX-4: T:20.0 °C, H:74.2 %, Habs:12.8 g/m^3
 - DHTXX-5: T:19.9 °C, H:99.9 %, Habs:17.2 g/m^3
 - DHTXX-6: T:19.2 °C, H:67.6 %, Habs:11.1 g/m^3
 - DHTXX-7: T:19.3 °C, H:65.4 %, Habs:10.8 g/m^3
 - DHTXX-8: T:19.9 °C, H:58.0 %, Habs:10.0 g/m^3
f
you are right: we forgot to implement
close
. I will do that. Thanks.
v1.6.0 has been released. if you update the dhtxx driver you should be able to just call
driver.close
.
k
🌩️ faster than lightning strikes !