Removed the dependency files from the test folder

This commit is contained in:
Th3maz1ng 2021-07-17 23:02:13 +02:00
parent ba457838c3
commit d2d1e6b4a4
6 changed files with 0 additions and 312 deletions

View File

@ -1,18 +0,0 @@
#include "BoardConfig.h"
BoardConfig::BoardConfig( const Pin LDOEnable,
const Pin NRFCe,
const Pin NRFCs,
const Pin I2CSDA,
const Pin I2CSCL,
const Pin LDRVSensEnable,
const Pin BATVSensEnable,
const Pin MOSI,
const Pin MISO,
const Pin SCK,
const Pin BATAnalogVSens,
const Pin LDRAnalogVSens
):LDOEnable(LDOEnable), NRFCe(NRFCe), NRFCs(NRFCs), I2CSDA(I2CSDA), I2CSCL(I2CSCL), LDRVSensEnable(LDRVSensEnable), BATVSensEnable(BATVSensEnable), MOSI(MOSI), MISO(MISO), SCK(SCK), BATAnalogVSens(BATAnalogVSens), LDRAnalogVSens(LDRAnalogVSens)
{
}

View File

@ -1,46 +0,0 @@
/**
* Author : Anatole SCHRAMM-HENRY
* Created the : 30/05/2021
* This class encapsulates the various configuration values for the board like the Pin Mapping for instance.
*/
#ifndef BOARDCONFIG_H
#define BOARDCONFIG_H
#include "definition.h"
class BoardConfig
{
public:
BoardConfig(
const Pin LDOEnable = D2_LDO_EN,
const Pin NRFCe = D3_NRF_CE,
const Pin NRFCs = D10_NRF_CS,
const Pin I2CSDA = A4_SDA,
const Pin I2CSCL = A5_SCL,
const Pin LDRVSensEnable = D4_LDR_V_SENS_EN,
const Pin BATVSensEnable = D5_BAT_V_SENS_EN,
const Pin MOSI = D11_MOSI,
const Pin MISO = D12_MISO,
const Pin SCK = D13_SCK,
const Pin BATAnalogVSens = A0_BAT_V_SENS,
const Pin LDRAnalogVSens = A1_LDR_V_SENS
);
const Pin LDOEnable;
const Pin NRFCe;
const Pin NRFCs;
const Pin I2CSDA;
const Pin I2CSCL;
const Pin LDRVSensEnable;
const Pin BATVSensEnable;
const Pin MOSI;
const Pin MISO;
const Pin SCK;
const Pin BATAnalogVSens;
const Pin LDRAnalogVSens;
protected:
private:
};
#endif //BOARDCONFIG_H

View File

@ -1,121 +0,0 @@
#include "WSPeripherals.h"
WSPeripherals::WSPeripherals(const BoardConfig &boardConfig): _boardConfig(boardConfig), _HTU21(HTU21D_RES_RH12_TEMP14), _NRF(boardConfig.NRFCe, boardConfig.NRFCs)
{}
uint8_t WSPeripherals::init()
{
uint8_t toReturn(0);
//We initialize used pins :
pinMode(_boardConfig.LDOEnable, OUTPUT);
_3V3PowerRail(OFF);
pinMode(_boardConfig.LDRVSensEnable, OUTPUT);
digitalWrite(_boardConfig.LDRVSensEnable, HIGH); //High means that it is disabled and low is active /!\/
pinMode(_boardConfig.BATVSensEnable, OUTPUT);
digitalWrite(_boardConfig.BATVSensEnable, LOW);
//Unused pins are set as inputs with internal pullup inable to reduce power consumption during sleep
pinMode(0,INPUT_PULLUP);
//pinMode(1,INPUT_PULLUP); TX pin for serial
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(8,INPUT_PULLUP);
pinMode(9,INPUT_PULLUP);
pinMode(10,INPUT_PULLUP);
pinMode(11,INPUT_PULLUP);
pinMode(12,INPUT_PULLUP);
pinMode(A2,INPUT_PULLUP);
pinMode(A3,INPUT_PULLUP);
pinMode(A6,INPUT_PULLUP);
pinMode(A7,INPUT_PULLUP);
//We check that every external devices are responding
_3V3PowerRail(ON);
toReturn |= _BMP280.begin(0x76);
toReturn |= _HTU21.begin() << 1;
toReturn |= _NRF.begin() << 2;
_3V3PowerRail(OFF);
return toReturn;
}
uint8_t WSPeripherals::initExternalPeripherals()
{
uint8_t toReturn(0);
toReturn |= _BMP280.begin(0x76);
toReturn |= _HTU21.begin() << 1;
toReturn |= _NRF.begin() << 2;
//We disable the I2C internal pullups :
digitalWrite(SDA, LOW);
digitalWrite(SCL, LOW);
return toReturn;
}
float WSPeripherals::batteryVoltage()
{
//We close the voltage divider bridge and we do the measurement
digitalWrite(_boardConfig.BATVSensEnable, HIGH);
int rawBatteryValue = analogRead(_boardConfig.BATAnalogVSens);
digitalWrite(_boardConfig.BATVSensEnable, LOW);
return float(rawBatteryValue) * ADC_QUANTUM * VOLTAGE_DIV_COEFF;
}
int WSPeripherals::sunlightMeasurement()
{
//We enable the voltage divider bridge and we do the measurement
digitalWrite(_boardConfig.LDRVSensEnable, LOW);
int rawSunlightMeasurement = analogRead(_boardConfig.LDRAnalogVSens);
digitalWrite(_boardConfig.LDRVSensEnable, HIGH);
return rawSunlightMeasurement;
}
void WSPeripherals::temperatureAndATMPressureFromBMP280(float *temperature, float *ATMPressure)
{
if(!temperature && !ATMPressure)return;
_BMP280.setSampling( Adafruit_BMP280::MODE_FORCED,
Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::SAMPLING_X16,
Adafruit_BMP280::FILTER_X16,
Adafruit_BMP280::STANDBY_MS_4000);
if(temperature)
*temperature = _BMP280.readTemperature();
if(ATMPressure)
*ATMPressure = _BMP280.readPressure();
}
float WSPeripherals::temperatureFromHTU21()
{
return _HTU21.readTemperature();
}
float WSPeripherals::humidity()
{
return _HTU21.readHumidity();
}
float WSPeripherals::compensatedHumidity()
{
return _HTU21.readCompensatedHumidity();
}
void WSPeripherals::_3V3PowerRail(State state)
{
digitalWrite(_boardConfig.LDOEnable, state);
if(state) //We let some time for the voltage to stabilize on the rail.
delay(10);
}
const RF24 &WSPeripherals::getRadio(){return _NRF;}
void WSPeripherals::applyRadioConfig(uint8_t channel, uint8_t paLevel, rf24_datarate_e datarate)
{
_NRF.setChannel(channel);
_NRF.setPALevel(paLevel);
_NRF.setDataRate(datarate);
}

