In my previous post, I created a chart without axis labels. Such an action is a breach of Intergalactic Science Law, and I’m going to have to solve the problem of converting these values into real sensor readings eventually. So for my next task in this home sensor project/obsession, I set about to do exactly that. It should have been a fairly simple task. It was not.
Let’s explore. The temperature sensor is a fairly simple device which outputs a voltage proportional to the ambient temperature. The analog voltage output is fed directly to a microcontroller on the sensor node. The microcontroller performs a process of analog-to-digital conversion (ADC) and translates the voltage to an 8-bit binary number. That byte is shoved into a packet of other bytes and beamed via radio to the receiver, which is attached to my trusty Arduino. So, we wind up with decimal values like these, taken during the shower (the values “peaked” at the 5 minute mark, probably when I shut the water off).
Time | ADC value |
0:00 | 96 |
2:00 | 107 |
3:00 | 120 |
4:00 | 153 |
5:00 | 161 |
So, the task of recovering the real sensor value involves translating those ADC output bytes into the original units of measurement being read; in this case, degrees Celsius.The math should just involve a couple of straightforward equations.
Vout = Vcc * (ADCout / ADCmax)
T = 100 * Vout – 50
The value Vcc is a constant, the source voltage for the microcontroller: 5 Volts. ADCmax is 255, which is the largest number 8 bits can represent. The temperature equation came from the part datasheet (actually from the SparkFun comments, but I tested it myself to verify). Just to make things easier for my silly American brain, I’ll also convert the temperature into degrees Fahrenheit. Man, one of these days I need to learn LaTeX.
Tf = (9/5) * Tc + 32
Okay, so what do we have here?
Time | Temperature (oF) |
0:00 | 280.8 |
2:00 | 319.6 |
3:00 | 365.5 |
4:00 | 482.0 |
5:00 | 510.2 |
Oh bother. I don’t carry the blood of the dragon, so those temperatures would have killed me almost instantly. No, I believe something might be wrong with my assumptions. I checked the transmitter, and it looks like the voltage regulator is working; I see 5V everywhere it needs to be. And remember when I said I tested the temperature equation? I double checked by reading the sensor directly: it read 0.7V, which is 20oC, or 68oF, exactly room temperature according to my thermostat. While checking this, the transmitter kept sending “92” to the Arduino.
During the soldering process, I kept having the nagging feeling that I put some parts in the wrong place. That mostly because the instructions at one point simply directly me to solder down the “blue” capacitors in a specific spot, when I had two different sizes of blue capacitors in the damn kit. So now, I have the sinking feeling that my coin flip came up tails. The good folks at the WickedDevice Q/A thought I also might have a low battery. That isn’t the case, but I appreciated a vendor giving my such a timely response.
Now I’m waiting for my order of three new nodes to arrive. If I don’t bungle the assembly, I can get some real readings, and put together a network with multiple transmitters. I was hoping to work on those two goals one at a time. Que sera sera.