I’ve just got around to fine tuning the WiFly sensor prototype. I’ve made another perfboard prototype, this time with my own 3.3V voltage regulator and a mini USB connector to provide power. It’s taken me a while, but I keep getting distracted by everything else I’m tryinig to do!
The main issue was working out what the hell the sensor pins on the RN-XV were doing. I managed to get a reasonably accurate set-up with some suck-it-and-see numbers. But they only worked accurately for a very very narrow range of temperatures.
I finally made some headway when I stumbled across this forum thread: WiFly sensor pin readings on the Sparkfun site. The crux of the issue is that the sensor pins already have a voltage divider across them. The excellent work the guys have done on the forum meant I could start getting some sensible readings from the WiFly.
Essentially, the RN-XV manual is very misleading. It makes reference to the max Voltage for the analogue pins, but fails to mention anywhere the voltage divider built into the RN-XV itself. It is possible to remove the resistors from the board yourself, as Bjorn has done here. But for my purposes this is unnecessary, and having them in place means that the pins remain 3.3V tolerant.
You also have to shift the HEX value reported for each sensor to the right before converting it to decimal.
This is a little section of my PHP script that processes the GET requests from the RN-XV
//pin19 = TMP36
// Grab the GET data. $wiflyData = stripslashes($_GET['data']);
// Split the data stream into each sensor value, every 4 digits. $myArray = str_split($wiflyData, 4);
// Add an extra byte to the HEX values $pin19HEX = str_pad($myArray, 5, "0", STR_PAD_RIGHT);
// Convert the padded HEX value to Decimal. $pin19Dec = base_convert($pin19HEX,16,10);
// Perform the weird RN-XV multiplier $microV = ($pin19Dec*5.064);
// Convert microVolts to milliVolts $milliV = ($microV/1000);
//Convert millivolts into temperature for the TMP36 $degC = (($milliV - 500) / 10);
Then it gets inserted into a mySQL database for graphing etc
It took a while to get this all sorted, but now I can leave the two prototypes running 24/7 for a few days and see how they hold up.