# ATMEGA328PU_lowPower_weather_station

## What is it ?

An ATMEGA328PU and NRF24L01+ based weather station operating on a single 18650 li-ion battery (or equivalent) and a solar panel.

**Check the LICENSE.md file at the root of this project for more information.**

![](http://82.64.196.164/images/git/weather_station_under.jpg)

## What are the functionalities ?
The station is equipped with the following sensors and has these functionalities :

* Temperature (BMP280 and HTU21)
* Humidity (HTU21)
* Compensated humidity (HTU21)
* Pressure (BMP280)
* Sunlight (LDR)
* Battery level indication (ATMEGA's 10 bit ADC)

## Power consumption :
* Around **60µA** during sleep
* Around a **13mA** spike during data transmission and **4mA** during sensor data collection.
* The solar panel is enough to even charge the battery it should thus never need to be replaced or recharged.

## Project folder architecture :
``` json
/
|_src                   This folder contains all the C/C++ file sources.
| \_app                 This folder contains the main app and it's dependencies.
| |_libs                This folder contains all the required 3rd party libraries that should be put in "Arduino\libraries" folder in order for the app to compile.
| |_test                This folder contains a test program which was used to test the dependencies.
|
|_schematic
| \_KiCad               This folder contains the KiCad files associated with the project.
| |_ATMEGA328PU_lowPower_weather_station.pdf    Which is the most recent schematic exported as a pdf for quick viewing.
|
|_documentation         This folder may one day contain the associated documentation if needed.
| 
|_.gitignore
|_LICENSE.md
|_README.md             The content of this page
```
## Getting started :
1. Clone this repository : git clone http://web-directories.cf/git/Th3maz1ng/ATMEGA328PU_lowPower_weather_station.git
2. Go to **"src\libs"** folder of this project and copy and paste its content in your "Arduino\libraries" folder.
3. Open the app.ino file with the Arduino IDE and select the "Arduino Pro or Pro Mini" board with processor : (Atmega 3.3V 8 Mhz).
4. Compile and Upload !
5. To receive the data sent by the station, you can check this other [project](http://www.web-directories.cf/git/Th3maz1ng/ESP8266_dual_NRF24l01_gateway) which is the receiver end.

## Configuration options :
You may change some settings present in the ***definition.h*** file.

Set **SLEEP_4_SEC_INTERVAL** which corresponds to the time interval between each data transmission in 4 seconds increments. 1 minute by default corresponds to a value of 15.

Set **SERIAL_DEBUG_ENABLED** to **1** to get debug output on the serial console.

Set **SERIAL_BAUD_RATE** to the desired baudrate for debugging.

Set **ADC_QUANTUM** to adjust the quantum if your VREF is not the same as mine.<br />
To do so, measure which voltage does the VCC pin of your Arduino board output and divide it by 1024 (10 bit ADC resolution).

Set **VOLTAGE_DIV_COEFF** to something different if you changed the voltage divider resistor values.

Set **RADIO_CHANNEL** to the NRF's RF channel (between 0 and 124). **Do not forget to set the receiver station up on the same channel**

Set **RADIO_NODE_ADDRESS** to change it's 5 byte address if you feel like it.

Set **RADIO_PA_LEVEL** to adjust the transmit power level if needed (higher power, higher current consumption)

## The hardware :
Here is a list of the parts used to build the station with a link to where you can buy it :
* [Solar panel : 72x72](https://fr.aliexpress.com/item/4001240640418.html?spm=a2g0s.9042311.0.0.27426c3741mIVH)
* [NRF24L01](https://fr.aliexpress.com/item/32976054389.html?spm=a2g0o.cart.0.0.657d3c00t37c7e&mp=1)
* [TC4056 (1 cell lipo charge/discharge protection)](https://fr.aliexpress.com/item/4000522397541.html?spm=a2g0o.productlist.0.0.175b30dfajsyO5&algo_pvid=203adaed-55ba-4678-a3e4-3aafcad89952&algo_exp_id=203adaed-55ba-4678-a3e4-3aafcad89952-1)
* [BMP280 pressure sensor](https://fr.aliexpress.com/item/32228095913.html?spm=a2g0s.9042311.0.0.27426c3741mIVH)
* [SHT/HTU 21 humidity sensor](https://fr.aliexpress.com/item/32787282185.html?spm=a2g0s.9042311.0.0.27426c3741mIVH)
* [ATMEGA328PU board](https://fr.aliexpress.com/item/4000190780977.html?spm=a2g0o.store_pc_allProduct.8148356.4.66547f0dNb2qkV)
* [3.3V LDO for the power rail : RT9013-33PB](https://fr.aliexpress.com/item/4001097171645.html?spm=a2g0o.productlist.0.0.48aa7800HoFD4h&algo_pvid=454c2fa4-a1a9-4ec2-9398-00d598a20b67&algo_exp_id=454c2fa4-a1a9-4ec2-9398-00d598a20b67-0)
* [LDR type : 5528](https://fr.aliexpress.com/item/32623615207.html?spm=a2g0o.productlist.0.0.41a66ceaAE4l8B&algo_pvid=b7699cb3-9564-4a0e-bfb2-cf66f2917b04&algo_exp_id=b7699cb3-9564-4a0e-bfb2-cf66f2917b04-0)

If you have any questions, do not hesitate to contact me at : bugreport[at]laposte[dot]net 

## Finally here are some pictures of the PCB and device :
PCB top view :
![](http://82.64.196.164/images/git/weather_station_pcb_top.jpg)

PCB back view :
![](http://82.64.196.164/images/git/weather_station_pcb_back.jpg)

Device's internals :
![](http://82.64.196.164/images/git/weather_station_open.jpg)

Device's internals with the PCB removed :
![](http://82.64.196.164/images/git/weather_station_box.jpg)

Device form factor :
![](http://82.64.196.164/images/git/weather_station_top.jpg)

Device's LDR and solar panel :
![](http://82.64.196.164/images/git/weather_station_back_solar_panel.jpg)

Device's antenna and SHT/HTU 21 cover :
![](http://82.64.196.164/images/git/weather_station_front.jpg)
