Hi All, please how can I read the MAC address of the DHT22 sensor connected to the arduino uno board?
I want to connect multiple DHT22 and will need to take readings of each at thesame time and I need the MAC address of each sensor to do this. Thank you.
If you mean the DHT22 temperature/humidity sensors they do not have a mac address. Each sensor needs it's own single bi-directional digital I/O line to the Arduino. Adafruit has libraries for this sensor available on line with examples. I've never tested it but you should be able to create multiple instances of the DHT object connected to different pins.
Doug
DougMorgan:
If you mean the DHT22 temperature/humidity sensors they do not have a mac address. Each sensor needs it's own single bi-directional digital I/O line to the Arduino. Adafruit has libraries for this sensor available on line with examples. I've never tested it but you should be able to create multiple instances of the DHT object connected to different pins.
Doug
That is correct.
I have four DHT11 and two DHT22 sensors on my system at http://219.88.69.69/2WG/ - check the Recent Climate and Climate for Week web pages. You can identify the DHT22 sensor readings because they provide temperature and humidity readings to one decimal place.
All of the DHT sensors on my system simply have pin 3 plugged into separate and consecutive pins on my Arduino board. This allows all the sensors to be read within a do loop and the results to be stored within arrays. The DHT sensors all share one common power and ground connection to the Arduino board.
My only use of a MAC address is to assign one to the Arduino board and then let my router assign the board a fixed internal LAN IP address when the Ethernet.begin() procedure is invoked within the setup() procedure. By using a fixed LAN IP address on the board my router can route www http port 80 traffic coming into my broadband modem (via my external/public IP address) to the Arduino board to enable my www user interface to operate using the EthernetClient object.
On my Arduino web site as above I am publishing some of the underlying code - more will be released over the new few days (weekend).
You only need one DHT object to support multiple DHT11 and DHT22 sensors. You call DHT.read11(pin #) to read a DHT11 and DHT.read22(pin #) to read a DHT22.
After DHT.readXX you should check the result for DHTLIB_OK. After that you can access temperatures and humidity via the properties DHT.temperature and DHT.humidity.
Having multiple DHT objects would likely waste SRAM.
I use this procedure to read my mixed set of DHT sensors.
int DHTRead(byte p_sensor, int & p_temperature, int & p_humidity) {
p_temperature = 0; //D
p_humidity = 0; //D
int l_dht_result;
//We attempt to read the sensor three times to
//eliminate any temporary error - seems reqd for DHT22
byte l_count = 0;
while (true) {
if (l_count == 3)
break;
//
if (C_SensorDHT11[p_sensor] == true)
l_dht_result = DHT.read11(p_sensor + DC_DHT_Sensor_First_Pin);
else
l_dht_result = DHT.read22(p_sensor + DC_DHT_Sensor_First_Pin);
//
if (l_dht_result == DHTLIB_OK)
break;
//
delay(2000); //DHT22 needs 1.7 secs for generate a reading
l_count++;
}
if (l_dht_result == DHTLIB_OK) {
p_temperature = int((DHT.temperature + DC_Temp_UpShift) * 10);
p_humidity = int(DHT.humidity * 10);
}
return l_dht_result;
}
You will note that internally I multiply both temperature and humidity readings by ten so I can carry these values (particularly DHT22 values) internally as integers rather than floats. I also upshift temperatures by 35 degrees C so I can use the number zero as a NULL value since my local temperature will never be minus 35 degrees C.
Having to use multiple pins for each DHT22 sensor kind of defeats the reason we use I2C. but then for some reason there are heaps of manufacturers out there who seem to think its a great idea to hardcode the address in limiting your ability to chain devices on the same interface.
Dallas 1 wire temperature sensors to the rescue again, OK so they will not spit out the humidity but at least you can chain them all up on one pin.