Welcome everyone. The time from my last article I spent on upgrading Weather Station project. Generally it worked, but two things are not working perfectly and I was trying to fix it:
- power supply, my Weather Station devices needs to be supply by USB cable and charger, although they use not much power I know that they can use less then now
- more precisely measurement, because DTH modules are not quiet good
These two problems caused that I started to think how to change my project (without any revolution change) to make it more precisely and first of all less power consumption.
Precisely measurement was quiet easy to achieve. I changed module DHT11 to BME280 and all readings of temperature and humidity are better. Benefit of using BME280 is additional pressure reading. But there is other side of using BME280, it is more expensive than DHT11.
The second problem with less power consumption was bigger. I try to figure out what I can do to achieve it and finally found solution:
- change microcontroller to pure Atmega328
- change transmission from WiFi to radio transmission
Why such changes, please read below…
Atmega328
Using pure microcontroller cause that you don’t have unnecessary elements which use more power. Additionally using LowPower library we can use deep sleep for our microcontroller and reduce using power to minimal value. Unfortunately this library has only two sleep modes that I can use: 8 seconds sleep (longest interval sleep) or forever until external signal wake up microcontroller. The second solution sounds perfectly, because I would like to make reading data every 10 minutes. For waking up microcontroller I used Real Time Clock DS3231, which has built-in alarm clock.
I built such project and it worked as I assumed, but RTC despite of built-in own battery consume a lot of power. Truly said it was few milliampere but of course it was too much. So I decided to change approach and use alternative sleep mode. I used 8 seconds deep sleep. The hole process can be write in such loop: deep sleep (8 seconds), wake up, check if measurement is necessary (do it or not), go deep sleep. This solution is maybe not the best programming aporach, but from power consumption aspect it was huge improvement. In my home conditions I was able to measure that pure micrcontroller use almost whole time process only 4 microampere (during wake up and gong sleep it was quiet more, but only through few milliseconds). So this solution was the base of my proeject.
Temperature and humidity sensor
The next step was to use proper sensor. As I mentioned previously I decided to change DHT11 to BME280 (but not all, and I have still outside DHT22). Those conditions change my point of view and I realized that I have create something flexible. So I wrote and class which can be easily modified by anyone. This class has unified interface to get temeprature, humidity and pressure (for DHT modules return null) and is able to use DHT11, DHT22 and BME280 of course. If someone needs to use another module he is more than welcome to change it and make some pull request in the future.
I have to add that my project is ready to read data from one or two sensors, but there is no problem to extend it to read data from more sensors.
Radio transmission
The next step of that project is radio transmission. Here I was a problem what kind of module I have to use. Finally I decided to CC1101. This module is not chip but also not so expensive. Its main advantage is power consumption. It use very low power during sending or receiving transmission also sleep mode use minimal power.
I think everyone knows that radio transmission is very easy to be listen by other receivers, so I decided to make mechanism which allows you to create encryption and decryption method to change you message and make it less susceptible for read. This is only you imagination what kind of encryption you will use.
Weather station – Client
This project I wrote above I called – Client. Why? I think that most of you who read some my previous posts knows that I store all reading sensor data in database, so I need something to translate radio message to some WiFi transmission. You know that this data needs to be transferred through MQTT to Home Assistant. So all that things need to create something what I called Bridge.
Before we go to describing Bride I would like to add that each Weather Station (Client) has its own unique ID and information from which sensor retrieve data (0 – first, 1 – second sensor). The proof of concept how can look like client you can find on below image.
Bridge
What is Bridge? Hmm… Generally it is Nodemcu v3 with CC1101 module setting as receiver, supplied by USB (one for multiple clients). Its main task is to get and decode data sent via radio transmission and send it on to MQTT broker in known format. All additional thinks will perform automatically.
Of course currently communication Client <-> Bridge is very simple solution. Client encrypt message, sends to Bridge and forget about it, the same is with Bridge he sends message via MQTT and also forget about it.
I think about upgrading this communication. Add some confirmations, but all such ideas makes this project more complex and consuming more energy. So I decided to do nothing with that. Probaility of losing data is quiet less, but even such things happen this is not critical situation especially that on server side there is mechanism which check if some sensor does not send data for more than one hour. If such situation happens it sends an email with notification.
Summary
Every Client is supplied by one battery 18650 with capacity 8800 mAh (voltage 4.2 or 3.7). From my calculations it should works on battery for few years making measurement every 5 minutes. How it will be in real – we see. But even if my calculation are not good and battery will empty after one year it will also be success.
Currently I worked on the code. I try to clean it and describe it, make some instruction. Everything for making my code public to share with you. All of the programming details I will write in my next post.