Then, both the serial and SoftwareSerial ports must be
initialized in the setup() function. The serial port is set to
9600 bps and the SoftwareSerial port to 2400 bps. The
main program loop (Figure 4) consists of reading the data,
verifying it, converting it to temperature, and displaying
the data. First, wait until at least four bytes of data are
available in the SoftwareSerial port RX buffer. Once it is,
read four bytes in the expected order: transmitter address,
high data byte, low data byte, and checksum.
■ FIGURE 4.
To verify the checksum, we simply sum all four bytes
as an unsigned byte (discarding overflow) — the total of
which should be zero. Next, check the transmitter
address; if it's the one we are looking for, then convert
the raw data to temperature and send it to the computer.
To do so, first combine the high and low byte into one
16-bit word and convert it to a voltage:
unsigned short data = (high_byte << 8) |
float voltage = (data / 1024.0) 2.048;
Next, convert the voltage to a temperature.
Remember, the TMP36 will output 750 mV at 25°C and
has a 10 mV/°C gradient:
float temperature_c = ((voltage - 0.750) 100)
float temperature_f = (1.8 temperature_c)
■ FIGURE 5.
Pretty easy. Finally, send it to the computer with
some Serial.print() function calls and watch the data
populate on the serial monitor.
Let’s Go for a Test Ride!
sleep and we're done. Wash, rinse, and repeat.
With the transmitter in one room and the receiver in
another, I had little issue receiving steady data. At times,
the receiver would miss a transmission but that's not
entirely surprising considering the specifications of the
receiver link and the fact that the ISM band this operates
on is very busy.
Anyone Out There?
For the base station, using the Holy Stone MO-RXLC-A (WRL-08949, replaced by WRL-10532), I decided to go
with an Arduino Uno with the RF receiver link wired per
the datasheet. I used the included SoftwareSerial library
to receive the data from the receiver link at 2400 bps,
process it in the Arduino, and then send the data to a
computer over the built-in serial/USB interface to
ultimately be displayed on the serial monitor included in
the Arduino IDE (Integrated Development Environment).
To verify the temperature sensor is indeed working, I
put my finger on the TMP36 and watched the
temperature increase and then decrease when I removed
my finger (Figure 5). The current draw when the PIC is
asleep and the devices are off is between 22. 2-25. 4 µA.
When transmitting, it increases to 4. 80-8. 56 mA. Even
with the small AAA batteries, you should be able to get
about 39,000 hours out of them. Not bad!
There is Room
Looking at temperature_receiver.ino, we first must
create a SoftwareSerial object using pin 10 for RX and pin
11 for TX (we will not actually be using the TX portion).
There are a few other ways to skin this cat which
could improve the design. First, we could use a digital
temperature sensor in the transmitter. This would cut
down on the number of parts required, but could
32 January 2014