code-grappe/include/main.h
2022-06-02 15:49:34 +02:00

69 lines
2 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 "test-alex"
#define MQTT_ADDRESS "185.233.103.24"
#define MQTT_PORT 1883
#define ESPNAME "esp32-bastien"
#define CLUSTER "grappe1"
#define SENSORS_NUMBER 5
#define DHT22 22
//comment for the test part this is the good frequency
#define TIME_TO_SLEEP 598
//#define TIME_TO_SLEEP 28
#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))
// Solder apply on all riders behind the ESP32 for the battery voltage captor
#define ADC_PIN 35
#define CONV_FACTOR 1.7
#define READS 20
const long gmtOffset_sec = 3600;
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();
/**
* @brief hgfhdjskl
*
* @param txt testetest
* @param temp dqsdzfs
* @param hum
* @param number vdsvsvsvs
*/
void writeMsg(char *txt, float *temp, float *hum, int number);
//timeClient.getEpochTime().toCharArray(date, 50); = convertir un string en char
/*
For test the esp32 signal emission without server Working/fixed/updated :
mosquitto_sub -h cohabit-capteurs.aquilenet.fr -u capteurs -P Fablab -t test-alex
*/
#endif