Multiple Gravity DHT20 Sensors - and addressing in code?!
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
Hi - my goal is one Arduino board with multiple Temperature/Humidity sensors e.g. a DHT20
The code to address a single sensor is at https://wiki.dfrobot.com/Gravity_I2C_Temperature_Humidity_Sensor_DHT20_SKU_SEN0497
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 persecptive 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?
Hi, DHT20 is an IIC communication, you can use the IIC expansion module to connect the same IIC sensors, up to 64 connections.
https://www.dfrobot.com/product-1780.html
![userHeadPic](https://dfimg.dfrobot.com/628da052aa9508d63a41e164/makelog/708f8ea66c513e3a46e39f2b938a2985_50x50.jpg)