Help Multiple Gravity DHT20 Sensors and addressing in code?

userHead mikegold 2022-08-22 23:58:47 941 Views1 Replies

Hi everyone,


My goal is one Arduino board with multiple Temperature/Humidity sensors e.g. a DHT20  


The code to address a single sensor is at

Apologies but my two specific Questions: may be considered pretty basic- Very new to this and getting started - 


In terms of cabling two or more sensors to the arduino board - I can't see it in my head - obviously one can be connected but can multiple? Am I missing something very basic? The wiki shows the cable diagram for one sensor being connected - can I just use another set of analogue ports for a second sensor? But I would quickly run out of ports - so how deal with (extreme example) 10 sensors as an example? 


And then in terms of code - 


#include <DFRobot_DHT20.h>


 * @brief Construct the function

 * @param pWire IC bus pointer object and construction device, can both pass or not pass parameters, Wire in default.

 * @param address Chip IIC address, 0x38 in default. */


DFRobot_DHT20 dht20; void setup(){



For one sensor - the declared sensor “dht20” is addressable. For multiple sensors I would need to declare multiple DFRobot_DHT20    which I can do from a code perspective but they will not be connected to the actual multiple sensors. Is the solution to pass @param pWire IC bus pointer object and construction device  and if so how is this done? Is there a tutorial I have not found?



2022-11-04 09:41:36

Hi! Please use with this product:


On the same I2C port, DFRobot Gravity: I2C Multiplexer solves the address conflict and enables the normal communication with multiple same-address I2C devices.

userHeadPic jenna