Sunday, June 1, 2014

Weatherstation - Internals

The weatherstation's internals are pretty much complete. I just have to solder the antennas onto the transmitter/receiver and the headers onto the barometric pressure sensor. I'll split this entry into three parts: first I'll go over how I made the antennas, second I'll go over the parts/operation of the transmitter, and third, I'll go over the operation of the receiver.

Antennas

I made quarter wavelength antennas out of wire. The antennas themselves are 1/4 the wavelength of the signal. In my case, the transmitter and receiver operate at a frequency of 433 MHz, so the quarter wavelength in centimeters is
λ = (c/f)*25

Where  c is the speed of light (m/s) and f is the frequency (1/s) of the wave. The quarter wavelength in centimeters is therefore:

λ = (3E8 /433E6)*25 = 17.3 cm

This length assumes the wave is traveling as if in a vacuum. I've seen other sources online that use 0.95c instead, therefore making the antenna a bit shorter.

So far, I've been able to get transmissions from about 12 ft away with a clear line of sight. More range tests are needed.

Transmitter

Parts

  1. Sparkfun Redboard
  2. 433 MHz transmitter
  3. DHT Sensor

Show Code

Refer to my previous post for details about how the code operates and a schematic to show how the components were hooked up to the Arduino.

Receiver

NOTE: You can't use the Sparkfun RedBoard for the transmitter out of the box because they don't come with the ISP headers populated. The Ethernet shield requires this, so you'll have to solder it on yourself or use an Arduino that already has the headers populated.

Parts

  1. Arduino Duemilanovae
  2. Arduino Ethernet shield w/Ethernet cable
  3. 433 MHz receiver

Show Code

How It Works

First, it is imperative that you call vw_setup() before calling server.begin(). There's possibly some sort of timer issue, and if you start the webserver before VirtualWire, nothing will work.

Receiving Weather Data


The receiver listens for transmissions from the transmitter and stores in it buf. The contents of buf are then copied into values, which will always contain the most recent weather data.

Manipulting C strings was definitely the most time consuming part of this project, but definitely the most educational. Arduino does have a String object, which simplifies string operations greatly. However, it will increase the size of your code.



The Webserver

Lines 14-17 set the server MAC address, IP address, and port. If your router requires a particular IP range, you'll want to change line 16. Once a client connects to the webserver, it will display the current data stored in the variable value. The webserver will also auto-refresh every 5 seconds.

The Arduino EthernetClient library is very straightforward. Think of the client.println() statement as the web browser version of Serial.println(). You're essentially printing a line-by-line webpage for your browser.

Future Additions

  1. Solder antennas to the transmitter and the  receiver
  2. Add my barometric pressure sensor once I solder its headers on
  3. Do more extensive range testing between the transmitter and the receiver
  4. Remove the use of the String library from line 55 of my transmitter code. Replace with C strings
  5. Start designing/constructing enclosures for the transmitter/receiver
  6. Solder components onto PCBs