Add teleinfo module

This commit is contained in:
Mathieu Maret 2021-02-18 00:25:45 +01:00
parent e60b8ef8ae
commit 9110ae3589
5 changed files with 34 additions and 10 deletions

View File

@ -18,6 +18,8 @@
#define BME680_ALT_FEED_FORMAT "/feeds/%s/%s/bme680/alt" #define BME680_ALT_FEED_FORMAT "/feeds/%s/%s/bme680/alt"
#define BME680_IAQ_FEED_FORMAT "/feeds/%s/%s/bme680/iaq" #define BME680_IAQ_FEED_FORMAT "/feeds/%s/%s/bme680/iaq"
#define BME680_IAQ_ACC_FEED_FORMAT "/feeds/%s/%s/bme680/iaqAcc" #define BME680_IAQ_ACC_FEED_FORMAT "/feeds/%s/%s/bme680/iaqAcc"
#define TELEINFO_IINST_FEED_FORMAT "/feeds/%s/%s/teleinfo/iinst"
#define TELEINFO_PAPP_FEED_FORMAT "/feeds/%s/%s/teleinfo/papp"
#ifndef CONFIG_DISABLE_MQTT #ifndef CONFIG_DISABLE_MQTT
#include "Adafruit_MQTT.h" #include "Adafruit_MQTT.h"

View File

@ -51,6 +51,7 @@
#include "Adafruit_MQTT.h" #include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h" #include "Adafruit_MQTT_Client.h"
#include "EEPROM.h" #include "EEPROM.h"
#include "Teleinfo.h"
extern "C" { extern "C" {
#include <user_interface.h> #include <user_interface.h>
@ -68,7 +69,7 @@ float bme680BSECT, bme680BSECP, bme680BSECH, bme680BSECIaq, bme680BSECIaqAcc;
int dryness; int dryness;
uint8_t mode; uint8_t mode;
int reconfig = 0; int reconfig = 0;
productConfig conf = {BOOTMODE_SETUP, "", "", "", "", "", "", 1883, 0, 0, 0, 0, 0, 0, 0, ""}; productConfig conf = {BOOTMODE_SETUP, NULL, NULL, NULL, NULL, NULL, NULL, 1883, 0, 0, 0, 0, 0, 0, 0, NULL};
// Should have less that MAXSUBSCRIPTIONS elements // Should have less that MAXSUBSCRIPTIONS elements
// MAXSUBSCRIPTIONS is defined is Adafruit_mqtt.h // MAXSUBSCRIPTIONS is defined is Adafruit_mqtt.h
const int gpioControlled[] = CONFIG_CONTROLLED_GPIO; const int gpioControlled[] = CONFIG_CONTROLLED_GPIO;
@ -229,12 +230,16 @@ void setup() {
SKETCH_DEBUG_PRINTLN(); SKETCH_DEBUG_PRINTLN();
// Get GPIO 3 Status // Get GPIO 3 Status
#if CONFIG_SERIAL_SHOULD_SWAP
SKETCH_DEBUG_PRINTLN("SWAP UART");
Serial.swap(); //Switch Serial on GPIO 13 & 15 Serial.swap(); //Switch Serial on GPIO 13 & 15
#endif
pinMode(CONFIG_SETUP_GPIO, INPUT_PULLUP); pinMode(CONFIG_SETUP_GPIO, INPUT_PULLUP);
int txStatus = digitalRead(CONFIG_SETUP_GPIO); int txStatus = digitalRead(CONFIG_SETUP_GPIO);
#ifndef CONFIG_ENABLE_EXTRA_GPIO //#if !defined(CONFIG_ENABLE_EXTRA_GPIO) && CONFIG_SERIAL_SHOULD_SWAP
Serial.swap(); // Switch back on GPIO 1 & 3 // Serial.swap(); // Switch back on GPIO 1 & 3
#endif // SKETCH_DEBUG_PRINTLN("SWAP UART");
//#endif
EEPROM.begin(CONFIG_EEPROM_SIZE); EEPROM.begin(CONFIG_EEPROM_SIZE);
EepromReadConfig(conf); EepromReadConfig(conf);
@ -283,6 +288,9 @@ void setup() {
if(!BME680BSECSetup()){ if(!BME680BSECSetup()){
SKETCH_DEBUG_PRINTLN("BME680 with BSEC init success"); SKETCH_DEBUG_PRINTLN("BME680 with BSEC init success");
} }
if(!TeleinfoSetup()){
SKETCH_DEBUG_PRINTLN("Teleinfo init success");
}
WebSetupServer(mode); WebSetupServer(mode);
} }
#ifdef CONFIG_ENABLE_POWER_SAVE #ifdef CONFIG_ENABLE_POWER_SAVE
@ -360,5 +368,6 @@ void loop() {
MqttBatchPublish(batchInfo, conf.mqttUser, conf.host); MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
nbCycle = 0; nbCycle = 0;
} }
TeleinfoProcess();
} }
} }

