code-grappe/include/main.h

53 lines
1.7 KiB
C
Raw Normal View History

/**
* @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
2021-11-08 21:07:15 +01:00
* @author Bastien Boineau, Lucas Pallaro, Loris Galland, pgp
* @version 1.0.1
* @date 08/11/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>
#include <RTClib.h>
#define TOPIC "test1"
2021-11-08 21:03:55 +01:00
#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
#define TIME_TO_SLEEP 3600 // l'ESp32 est rallumé à plein régime pour prendre une mesure toutes les 3600 secondes (soit 1 fois/heure)
2021-11-29 15:19:44 +01:00
#define US_TO_S_FACTOR 1000000 //1000000 => 1 mesure par 10 min
#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);
void wakeup();
//timeClient.getEpochTime().toCharArray(date, 50); = convertir un string en char
#endif