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.

<p>ciao, your project is a real dream but I've some lack for coding on attiny.</p><p>have you made some test on a sketch for the arduino one's board?</p><p>it will help me a lot .</p><p>thank's a lot anyway .</p>
<p>you can build similar project on arduino, like thus one: https://www.hackster.io/sfrwmaker/make-your-own-remote-temperature-humidity-sensor-464f63</p>
<p>Hi again</p><p>I have a big favor to ask. Can you please add the libraries that you used to compile this sketch with. I have tried several different versions of the following:</p><p>#include &lt;TinyWireM.h&gt;</p><p>#include &lt;USI_TWI_Master.h&gt;</p><p>#include &lt;SI7021.h&gt;</p><p>All without success.</p><p>Thanks in advance.</p>
<p>Have you fixed the .cpp file of the SI7021 library? You had to commented out the include of &lt;Wire.h&gt; library like this:</p><p>/*<br>Copyright 2014 Marcus Sorensen &lt;marcus@electron14.com&gt;<br><br>This program is licensed, please check with the copyright holder for terms<br><br>Updated: Jul 16, 2015: TomWS1: <br> eliminated Byte constants, <br> fixed 'sizeof' error in _command(), <br> added getTempAndRH() function to simplify calls for C &amp; RH only<br>*/<br>#include &quot;Arduino.h&quot;<br>#include &quot;SI7021.h&quot;<br><strong>//#include &lt;Wire.h&gt;</strong></p><p>Anyway, you can download the libraries using this link:</p><p><a href="https://www.dropbox.com/sh/0z9mb5u1f72nt9d/AADr45o9LK6ICb-EtkXnS0E3a?dl=0">https://www.dropbox.com/sh/0z9mb5u1f72nt9d/AADr45o...</a></p><p>Adruino IDE version used - 1.6.12 for windows. Attiny support was recently added to my IDE.</p>
<p>Thanks for your help. But after building the circuit, my weather station did not pick up the new sensor.</p><p>I later found out that my wireless protocol uses Oregon V3. But it was worth the build, as I never used the ATTiny85 before. Still learned a lot building the project.</p>
<p>Sorry for that. Domique Piere have realized some functions for Oregon protocol v3. It is a little bit more complicated than v.2 protocol, but you could implement it, if you have a time. </p>
<p>Thank you. Yes, I did NOT comment out the Wire.h in the cpp file.</p><p>I was able to compile and upload the file afterwards.</p>
<p>Very interesting. I have built an attint85 weatherstation (and wrote an instructable on it) but that was just with a whip up 'protocol' with Manchestercode. Your Oregon protocol makes it a lot more interesting and more universal. I'll see if I can implement your code on my hardware.<br>Other than that, yours looks great as well</p>
<p>Excellent project. I will definitely build one to add to my weather station. </p>
Nice project. You could use the 1.1v internal voltage reference of the attiny for battery monitoring. That way you get 2 pins free and don't need the voltage reference of 1.24v.
Thank you very much. I will investigate this capability. This would make the sensor much simpler.

About This Instructable



More by sfrwmaker:attiny85 wireless weather sensor 5 minutes Christmas neopixel led strip Weather monitor 
Add instructable to: