Sunday, April 20, 2014

Arduino Weatherstation - RF Communication

I'm still waiting on my SparkFun Redboards. In the meantime, I received one 433 MHz transmitter and one 433 MHz receiver. Since I have a TI MSP430G2553 and a Duemilanove lying around, I thought I'd get them "talking" to each other.

Components

  1. 433 MHz receiver
  2. 433 MHz transmitter
  3. TI Launchpad w/MSP430G2553
  4. Arduino Duemilanove
  5. DHT22 temperature/humidity sensor
  6. Jumper cables, breadboard

Schematic

Note: For the MSP430G2, p9 is the same as P2_1 in receiver.pde.

What It Does

Every two seconds, the Duemilanove reads the temperature and relative humidity data from the DHT22 and also calculates the dewpoint. These three data points are concatenated into a string, with each value separated by a comma. Then, the string is transmitted to the MSP430, which dumps these raw data to the serial monitor.

Receiver Code

I used the VirtualWire library for both the Arduino and MSP430 boards. The MSP used a modified version of VirtualWire that can be found here (caution: French). I simply modified one line in the
receiver.pde example. I changed line 47 from this:

Serial.print(buf[i], HEX);

To this:

Serial.write(buf[i]);

This small change just outputs the the string that's transmitted, rather than its hexadecimal representation.

Transmitter Code

This part was more complicated. VirtualWire makes the communication part easy, but the problem lies in manipulating the sensor data to the appropriate format for transmission. I tried to limit the use of the String class to keep the code leaner, but I couldn't figure out a good way to concatenate all of the sensor values at the end.

I'm not super familiar with C strings and I've been spoiled by programming in more abstract languages.

Show Code

Results

It works! As you can see in the picture, the data are transmitted an astonishing 1/4'' wirelessly. Next up: Making quarter-wave whip antennae and range testing.