View File

@ -39,6 +39,11 @@
#define CONFIG_DHT_PIN 0 #define CONFIG_DHT_PIN 0
#endif #endif
#if defined(CONFIG_ENABLE_TELEINFO)
#warning "TELEINFO is using SERIAL for communication. Debug will be on Serial1 (D4)"
#define DEBUG_PRINTER_WIFICONTROLSENSOR Serial1
#endif
#ifndef CONFIG_DRY_POWER_PIN #ifndef CONFIG_DRY_POWER_PIN
#define CONFIG_DRY_POWER_PIN -1 #define CONFIG_DRY_POWER_PIN -1
#endif #endif
@ -70,3 +75,7 @@
#ifndef CONFIG_DHT_TYPE #ifndef CONFIG_DHT_TYPE
#define CONFIG_DHT_TYPE DHT11 #define CONFIG_DHT_TYPE DHT11
#endif #endif
#if CONFIG_SETUP_GPIO == 3 || CONFIG_SETUP_GPIO == 1
#define CONFIG_SERIAL_SHOULD_SWAP
#endif

View File

@ -44,6 +44,8 @@
// Long press on this button will put device in setup mode at runtime // Long press on this button will put device in setup mode at runtime
#define CONFIG_SETUP_BUTTON 0 #define CONFIG_SETUP_BUTTON 0
// Teleinfo https://github.com/hallard/LibTeleinfo/
#define CONFIG_ENABLE_TELEINFO
/* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */ /* DEFAULT VALUE ALSO DEFINED IN CONFIG.H */
//If this GPIO is LOW at boot, device will enter setup mode //If this GPIO is LOW at boot, device will enter setup mode
@ -53,7 +55,7 @@
//#define CONFIG_WEB_DELAY_MS 100 //#define CONFIG_WEB_DELAY_MS 100
// Get sensors value every X ms // Get sensors value every X ms
#define CONFIG_SAMPLING_PERIODE_MS 3000 #define CONFIG_SAMPLING_PERIODE_MS 30000
// Name of the SSID when in AP mode for configuration // Name of the SSID when in AP mode for configuration
#define CONFIG_SSID_NAME "ESPConfiguratorBureau" #define CONFIG_SSID_NAME "ESPConfiguratorBureau"

View File

@ -2,13 +2,15 @@
//#define CONFIG_SKETCH_DEBUG //#define CONFIG_SKETCH_DEBUG
// Set where debug messages will be printed. // Set where debug messages will be printed.
#define DEBUG_PRINTER Serial #ifndef DEBUG_PRINTER_WIFICONTROLSENSOR
#define DEBUG_PRINTER_WIFICONTROLSENSOR Serial
#endif
#ifdef CONFIG_SKETCH_DEBUG #ifdef CONFIG_SKETCH_DEBUG
#define SKETCH_DEBUG_INIT(speed){ DEBUG_PRINTER.begin(speed); } #define SKETCH_DEBUG_INIT(speed){ DEBUG_PRINTER_WIFICONTROLSENSOR.begin(speed); }
#define SKETCH_DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } #define SKETCH_DEBUG_PRINT(...) { DEBUG_PRINTER_WIFICONTROLSENSOR.print(__VA_ARGS__); }
#define SKETCH_DEBUG_PRINTF(...) { DEBUG_PRINTER.printf(__VA_ARGS__); } #define SKETCH_DEBUG_PRINTF(...) { DEBUG_PRINTER_WIFICONTROLSENSOR.printf(__VA_ARGS__); }
#define SKETCH_DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } #define SKETCH_DEBUG_PRINTLN(...) { DEBUG_PRINTER_WIFICONTROLSENSOR.println(__VA_ARGS__); }
#else #else
#define SKETCH_DEBUG_INIT(speed) #define SKETCH_DEBUG_INIT(speed)
#define SKETCH_DEBUG_PRINT(...) {} #define SKETCH_DEBUG_PRINT(...) {}