View File

@ -1,60 +0,0 @@
/**
* Author : Anatole SCHRAMM-HENRY
* Created the : 30/05/2021
* This classe exposes all the methods necessary to init the WSPeripherals (Weather Station Peripherals) and
* to retrieve various data and measurements like battery voltage, Temperatures etc...
*/
#ifndef WSPERIPHERALS_H
#define WSPERIPHERALS_H
#include <RF24.h>
#include <HTU21D.h>
#include <Adafruit_BMP280.h>
#include <LowPower.h>
#include "BoardConfig.h"
class WSPeripherals
{
public:
enum State {OFF, ON};
WSPeripherals(const BoardConfig &boardConfig);
/*
* Returns 7 if all the external devices are working properly, or an other value if it is not the case.
*/
uint8_t init();
/*
* After calling this methode , you need to execute initExternalPeripherals() to init the peripherals.
*/
void externalPeripherals(State state){_3V3PowerRail(state);}
/*
* Used to init devices after each LDO powerup, external devices need to be turned one externalPeripherals(ON) before calling this function.
*/
uint8_t initExternalPeripherals();
float batteryVoltage();
int sunlightMeasurement();
void temperatureAndATMPressureFromBMP280(float *temperature = NULL, float *ATMPressure = NULL);
float temperatureFromHTU21();
float humidity();
float compensatedHumidity();
/*
* 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);
const RF24 &getRadio();
protected:
private:
void _3V3PowerRail(State state);
const BoardConfig &_boardConfig;
const Adafruit_BMP280 _BMP280;
const HTU21D _HTU21;
const RF24 _NRF;
};
#endif //WSPERIPHERALS_H

View File

@ -1,61 +0,0 @@
/**
* Author : Anatole SCHRAMM-HENRY
* Created the : 29/05/2021
* This file contains all the config used by the other classes and sources files.
*/
#ifndef DEFINITION_H
#define DEFINITION_H
#include <Arduino.h>
#include <RF24.h>
#include "packet_format.h"
//Serial debug config part
#define SERIAL_DEBUG_ENABLED 0
#define SERIAL_BAUD_RATE 115200
//Battery config part
#define ADC_QUANTUM 0.00323632812 //ADC_VREF / ADC_RESOLUTION -> 3.314 and 10 bits (1024) in my case
#define VOLTAGE_DIV_COEFF 1.3125 //(R1 + R2)/R2
//NRF Radio config part
#define RADIO_CHANNEL 108
#define RADIO_NODE_ADDRESS "WEST1" //Weather Station 1
#define RADIO_PA_LEVEL RF24_PA_LOW //RF24_PA_MIN,RF24_PA_LOW,RF24_PA_HIGH,RF24_PA_MAX
#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.
#define SLEEP_4_SEC_INTERVAL 15
//Pin config part
typedef enum
{
D2_LDO_EN = 2,
D3_NRF_CE = 3,
A4_SDA = A4,
A5_SCL = A5,
D4_LDR_V_SENS_EN = 4,
D5_BAT_V_SENS_EN = 5,
D10_NRF_CS = 10,
D11_MOSI = 11,
D12_MISO = 12,
D13_SCK = 13,
A0_BAT_V_SENS = A0,
A1_LDR_V_SENS = A1,
} Pin;
//Payload structure
typedef struct
{
uint16_t id;
HEADER_e header : 6;
unsigned int ldr : 10;
float battery;
float bmpTemp;
float bmpPress;
float humidity;
float compensatedHumidity;
float htuTemp;
} DataPacket __attribute__((__packed__));
#endif //DEFINITION_H

View File

@ -1,6 +0,0 @@
#ifndef PACKET_FORMAT_H
#define PACKET_FORMAT_H
enum HEADER_e {WEATHER_STATION = 0};
#endif //PACKET_FORMAT_H