In this article is shown how to build your own wireless weather sensor compatible with Oregon weather station using compact attiny85 micro controller. You can buy spare Oregon sensor THGN123N for about $20 or you can build your own wireless sensor that implements Oregon protocol V2.1 for about $9 and have fun!
The main component of the sensor is an accurate temperature/humidity sensor that can report the weather condition with high precision (about 0.5 degree of centegrees). The si7021 sensor has shown perfect results, so I recommend this sensor one more time: it has great accuracy, small form-factor and low power consumption.
Also, we need mobile platform with low power requirements that can run on the batteries for a long time. The sensor firmware is small and can easily fit into attiny85 micro controller memory. The power consumption of the attiny85 running at 1MHz in sleep mode is about 4 micro Amps!
And the last, we need the software library for sending the signals using appropriate protocol. Happily, there is the software created by Domonique Pierre, emulated Oregon V2.1 protocol, that we can reuse.
Step 1: Component List
To build own weather sensor you need the following components:
- attiny85 micro controller - $1.2 (in bundle of 10)
- temperature/humidity sensor si7021 - $2.6
- wireless transmitter 433 MHz - $0.6 (in bundle of 5 pairs transmitter/receiver)
- two AA battery case pack - $1
- small components - about $0.5
- resister 10k
- resister 3.3k - 2 pcs
Step 2: Hardware
First, we need to build the hardware platform for our sensor. Here you can see the simple schematics, that can be easily implemented on general PCB or you can use custom PCB using my design. Two AA battery pack provides sufficient power for the sensor during six month or so. To evaluate the remaining battery capacity, internal reference voltage is used, which supplies stabilized 1.1 volt. The readings from this reference voltage source depends on battery voltage, so we can estimate the battery capacity. Here you can find detailed description of how to use this reference source.
Step 3: Attiny85 Challenges
attyny85 is small micro controller and has limited capabilities. It does not have hardware UART port helping debug the firmware nor hardware i2c bus. Hopefully, the sketch developed for the Arduino micro controller, required a cosmetic changes and there is good TinyWireM library that simulated i2c bus on the attiny85. pins 5 and 7 of the attiny85 used for i2c communication. The standard library for si7021 sensor should be modified slightly: you must remove #include line from the .cpp library file. The library header file has correct include statement in case of attiny85 controller.
To reduce the power requirements of our sensor, Attiny85 controller configured to use internal 1MHz clock. Also the sketch implementing watchdog timer that wakes-up the controller every 8 seconds. This aproach allows significantly reduce the power consumption of our sensor from 1mA to about 5 uA (micro Amps, at 3.3 volts).
At the beginning, I tried to use pure Oregon protocol library written by Domonique Pierre. Unfortunately, the controller speed was not sufficient to send the data in the time limits required by the protocol using digitalWrite() system call. To make the library faster, direct port manipulation was implemented in the sketch. In the attiny85 controller there is one output port only, D. So the direct port manipulation class is very simple. The constructor for OregonSensor class automatically selects appropriate port based on the transmission pin number. There are direct port manipulation functions in the class to send "one" and "zero" signal according by the Oregon protocol that allows to speed-up the signal transmission.
Step 4: How It Works?
The sketch code for the sensor is very simple. The main time the controller is in sleep mode. Every 8 seconds the controller is waked up by the watchdog timer. The internal counter skips 4 times ans activates the sensor every 40 seconds: the controller sends the readings from the temperature and humidity sensor si7021 to the weather station using Oregon 2.1 protocol.
The battery capacity evaluated every 100-th time by reading the voltage of internal reference source. As i mentioned before, the reference voltage is stabilized at 1.1 v and the reading of reference source depends on voltage on the vcc pin of the attiny85 micro controller.
Step 5: Conclusion
There are three interesting features in this project:
- non-expensive, compact, simple-to-implement attiny85 based hardware platform.
- power-efficient wireless sensor that can run over a half-year on two AA batteries.
- the software that supports Oregon V2.1 protocol with advanced direct port manipulation functions.
I hope, you enjoy investigating all of the components or you can build your own sensor using this technology.