code-grappe/include/main.h

51 lines
1.5 KiB
C++

/**
* @file main.h
* @brief projet thermo-bibli, Équiper la réserve de l'UB de capteurs de température et hygrométrie autonomes et connectés
* @author Bastien Boineau, Lucas Pallaro, Loris Galland
* @version 1.0
* @date 28/06/2021
*/
#ifndef HEADER_H
#define HEADER_H
#include <ESPAsyncWebServer.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <DHT.h>
#include <PubSubClient.h>
#include <Pangodream_18650_CL.h>
#include <secret.h>
#define TOPIC "test1"
#define MQTT_ADDRESS "192.168.0.242"
#define MQTT_PORT 1883
#define ESPNAME "esp32-bastien"
#define CLUSTER "grappe1"
#define SENSORS_NUMBER 5
#define DHT22 22
#define TIME_TO_SLEEP 598
#define US_TO_S_FACTOR 1000000
#define R2 100
#define R3 10
#define VOLTAGE_OUT(Vin) (((Vin)*R3) / (R2 + R3))
#define VOLTAGE_MAX 4200
#define VOLTAGE_MIN 3300
#define ADC_REFERENCE 1100
#define VOLTAGE_TO_ADC(in) ((ADC_REFERENCE * (in)) / 4096)
#define BATTERY_MAX_ADC VOLTAGE_TO_ADC(VOLTAGE_OUT(VOLTAGE_MAX))
#define BATTERY_MIN_ADC VOLTAGE_TO_ADC(VOLTAGE_OUT(VOLTAGE_MIN))
#define ADC_PIN 34
#define CONV_FACTOR 2.92
#define READS 20
void setupMQTT(const char *address, int port);
void setupWIFI(const char *wifi_name, const char *password);
void reconnect(void);
void initSensors(DHT *sensors, int number);
void readSensors(DHT sensors[], float temp[], float hum[], int number);
void sleep();
std::tuple<int, int, int> getDate();
void writeMsg(char *txt, float *temp, float *hum, int number);
//timeClient.getEpochTime().toCharArray(date, 50); = convertir un string en char
#endif