Multiple Gravity DHT20 Sensors - and addressing in code?!

userHead SsadfJ 2022-07-24 02:24:28 1133 Views1 Replies

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?

 

 

 

 

 

2022-11-02 10:40:39

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 Winster