Pages: [1]   Go Down
Author Topic: Hot Swappable 1-Wire and DHT22  (Read 754 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am having a play around with the Arduino, to use it to record temperature measurements (using the 1-Wire Network), in addition to Temperature and Humidity measurements using the DHT22 Sensor. The test run works, and outputs delimited data to the serial port, which a simple VB.Net app can work with to store the data in a database.

The issue I am having though, is that I want the system to be hot swappable, and be able to remove, or add sensors whilst it is running. The 1-Wire system reports the ID of the sensor, and the temperature, so it does not matter if another sensor gets added or removed (at least to the vb.net side) and the DHT22 sensors will be tied to specific pins, that is pins X through Y will be used, so I don't mind if different sensors get plugged in (at least if DHT22 - Sensor 1 gets plugged into pin x instead of Y.

My question is, how can i configure the wiring, or the code to allow me to be able to plug in new sensors, or remove old ones without having the unit reset?

Thanks for your help smiley
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1018
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use the OneWire library with the examples for the DS18B20, the bus is scanned for every DS18B20, and the checksum is calculated to be sure the data is correct.

I did some tests, and I could add and remove sensors runtime without problems.

You might have some data corruption if there is communication going on and you add or remove sensors. But you just get an checksum error, so you can detect a wrong value.

I forgot what the DHTxx communication looks like. But looking at the Adafruit code, there is a timeout in the code. So this should be no problem (I hope).
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8821
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Set all the DHT22 pins to OUTPUT and HIGH.  You pulse the line LOW and switch to INPUT_PULLUP.  If the line does not get pulled low within a very short time there is no DHT22 on that line.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: