Using DHTxx or separate sensors with Remote Xbee

Hello all.

My comment doesn't fit perfectly in a single subforum, but wherever the Mod says it goes is great.

Prologue
I am using 2 Xbee S1's and 1 Arduino Yun for data transmitting, and then responding to that data to turn on AC equipment.
At this time please assume my Xbees communicate properly using a Coordinator Xbee in API mode and a Remote Xbee in AT mode. SoftwareSerial is used for the serial communication between YUN and the Xbees, and I have the relays correctly setup and controlled by digital pin assignment to the Xbee at the proper time or condition. Also, I realize that I can use the YUN to communicate directly with the DHTxx sensors and do relay interaction. (That part is a done deal)

Supposition
As I read through the DHT.cpp file under the function 'boolean DHT::read(void)' and the user manual for the DHTxx it is obvious that the DHT does not transmit continuously, and because of that I must make all changes through sending various API Frames to my Remote xbee to match what would normally happen in the DHT library if it were working through the Arduino on its own pin :

  1. Mandatory 2 second delay between readings, then
  2. Have pin voltage initially HIGH at least 250 ms, then
  3. Change my chosen Xbee pin to a Digital pin OUTPUT LOW-for 20 ms
  4. Then change Digital pin OUTPUT HIGH for 40 ms
  5. Then initiate data transmission by changing pinMode from the Xbee to Analog INPUT

Then a whole other set of pin manipulations must take place just to get the data back to me. More API Frame commands--
The data coming in must be captured in 8 bit packets 1 bit at a time, and stored discreetly, then added together.------

Comment
Seems like it would be much easier in more than one way, to just use 2 separate sensors per Remote Xbee-one for Temp, like the LM35, and another for humidity, like a nice Honeywell. The analog pieces at least work continuously without the need for this crazy manipulation, even though I have to use 1 extra pin per Xbee.
Any other comments or suggestions along these lines are welcome.
I definitely don't want to reinvent the wheel here folks. I just need to get the job done. Trying to use the DHT sensors with Remote xbees seems like too much code overhead.
Feel free to pitch in.

Thank you,
houdinihar

If you've got the DHT connected directly to the Xbee, and no MCU on that end then you'd likely need to literally write xbee code to read a DHT. If it were me I'd be going down the road you're now looking at and getting some analogue sensors that can be interpreted once they get back to the arduino.

Just remember the Xbee's are 3.3v so you'll have to factor that into any result that comes from them (and possibly lose resolution from the sensor because of that)

Hello WendoNZ.

Yes, I definitely wouldn't want to write new code for the Xbees and since I don't use any Arduinos on the Remote Xbees, they have to work pretty much out of the box.

Just remember the Xbee's are 3.3v so you'll have to factor that into any result that comes from them (and possibly lose resolution from the sensor because of that)

This is a good point WendoNZ. I have already been thinking of that so I use Regulated boards with each Xbee which can take 5V input without a problem and the Remote Xbees are powered by a transformer which can be preset to 5v DC. Both the Xbee and the sensors can live on the same mini-board I made with a 2.1 mm male barrel jack for the transformer wire in.

Another important point here is that the voltage output from the LM35 temperature sensor to the Xbee input pin varies from –550 mV at –55°C to 1 volt at 100°C--so I think I will be in good range here with my transformer voltage and milliamperage values.

On the other hand, using the HIH-4030 humidity sensor my max Vout at 100% humidity is around 4 volts with a 5 volt input to the sensor. This is a little high for the Xbee digital input pin since it maxes at around 3.4 volts dc. I may have to rethink some of this WendoNZ.

Thank you for the thoughts.
houdinihar

On the other hand, using the HIH-4030 humidity sensor my max Vout at 100% humidity is around 4 volts with a 5 volt input to the sensor. This is a little high for the Xbee digital input pin since it maxes at around 3.4 volts dc. I may have to rethink some of this WendoNZ.

Add a voltage divider?

Hi Rob.

Thank you for that thought point. I am not well-versed in electronics theory, but I have read a little on the use of the voltage divider circuit. If I miss something facile, please correct me.
Using the voltage divider circuit on the data pin of the sensor, I saw that Vout = Vin * (R2 / (R1 + R2)) and by using 5Vin and R1 = 270 ohms and R2 = 560 ohms, my Vout = 3.37. Pretty close to ideal max for the analog pin on the Xbee.

This is the page I used in the voltage divider circuit:
https://learn.sparkfun.com/tutorials/voltage-dividers

If that is the case, then possibly the correct humidity chart could be constructed based on a proportional analysis between the former values dependent on a Vout of 4V max at 100% RH and now a max Vout at 3.4 in the voltage divider circuit and use the data from the datasheet I list below as a start point.

Also, by using 2 separate HIH 4030's which I have, one connected in a non-modified version straight to my Arduino, and then another setup with the voltage divider circuit as noted above, or with similar output values, and make simultaneous recordings of each one in close proximity to each to establish my baseline and go off that. It would be a little extra work, but may be more accurate in the longrun than a purely mathematical attempt at the solution. What do you think Rob? Would that work maybe?

This is the data sheet from Sparkfun of the HIH 4030 sensor at:

This indicates :
Calculated values at 5 V
VOUT at 0% RH 0.958 V
VOUT at 75.3% RH 3.268 V

Linear output for 3.5% RH
accuracy at 25 °C
Zero offset 0.958 V
Slope 30.680 mV/%RH
Sensor RH (VOUT - zero offset)/slope
(VOUT - 0.958)/0.0307

Thank you for the feedback, Rob. I appreciate hearing from a seasoned person here.
houdinihar

you could make the resistors a little larger but keep their ratio. The larger the resistor the less current will flow.

270 + 560 = 830ohm at 5Volt => 5/830 = 6mA (ratio = 2.07)

2K2 + 4K7 => 6K9 @ 5V => 0.7mA enough for the ADC while keeping the ration almost equal 2.13

That is great Rob, Thank you. I will work on managing all that hopefully by this weekend and report back on the experimental data.
houdinihar

Hello friends,
Haven't done the actual vs mathematical comparison of humidity yet, but I whipped out the expected correlative real numbers based on the data available from the HIH 4030 datasheet as seen in my last post with the mathematical derivative only.

Provided data from datasheet
Initial output voltage at 0% Humidity is 0.958 volts with a max Vout of ~4 volts at 100%. The slope is derived to be 0.03068 volts/1% RH

Derived data
My max input to the Xbee pin is 3.4 volts, so I have to limit my max Vout to 3.4 as well by the voltage divider equation from my last post, as suggested by Rob. I do have to factor in the voltage at 0% RH and subtract from my max Vout in order to calculate slope.

Inferring from this example above, the calculated slope is: (3.4 - 0.958) / 100 = 0.02442 volt/1% RH
So based on the above data, if my HIH 4030 Humidity sensor is as close in accuracy as described by the datasheet, I should be able to easily calculate an ideal table of voltage and expected Humidity values and then run that against "real" experimental data.

The 4D systems uLCD-35DT that I am currently experimenting with has a great software driven Voltage meter program for the Arduino that should be perfect to allow me to do realtime voltage checks while generating humidity data simultaneously. I will intergrate the 2 and see how that turns out.
Here is the link for that complete zip file in case anyone else may wish to review it:
http://www.4dsystems.com.au/downloads/Application-Notes/4D-AN-00019_R_1_0.zip

take care all,
houdinihar