2021-06-28 15:43:37 +02:00
|
|
|
/**
|
|
|
|
* @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>
|
|
|
|
|
2022-05-20 17:01:50 +02:00
|
|
|
#define TOPIC "test-alex"
|
|
|
|
#define MQTT_ADDRESS "185.233.103.24"
|
2021-06-28 15:43:37 +02:00
|
|
|
#define MQTT_PORT 1883
|
|
|
|
#define ESPNAME "esp32-bastien"
|
|
|
|
#define CLUSTER "grappe1"
|
|
|
|
#define SENSORS_NUMBER 5
|
|
|
|
#define DHT22 22
|
2022-05-20 17:01:50 +02:00
|
|
|
//comment for the test part this is the good frequency
|
2022-06-02 00:21:41 +02:00
|
|
|
#define TIME_TO_SLEEP 598
|
|
|
|
//#define TIME_TO_SLEEP 28
|
2021-06-28 15:43:37 +02:00
|
|
|
#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))
|
2022-05-20 17:01:50 +02:00
|
|
|
// Solder apply on all riders behind the ESP32 for the battery voltage captor
|
|
|
|
#define ADC_PIN 35
|
|
|
|
#define CONV_FACTOR 1.7
|
2021-06-28 15:43:37 +02:00
|
|
|
#define READS 20
|
2022-05-24 10:03:16 +02:00
|
|
|
const long gmtOffset_sec = 3600;
|
2021-06-28 15:43:37 +02:00
|
|
|
|
|
|
|
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();
|
2022-06-02 15:49:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief hgfhdjskl
|
|
|
|
*
|
|
|
|
* @param txt testetest
|
|
|
|
* @param temp dqsdzfs
|
|
|
|
* @param hum
|
|
|
|
* @param number vdsvsvsvs
|
|
|
|
*/
|
2021-06-28 15:43:37 +02:00
|
|
|
void writeMsg(char *txt, float *temp, float *hum, int number);
|
|
|
|
|
|
|
|
//timeClient.getEpochTime().toCharArray(date, 50); = convertir un string en char
|
|
|
|
|
2022-05-20 17:01:50 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
2021-06-28 15:43:37 +02:00
|
|
|
#endif
|