Merge branch 'master' of http://web-directories.cf/git/Th3maz1ng/ATMEGA328PU_lowPower_weather_station
This commit is contained in:
commit
61c6383f0c
4
.gitignore
vendored
4
.gitignore
vendored
@ -36,5 +36,5 @@
|
|||||||
*.bin
|
*.bin
|
||||||
credentials.h
|
credentials.h
|
||||||
!schematic/KiCad/ATMEGA328PU_lowPower_weather_station/*
|
!schematic/KiCad/ATMEGA328PU_lowPower_weather_station/*
|
||||||
src/app/*
|
src/tests/*
|
||||||
!src/app/*.ino
|
!src/tests/*.ino
|
||||||
|
112
README.md
112
README.md
@ -1,8 +1,108 @@
|
|||||||
# ATMEGA328PU_lowPower_weather_station
|
# ATMEGA328PU_lowPower_weather_station
|
||||||
|
|
||||||
An ATMEGA328PU and NRF24L01+ based weather station operating on a single 18650 li-ion cell and a solar panel.
|
## What is it ?
|
||||||
Sensors :
|
|
||||||
* Temperature
|
An ATMEGA328PU and NRF24L01+ based weather station operating on a single 18650 li-ion battery (or equivalent) and a solar panel.<br />
|
||||||
* Humidity
|
On [this page](/Pages/station.html) is displayed the data collected by this very unit !
|
||||||
* Pressure
|
|
||||||
* Sunlight
|
**Check the LICENSE.md file at the root of this project for more information.**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## What are the functionalities ?
|
||||||
|
The station is equipped with the following sensors and 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 externally.
|
||||||
|
|
||||||
|
## 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 This folder contains all the files associated with the 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.tk/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](/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. **Do not forget to set the receiver station up on the same address**
|
||||||
|
|
||||||
|
Set **RADIO_PA_LEVEL** to adjust the transmit power level if needed (higher the power, higher the current consumption)
|
||||||
|
|
||||||
|
Set **ENABLE_LNA** to true or false to enable or disable the Low Noise Amplifier on the NRF modules if it has one.
|
||||||
|
|
||||||
|
## The hardware :
|
||||||
|
Here is a list of the parts used to build the station with a link to where you can buy them :
|
||||||
|
* [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)
|
||||||
|
* [Small junction box](https://www.amazon.com/LeMotech-Dustproof-Waterproof-Electrical-85mmx85mmx50mm/dp/B075X14RVH/ref=sr_1_2?dchild=1&keywords=junction+box+3.4+3.4+2&qid=1626903891&sr=8-2)
|
||||||
|
|
||||||
|
***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 :
|
||||||
|

|
||||||
|
|
||||||
|
PCB back view :
|
||||||
|

|
||||||
|
|
||||||
|
Device's internals :
|
||||||
|

|
||||||
|
|
||||||
|
Device's internals with the PCB removed :
|
||||||
|

|
||||||
|
|
||||||
|
Device form factor :
|
||||||
|

|
||||||
|
|
||||||
|
Device's LDR and solar panel :
|
||||||
|

|
||||||
|
|
||||||
|
Device's antenna and SHT/HTU 21 cover :
|
||||||
|

|
||||||
|
BIN
schematic/ATMEGA328PU_lowPower_weather_station.pdf
Normal file
BIN
schematic/ATMEGA328PU_lowPower_weather_station.pdf
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
update=22/05/2015 07:44:53
|
update=13/06/2021 10:07:06
|
||||||
version=1
|
version=1
|
||||||
last_client=kicad
|
last_client=eeschema
|
||||||
[general]
|
[general]
|
||||||
version=1
|
version=1
|
||||||
RootSch=
|
RootSch=
|
||||||
@ -31,3 +31,13 @@ NetIExt=net
|
|||||||
version=1
|
version=1
|
||||||
LibDir=
|
LibDir=
|
||||||
[eeschema/libraries]
|
[eeschema/libraries]
|
||||||
|
[schematic_editor]
|
||||||
|
version=1
|
||||||
|
PageLayoutDescrFile=
|
||||||
|
PlotDirectoryName=
|
||||||
|
SubpartIdSeparator=0
|
||||||
|
SubpartFirstId=65
|
||||||
|
NetFmtName=
|
||||||
|
SpiceAjustPassiveValues=0
|
||||||
|
LabSize=50
|
||||||
|
ERC_TestSimilarLabels=1
|
||||||
|
@ -5,10 +5,10 @@ EELAYER END
|
|||||||
$Descr A4 11693 8268
|
$Descr A4 11693 8268
|
||||||
encoding utf-8
|
encoding utf-8
|
||||||
Sheet 1 1
|
Sheet 1 1
|
||||||
Title ""
|
Title "ATMEGA328PU Low Power Weather Station"
|
||||||
Date ""
|
Date "2021-06-13"
|
||||||
Rev ""
|
Rev "1.0"
|
||||||
Comp ""
|
Comp "www.web-directories.tk"
|
||||||
Comment1 ""
|
Comment1 ""
|
||||||
Comment2 ""
|
Comment2 ""
|
||||||
Comment3 ""
|
Comment3 ""
|
||||||
|
@ -4,9 +4,9 @@ EELAYER END
|
|||||||
$Descr A4 11693 8268
|
$Descr A4 11693 8268
|
||||||
encoding utf-8
|
encoding utf-8
|
||||||
Sheet 1 1
|
Sheet 1 1
|
||||||
Title ""
|
Title "ATMEGA328PU Low Power Weather Station"
|
||||||
Date ""
|
Date "2021-06-13"
|
||||||
Rev ""
|
Rev "1.0"
|
||||||
Comp ""
|
Comp ""
|
||||||
Comment1 ""
|
Comment1 ""
|
||||||
Comment2 ""
|
Comment2 ""
|
||||||
@ -501,7 +501,7 @@ $EndComp
|
|||||||
Text GLabel 2150 4800 0 50 Input ~ 0
|
Text GLabel 2150 4800 0 50 Input ~ 0
|
||||||
~LDR_V_SENS_EN
|
~LDR_V_SENS_EN
|
||||||
Text GLabel 2150 4950 0 50 Input ~ 0
|
Text GLabel 2150 4950 0 50 Input ~ 0
|
||||||
~BAT_V_SENS_EN
|
BAT_V_SENS_EN
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2150 4800 2600 4800
|
2150 4800 2600 4800
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -601,7 +601,7 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
7900 4850 8100 4850
|
7900 4850 8100 4850
|
||||||
Text GLabel 7700 4850 0 50 Input ~ 0
|
Text GLabel 7700 4850 0 50 Input ~ 0
|
||||||
~BAT_V_SENS_EN
|
BAT_V_SENS_EN
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6900 5950 6900 6050
|
6900 5950 6900 6050
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
|
@ -14,7 +14,7 @@ uint8_t WSPeripherals::init()
|
|||||||
pinMode(_boardConfig.BATVSensEnable, OUTPUT);
|
pinMode(_boardConfig.BATVSensEnable, OUTPUT);
|
||||||
digitalWrite(_boardConfig.BATVSensEnable, LOW);
|
digitalWrite(_boardConfig.BATVSensEnable, LOW);
|
||||||
|
|
||||||
//Unused pins are set as inputs with internal pullup inable to reduce power consumption during sleep
|
//Unused pins are set as inputs with internal pullup enabled to reduce power consumption during sleep
|
||||||
pinMode(0,INPUT_PULLUP);
|
pinMode(0,INPUT_PULLUP);
|
||||||
//pinMode(1,INPUT_PULLUP); TX pin for serial
|
//pinMode(1,INPUT_PULLUP); TX pin for serial
|
||||||
pinMode(6,INPUT_PULLUP);
|
pinMode(6,INPUT_PULLUP);
|
||||||
@ -113,9 +113,9 @@ void WSPeripherals::_3V3PowerRail(State state)
|
|||||||
|
|
||||||
const RF24 &WSPeripherals::getRadio(){return _NRF;}
|
const RF24 &WSPeripherals::getRadio(){return _NRF;}
|
||||||
|
|
||||||
void WSPeripherals::applyRadioConfig(uint8_t channel, uint8_t paLevel, rf24_datarate_e datarate)
|
void WSPeripherals::applyRadioConfig(uint8_t channel, uint8_t paLevel, bool enableLNA, rf24_datarate_e datarate)
|
||||||
{
|
{
|
||||||
_NRF.setChannel(channel);
|
_NRF.setChannel(channel);
|
||||||
_NRF.setPALevel(paLevel);
|
_NRF.setPALevel(paLevel, enableLNA);
|
||||||
_NRF.setDataRate(datarate);
|
_NRF.setDataRate(datarate);
|
||||||
}
|
}
|
@ -44,7 +44,7 @@ class WSPeripherals
|
|||||||
/*
|
/*
|
||||||
* Before calling this method, externalPeripherals(ON) and initExternalPeripherals() must be called respectively
|
* Before calling this method, externalPeripherals(ON) and initExternalPeripherals() must be called respectively
|
||||||
*/
|
*/
|
||||||
void applyRadioConfig(uint8_t channel = RADIO_CHANNEL, uint8_t paLevel = RADIO_PA_LEVEL, rf24_datarate_e datarate = RADIO_DATARATE);
|
void applyRadioConfig(uint8_t channel = RADIO_CHANNEL, uint8_t paLevel = RADIO_PA_LEVEL, bool enableLNA = ENABLE_LNA, rf24_datarate_e datarate = RADIO_DATARATE);
|
||||||
const RF24 &getRadio();
|
const RF24 &getRadio();
|
||||||
|
|
||||||
protected:
|
protected:
|
@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Author : Anatole SCHRAMM-HENRY
|
||||||
|
* Created the : 30/05/2021
|
||||||
|
* This is the source file containing the main app.
|
||||||
|
* It defines all the logic which make the weather station work.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "definition.h"
|
#include "definition.h"
|
||||||
#include "BoardConfig.h"
|
#include "BoardConfig.h"
|
||||||
#include "WSPeripherals.h"
|
#include "WSPeripherals.h"
|
||||||
@ -7,7 +14,7 @@ BoardConfig defaultBC;
|
|||||||
WSPeripherals WSP(defaultBC);
|
WSPeripherals WSP(defaultBC);
|
||||||
|
|
||||||
uint8_t sleepSlots(0), rCode(0);
|
uint8_t sleepSlots(0), rCode(0);
|
||||||
DataPacket payload;
|
WeatherStationDataPacket payload;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -17,7 +24,7 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
rCode = WSP.init();
|
rCode = WSP.init();
|
||||||
memset(&payload, 0, sizeof(payload));
|
memset(&payload, 0, sizeof payload);
|
||||||
#if SERIAL_DEBUG_ENABLED == 1
|
#if SERIAL_DEBUG_ENABLED == 1
|
||||||
Serial.print("Payload size : ");Serial.println(sizeof payload);
|
Serial.print("Payload size : ");Serial.println(sizeof payload);
|
||||||
debugStruct(&payload);
|
debugStruct(&payload);
|
||||||
@ -57,10 +64,10 @@ void loop()
|
|||||||
if(WSP.getRadio().isChipConnected())
|
if(WSP.getRadio().isChipConnected())
|
||||||
{
|
{
|
||||||
WSP.applyRadioConfig();
|
WSP.applyRadioConfig();
|
||||||
|
//WSP.getRadio().setPayloadSize(sizeof payload); //Does not work
|
||||||
WSP.getRadio().setRetries(10,20);
|
WSP.getRadio().setRetries(10,20);
|
||||||
WSP.getRadio().openWritingPipe((const uint8_t *)RADIO_NODE_ADDRESS);
|
WSP.getRadio().openWritingPipe((const uint8_t *)RADIO_NODE_ADDRESS);
|
||||||
//WSP.getRadio().setPayloadSize(sizeof payload);
|
bool result = WSP.getRadio().write(&payload, sizeof payload);
|
||||||
bool result = WSP.getRadio().write(&payload, sizeof(payload));
|
|
||||||
#if SERIAL_DEBUG_ENABLED == 1
|
#if SERIAL_DEBUG_ENABLED == 1
|
||||||
if(result)
|
if(result)
|
||||||
Serial.println("Payload sent !");
|
Serial.println("Payload sent !");
|
||||||
@ -87,7 +94,7 @@ void loop()
|
|||||||
sleepSlots++;
|
sleepSlots++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugStruct(DataPacket *p)
|
void debugStruct(WeatherStationDataPacket *p)
|
||||||
{
|
{
|
||||||
Serial.println("##############DATA##############");
|
Serial.println("##############DATA##############");
|
||||||
Serial.print("ID : ");
|
Serial.print("ID : ");
|
||||||
|
@ -19,12 +19,14 @@
|
|||||||
#define VOLTAGE_DIV_COEFF 1.3125 //(R1 + R2)/R2
|
#define VOLTAGE_DIV_COEFF 1.3125 //(R1 + R2)/R2
|
||||||
|
|
||||||
//NRF Radio config part
|
//NRF Radio config part
|
||||||
#define RADIO_CHANNEL 108
|
#define RADIO_CHANNEL 108 //0-125
|
||||||
#define RADIO_NODE_ADDRESS "WEST1" //Weather Station 1
|
#define RADIO_NODE_ADDRESS "WEST1" //Weather Station 1
|
||||||
#define RADIO_PA_LEVEL RF24_PA_LOW
|
#define RADIO_PA_LEVEL RF24_PA_HIGH //RF24_PA_MIN,RF24_PA_LOW,RF24_PA_HIGH,RF24_PA_MAX
|
||||||
|
#define ENABLE_LNA false //true or false
|
||||||
#define RADIO_DATARATE RF24_250KBPS
|
#define RADIO_DATARATE RF24_250KBPS
|
||||||
|
|
||||||
//Sleep config part : in 4 second increments ie : 1 corresponds to 4s of sleep, and 15 correponds to 60 seconds of sleep.
|
//Sleep config part : in 4 second increments ie : 1 corresponds to 4s of sleep, and 15 correponds to 60 seconds of sleep.
|
||||||
|
//Max is 255 * 4s.
|
||||||
#define SLEEP_4_SEC_INTERVAL 15
|
#define SLEEP_4_SEC_INTERVAL 15
|
||||||
|
|
||||||
//Pin config part
|
//Pin config part
|
||||||
@ -56,6 +58,6 @@ typedef struct
|
|||||||
float humidity;
|
float humidity;
|
||||||
float compensatedHumidity;
|
float compensatedHumidity;
|
||||||
float htuTemp;
|
float htuTemp;
|
||||||
} DataPacket __attribute__((__packed__));
|
} __attribute__((__packed__)) WeatherStationDataPacket;
|
||||||
|
|
||||||
#endif //DEFINITION_H
|
#endif //DEFINITION_H
|
@ -1,10 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* Author : Anatole SCHRAMM-HENRY
|
* Author : Anatole SCHRAMM-HENRY
|
||||||
* Created the : 29/05/2021
|
* Created the : 29/05/2021
|
||||||
* This TEST program aims to verify all basic functions of the station like by displaying some values to a serial console :
|
* This TEST program aims to verify all the basic functions of the weather station by displaying all the sensors values to a serial console :
|
||||||
* - The battery level sensing
|
* - The battery level sensing
|
||||||
* - The light level with the LDR
|
* - The light level with the LDR
|
||||||
* - The Temperature
|
* - The temperature of the BMP280
|
||||||
|
* - The temperature of the HTU21
|
||||||
* - The pressure
|
* - The pressure
|
||||||
* - The humidity
|
* - The humidity
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user