Browse Source

Load sensor classes later (#2128)

* Sensors: refactor configuration

- move sensor implementaion to the .ino,
  remove dependency undef / define from sensor files
- update test/build/sensor.h from SENSOR_SUPPORT
- allow to change sensor config variables externally
- `#include <...>` for global headers and libraries,
  fix relative path for math library

* add missing sns <-> i2c dependency

* ledrelay should return relay_none as default

* rollback to original test header

* include debug header when requested (relative)
mcspr-patch-1
Max Prokhorov 4 years ago
committed by GitHub
parent
commit
0d40d2275a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 441 additions and 392 deletions
  1. +31
    -26
      code/espurna/config/dependencies.h
  2. +0
    -5
      code/espurna/config/deprecated.h
  3. +17
    -0
      code/espurna/config/general.h
  4. +102
    -201
      code/espurna/config/sensors.h
  5. +1
    -1
      code/espurna/led_config.h
  6. +159
    -4
      code/espurna/sensor.ino
  7. +0
    -3
      code/espurna/sensors/ADE7953Sensor.h
  8. +1
    -3
      code/espurna/sensors/AM2320Sensor.h
  9. +2
    -4
      code/espurna/sensors/AnalogSensor.h
  10. +1
    -3
      code/espurna/sensors/BH1750Sensor.h
  11. +2
    -5
      code/espurna/sensors/BMP180Sensor.h
  12. +1
    -4
      code/espurna/sensors/BMX280Sensor.h
  13. +8
    -7
      code/espurna/sensors/CSE7766Sensor.h
  14. +5
    -3
      code/espurna/sensors/DallasSensor.h
  15. +2
    -1
      code/espurna/sensors/DigitalSensor.h
  16. +3
    -1
      code/espurna/sensors/ECH1560Sensor.h
  17. +3
    -2
      code/espurna/sensors/EZOPHSensor.h
  18. +3
    -1
      code/espurna/sensors/EmonADS1X15Sensor.h
  19. +1
    -4
      code/espurna/sensors/EmonAnalogSensor.h
  20. +3
    -4
      code/espurna/sensors/EmonSensor.h
  21. +3
    -1
      code/espurna/sensors/EventSensor.h
  22. +1
    -5
      code/espurna/sensors/GUVAS12SDSensor.h
  23. +14
    -13
      code/espurna/sensors/GeigerSensor.h
  24. +4
    -2
      code/espurna/sensors/HLW8012Sensor.h
  25. +4
    -8
      code/espurna/sensors/LDRSensor.h
  26. +5
    -3
      code/espurna/sensors/MAX6675Sensor.h
  27. +3
    -2
      code/espurna/sensors/MHZ19Sensor.h
  28. +1
    -5
      code/espurna/sensors/MICS2710Sensor.h
  29. +1
    -5
      code/espurna/sensors/MICS5525Sensor.h
  30. +1
    -5
      code/espurna/sensors/NTCSensor.h
  31. +4
    -3
      code/espurna/sensors/PMSX003Sensor.h
  32. +3
    -2
      code/espurna/sensors/PZEM004TSensor.h
  33. +3
    -1
      code/espurna/sensors/PulseMeterSensor.h
  34. +4
    -3
      code/espurna/sensors/SDS011Sensor.h
  35. +1
    -4
      code/espurna/sensors/SHT3XI2CSensor.h
  36. +1
    -4
      code/espurna/sensors/SI7021Sensor.h
  37. +3
    -2
      code/espurna/sensors/SenseAirSensor.h
  38. +3
    -2
      code/espurna/sensors/SonarSensor.h
  39. +4
    -2
      code/espurna/sensors/T6613Sensor.h
  40. +1
    -4
      code/espurna/sensors/TMP3XSensor.h
  41. +4
    -4
      code/espurna/sensors/V9261FSensor.h
  42. +2
    -5
      code/espurna/sensors/VEML6075Sensor.h
  43. +2
    -5
      code/espurna/sensors/VL53L1XSensor.h
  44. +5
    -5
      code/test/build/emon.h
  45. +19
    -15
      code/test/build/sensor.h

+ 31
- 26
code/espurna/config/dependencies.h View File

@ -1,11 +1,12 @@
#pragma once
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Do not change this file unless you know what you are doing // Do not change this file unless you know what you are doing
// Configuration settings are in the general.h file // Configuration settings are in the general.h file
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define DEBUG_SUPPORT (DEBUG_SERIAL_SUPPORT || DEBUG_UDP_SUPPORT || DEBUG_TELNET_SUPPORT || DEBUG_WEB_SUPPORT)
#pragma once
//------------------------------------------------------------------------------
// Various modules configuration
#if DEBUG_TELNET_SUPPORT #if DEBUG_TELNET_SUPPORT
#undef TELNET_SUPPORT #undef TELNET_SUPPORT
@ -28,11 +29,10 @@
#endif #endif
#if UART_MQTT_SUPPORT #if UART_MQTT_SUPPORT
#define MQTT_SUPPORT 1
#undef TERMINAL_SUPPORT
#define TERMINAL_SUPPORT 0
#undef MQTT_SUPPORT
#define MQTT_SUPPORT 1 // UART<->MQTT requires MQTT and no serial debug
#undef DEBUG_SERIAL_SUPPORT #undef DEBUG_SERIAL_SUPPORT
#define DEBUG_SERIAL_SUPPORT 0
#define DEBUG_SERIAL_SUPPORT 0 // TODO: compare UART_MQTT_PORT with DEBUG_PORT? (as strings)
#endif #endif
#if ALEXA_SUPPORT #if ALEXA_SUPPORT
@ -43,8 +43,6 @@
#if RPN_RULES_SUPPORT #if RPN_RULES_SUPPORT
#undef BROKER_SUPPORT #undef BROKER_SUPPORT
#define BROKER_SUPPORT 1 // If RPN Rules enabled enable BROKER #define BROKER_SUPPORT 1 // If RPN Rules enabled enable BROKER
#undef WEB_SUPPORT
#define WEB_SUPPORT 1
#undef MQTT_SUPPORT #undef MQTT_SUPPORT
#define MQTT_SUPPORT 1 #define MQTT_SUPPORT 1
#endif #endif
@ -60,10 +58,10 @@
#endif #endif
#if DOMOTICZ_SUPPORT #if DOMOTICZ_SUPPORT
#undef MQTT_SUPPORT
#define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT
#undef BROKER_SUPPORT #undef BROKER_SUPPORT
#define BROKER_SUPPORT 1 // If Domoticz enabled enable BROKER #define BROKER_SUPPORT 1 // If Domoticz enabled enable BROKER
#undef MQTT_SUPPORT
#define MQTT_SUPPORT 1 // If Domoticz enabled enable MQTT
#endif #endif
#if HOMEASSISTANT_SUPPORT #if HOMEASSISTANT_SUPPORT
@ -91,21 +89,6 @@
#define TELNET_SERVER_ASYNC_BUFFERED 1 // enable buffered telnet by default on latest Cores #define TELNET_SERVER_ASYNC_BUFFERED 1 // enable buffered telnet by default on latest Cores
#endif #endif
#if LLMNR_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef LLMNR_SUPPORT
#define LLMNR_SUPPORT 0
#endif
#if NETBIOS_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef NETBIOS_SUPPORT
#define NETBIOS_SUPPORT 0
#endif
#if SSDP_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef SSDP_SUPPORT
#define SSDP_SUPPORT 0
#endif
#if LIGHT_PROVIDER == LIGHT_PROVIDER_TUYA #if LIGHT_PROVIDER == LIGHT_PROVIDER_TUYA
#undef TUYA_SUPPORT #undef TUYA_SUPPORT
#define TUYA_SUPPORT 1 // Need base Tuya module for this to work #define TUYA_SUPPORT 1 // Need base Tuya module for this to work
@ -118,7 +101,10 @@
#define BROKER_SUPPORT 1 // Broker is required to process relay & lights events #define BROKER_SUPPORT 1 // Broker is required to process relay & lights events
#endif #endif
//------------------------------------------------------------------------------
// Hint about ESPAsyncTCP options and our internal one
// TODO: clean-up SSL_ENABLED and USE_SSL settings for 1.15.0 // TODO: clean-up SSL_ENABLED and USE_SSL settings for 1.15.0
#if ASYNC_TCP_SSL_ENABLED && SECURE_CLIENT == SECURE_CLIENT_NONE #if ASYNC_TCP_SSL_ENABLED && SECURE_CLIENT == SECURE_CLIENT_NONE
#undef SECURE_CLIENT #undef SECURE_CLIENT
#define SECURE_CLIENT SECURE_CLIENT_AXTLS #define SECURE_CLIENT SECURE_CLIENT_AXTLS
@ -141,3 +127,22 @@
#define DEBUG_LOG_BUFFER_SUPPORT 0 // Can't buffer if there is no debugging enabled. #define DEBUG_LOG_BUFFER_SUPPORT 0 // Can't buffer if there is no debugging enabled.
// Helps to avoid checking twice for both DEBUG_SUPPORT and BUFFER_LOG_SUPPORT // Helps to avoid checking twice for both DEBUG_SUPPORT and BUFFER_LOG_SUPPORT
#endif #endif
//------------------------------------------------------------------------------
// These depend on newest Core libraries
#if LLMNR_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef LLMNR_SUPPORT
#define LLMNR_SUPPORT 0
#endif
#if NETBIOS_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef NETBIOS_SUPPORT
#define NETBIOS_SUPPORT 0
#endif
#if SSDP_SUPPORT && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#undef SSDP_SUPPORT
#define SSDP_SUPPORT 0
#endif

+ 0
- 5
code/espurna/config/deprecated.h View File

@ -48,8 +48,3 @@
#warning "Current implementation of AsyncMqttClient with axTLS is no longer supported. Consider switching to the SECURE_CLIENT configuration with MQTT_LIBRARY_ARDUINOMQTT or MQTT_LIBRARY_PUBSUBCLIENT. See: https://github.com/xoseperez/espurna/issues/1465" #warning "Current implementation of AsyncMqttClient with axTLS is no longer supported. Consider switching to the SECURE_CLIENT configuration with MQTT_LIBRARY_ARDUINOMQTT or MQTT_LIBRARY_PUBSUBCLIENT. See: https://github.com/xoseperez/espurna/issues/1465"
#endif #endif
// 1.14.2 renames MQTT to MANUAL
#undef LED_MODE_MQTT
#ifdef LED_MODE_MQTT
#warning LED_MODE_MQTT is deprecated! Please use LED_MODE_MANUAL instead
#endif

+ 17
- 0
code/espurna/config/general.h View File

@ -1926,3 +1926,20 @@
#ifndef TUYA_SERIAL #ifndef TUYA_SERIAL
#define TUYA_SERIAL Serial #define TUYA_SERIAL Serial
#endif #endif
// =============================================================================
// Configuration helpers
// =============================================================================
//------------------------------------------------------------------------------
// Provide generic way to detect debugging support
//------------------------------------------------------------------------------
#ifndef DEBUG_SUPPORT
#define DEBUG_SUPPORT ( \
DEBUG_SERIAL_SUPPORT || \
DEBUG_UDP_SUPPORT || \
DEBUG_TELNET_SUPPORT || \
DEBUG_WEB_SUPPORT \
)
#endif

+ 102
- 201
code/espurna/config/sensors.h View File

@ -1,19 +1,42 @@
// ============================================================================= // =============================================================================
// SENSORS - General data
// SENSORS - General configuration
// ============================================================================= // =============================================================================
#ifndef SENSOR_DEBUG
#define SENSOR_DEBUG 0 // Debug sensors #define SENSOR_DEBUG 0 // Debug sensors
#endif
#ifndef SENSOR_READ_INTERVAL
#define SENSOR_READ_INTERVAL 6 // Read data from sensors every 6 seconds #define SENSOR_READ_INTERVAL 6 // Read data from sensors every 6 seconds
#endif
#ifndef SENSOR_READ_MIN_INTERVAL
#define SENSOR_READ_MIN_INTERVAL 1 // Minimum read interval #define SENSOR_READ_MIN_INTERVAL 1 // Minimum read interval
#endif
#ifndef SENSOR_READ_MAX_INTERVAL
#define SENSOR_READ_MAX_INTERVAL 3600 // Maximum read interval #define SENSOR_READ_MAX_INTERVAL 3600 // Maximum read interval
#endif
#ifndef SENSOR_INIT_INTERVAL
#define SENSOR_INIT_INTERVAL 10000 // Try to re-init non-ready sensors every 10s #define SENSOR_INIT_INTERVAL 10000 // Try to re-init non-ready sensors every 10s
#endif
#ifndef SENSOR_REPORT_EVERY
#define SENSOR_REPORT_EVERY 10 // Report every this many readings #define SENSOR_REPORT_EVERY 10 // Report every this many readings
#endif
#ifndef SENSOR_REPORT_MIN_EVERY
#define SENSOR_REPORT_MIN_EVERY 1 // Minimum every value #define SENSOR_REPORT_MIN_EVERY 1 // Minimum every value
#endif
#ifndef SENSOR_REPORT_MAX_EVERY
#define SENSOR_REPORT_MAX_EVERY 60 // Maximum #define SENSOR_REPORT_MAX_EVERY 60 // Maximum
#endif
#ifndef SENSOR_USE_INDEX
#define SENSOR_USE_INDEX 0 // Use the index in topic (i.e. temperature/0) #define SENSOR_USE_INDEX 0 // Use the index in topic (i.e. temperature/0)
#endif
// even if just one sensor (0 for backwards compatibility) // even if just one sensor (0 for backwards compatibility)
#ifndef SENSOR_POWER_CHECK_STATUS #ifndef SENSOR_POWER_CHECK_STATUS
@ -428,7 +451,9 @@
#define EMON_ADC121_SUPPORT 0 // Do not build support by default #define EMON_ADC121_SUPPORT 0 // Do not build support by default
#endif #endif
#ifndef EMON_ADC121_I2C_ADDRESS
#define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto #define EMON_ADC121_I2C_ADDRESS 0x00 // 0x00 means auto
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Energy Monitor based on ADS1X15 // Energy Monitor based on ADS1X15
@ -439,7 +464,10 @@
#define EMON_ADS1X15_SUPPORT 0 // Do not build support by default #define EMON_ADS1X15_SUPPORT 0 // Do not build support by default
#endif #endif
#ifndef EMON_ADS1X15_I2C_ADDRESS
#define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto #define EMON_ADS1X15_I2C_ADDRESS 0x00 // 0x00 means auto
#endif
#define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115 #define EMON_ADS1X15_TYPE ADS1X15_CHIP_ADS1115
#define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V #define EMON_ADS1X15_GAIN ADS1X15_REG_CONFIG_PGA_4_096V
#define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8 #define EMON_ADS1X15_MASK 0x0F // A0=1 A1=2 A2=4 A3=8
@ -1195,54 +1223,6 @@
#define EZOPH_SYNC_INTERVAL 1000 // Amount of time (in ms) sync new readings. #define EZOPH_SYNC_INTERVAL 1000 // Amount of time (in ms) sync new readings.
#endif #endif
// =============================================================================
// Sensor helpers configuration - can't move to dependencies.h
// =============================================================================
#ifndef SENSOR_SUPPORT
#define SENSOR_SUPPORT ( \
AM2320_SUPPORT || \
ANALOG_SUPPORT || \
BH1750_SUPPORT || \
BMP180_SUPPORT || \
BMX280_SUPPORT || \
CSE7766_SUPPORT || \
DALLAS_SUPPORT || \
DHT_SUPPORT || \
DIGITAL_SUPPORT || \
ECH1560_SUPPORT || \
EMON_ADC121_SUPPORT || \
EMON_ADS1X15_SUPPORT || \
EMON_ANALOG_SUPPORT || \
EVENTS_SUPPORT || \
EZOPH_SUPPORT || \
GEIGER_SUPPORT || \
GUVAS12SD_SUPPORT || \
HLW8012_SUPPORT || \
LDR_SUPPORT || \
MAX6675_SUPPORT || \
MICS2710_SUPPORT || \
MICS5525_SUPPORT || \
MHZ19_SUPPORT || \
NTC_SUPPORT || \
SDS011_SUPPORT || \
SENSEAIR_SUPPORT || \
PMSX003_SUPPORT || \
PZEM004T_SUPPORT || \
PULSEMETER_SUPPORT || \
SHT3X_I2C_SUPPORT || \
SI7021_SUPPORT || \
SONAR_SUPPORT || \
T6613_SUPPORT || \
THERMOSTAT_SUPPORT || \
TMP3X_SUPPORT || \
V9261F_SUPPORT || \
VEML6075_SUPPORT || \
VL53L1X_SUPPORT || \
ADE7953_SUPPORT \
)
#endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ADC // ADC
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -1299,162 +1279,83 @@
#define ADE7953_ADDRESS 0x38 #define ADE7953_ADDRESS 0x38
#endif #endif
//--------------------------------------------------------------------------------
// Class loading
//--------------------------------------------------------------------------------
#if SENSOR_SUPPORT
#if AM2320_SUPPORT
#include "../sensors/AM2320Sensor.h"
#endif
#if ANALOG_SUPPORT
#include "../sensors/AnalogSensor.h"
#endif
#if BH1750_SUPPORT
#include "../sensors/BH1750Sensor.h"
#endif
#if BMP180_SUPPORT
#include "../sensors/BMP180Sensor.h"
#endif
#if BMX280_SUPPORT
#include "../sensors/BMX280Sensor.h"
#endif
#if CSE7766_SUPPORT
#include "../sensors/CSE7766Sensor.h"
#endif
#if DALLAS_SUPPORT
#include "../sensors/DallasSensor.h"
#endif
#if DHT_SUPPORT
#include "../sensors/DHTSensor.h"
#endif
#if DIGITAL_SUPPORT
#include "../sensors/DigitalSensor.h"
#endif
#if ECH1560_SUPPORT
#include "../sensors/ECH1560Sensor.h"
#endif
#if EMON_ADC121_SUPPORT
#include "../sensors/EmonADC121Sensor.h"
#endif
#if EMON_ADS1X15_SUPPORT
#include "../sensors/EmonADS1X15Sensor.h"
#endif
#if EMON_ANALOG_SUPPORT
#include "../sensors/EmonAnalogSensor.h"
#endif
#if EVENTS_SUPPORT
#include "../sensors/EventSensor.h"
#endif
#if EZOPH_SUPPORT
#include "../sensors/EZOPHSensor.h"
#endif
#if GEIGER_SUPPORT
#include "../sensors/GeigerSensor.h"
#endif
#if GUVAS12SD_SUPPORT
#include "../sensors/GUVAS12SDSensor.h"
#endif
#if HLW8012_SUPPORT
#include "../sensors/HLW8012Sensor.h"
#endif
#if LDR_SUPPORT
#include "../sensors/LDRSensor.h"
#endif
#if MAX6675_SUPPORT
#include "../sensors/MAX6675Sensor.h"
#endif
#if MICS2710_SUPPORT
#include "../sensors/MICS2710Sensor.h"
#endif
#if MICS5525_SUPPORT
#include "../sensors/MICS5525Sensor.h"
#endif
#if MHZ19_SUPPORT
#include "../sensors/MHZ19Sensor.h"
#endif
#if NTC_SUPPORT
#include "../sensors/NTCSensor.h"
#endif
#if SDS011_SUPPORT
#include "../sensors/SDS011Sensor.h"
#endif
#if SENSEAIR_SUPPORT
#include "../sensors/SenseAirSensor.h"
#endif
#if PMSX003_SUPPORT
#include "../sensors/PMSX003Sensor.h"
#endif
#if PULSEMETER_SUPPORT
#include "../sensors/PulseMeterSensor.h"
#endif
#if PZEM004T_SUPPORT
#include "../sensors/PZEM004TSensor.h"
#endif
#if SHT3X_I2C_SUPPORT
#include "../sensors/SHT3XI2CSensor.h"
#endif
#if SI7021_SUPPORT
#include "../sensors/SI7021Sensor.h"
#endif
#if SONAR_SUPPORT
#include "../sensors/SonarSensor.h"
#endif
#if T6613_SUPPORT
#include "../sensors/T6613Sensor.h"
#endif
#if TMP3X_SUPPORT
#include "../sensors/TMP3XSensor.h"
#endif
#if V9261F_SUPPORT
#include "../sensors/V9261FSensor.h"
#endif
// =============================================================================
// Configuration helpers
// =============================================================================
#if VEML6075_SUPPORT
#include "../sensors/VEML6075Sensor.h"
// I2C support when sensor needs it
#if ( ADE7952_SUPPORT || \
AM2320_SUPPORT || \
BH1750_SUPPORT || \
BMP180_SUPPORT || \
BMX280_SUPPORT || \
EMON_ADC121_SUPPORT || \
EMON_ADS1X15_SUPPORT || \
SHT3X_I2C_SUPPORT || \
SI7021_SUPPORT || \
VEML6075_SUPPORT || \
VL53L1X_SUPPORT \
)
#undef I2C_SUPPORT
#define I2C_SUPPORT 1
#endif #endif
#if VL53L1X_SUPPORT
#include "../sensors/VL53L1XSensor.h"
// Can't have ADC reading something else
#if ( ANALOG_SUPPORT || \
EMON_ANALOG_SUPPORT || \
GUVAS12SD_SUPPORT || \
LDR_SUPPORT || \
MICS2710_SUPPORT || \
MICS5525_SUPPORT || \
NTC_SUPPORT || \
TMP3X_SUPPORT \
)
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#endif #endif
#if ADE7953_SUPPORT
#include "../sensors/ADE7953Sensor.h"
// Provide generic way to detect sensor presence
#ifndef SENSOR_SUPPORT
#define SENSOR_SUPPORT ( \
ADE7953_SUPPORT || \
AM2320_SUPPORT || \
ANALOG_SUPPORT || \
BH1750_SUPPORT || \
BMP180_SUPPORT || \
BMX280_SUPPORT || \
CSE7766_SUPPORT || \
DALLAS_SUPPORT || \
DHT_SUPPORT || \
DIGITAL_SUPPORT || \
ECH1560_SUPPORT || \
EMON_ADC121_SUPPORT || \
EMON_ADS1X15_SUPPORT || \
EMON_ANALOG_SUPPORT || \
EVENTS_SUPPORT || \
EZOPH_SUPPORT || \
GEIGER_SUPPORT || \
GUVAS12SD_SUPPORT || \
HLW8012_SUPPORT || \
LDR_SUPPORT || \
MAX6675_SUPPORT || \
MHZ19_SUPPORT || \
MICS2710_SUPPORT || \
MICS5525_SUPPORT || \
NTC_SUPPORT || \
PMSX003_SUPPORT || \
PULSEMETER_SUPPORT || \
PZEM004T_SUPPORT || \
SDS011_SUPPORT || \
SENSEAIR_SUPPORT || \
SHT3X_I2C_SUPPORT || \
SI7021_SUPPORT || \
SONAR_SUPPORT || \
T6613_SUPPORT || \
THERMOSTAT_SUPPORT || \
TMP3X_SUPPORT || \
V9261F_SUPPORT || \
VEML6075_SUPPORT || \
VL53L1X_SUPPORT \
)
#endif #endif
#endif // SENSOR_SUPPORT

+ 1
- 1
code/espurna/led_config.h View File

@ -41,7 +41,7 @@ constexpr const unsigned char _ledRelay(unsigned char index) {
(index == 4) ? (LED5_RELAY - 1) : (index == 4) ? (LED5_RELAY - 1) :
(index == 5) ? (LED6_RELAY - 1) : (index == 5) ? (LED6_RELAY - 1) :
(index == 6) ? (LED7_RELAY - 1) : (index == 6) ? (LED7_RELAY - 1) :
(index == 7) ? (LED8_RELAY - 1) : 0
(index == 7) ? (LED8_RELAY - 1) : RELAY_NONE
); );
} }


+ 159
- 4
code/espurna/sensor.ino View File

@ -9,18 +9,173 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if SENSOR_SUPPORT #if SENSOR_SUPPORT
#include <vector> #include <vector>
#include <float.h>
#include "relay.h"
#include "broker.h"
#include "ws.h"
//--------------------------------------------------------------------------------
#include "filters/LastFilter.h" #include "filters/LastFilter.h"
#include "filters/MaxFilter.h" #include "filters/MaxFilter.h"
#include "filters/MedianFilter.h" #include "filters/MedianFilter.h"
#include "filters/MovingAverageFilter.h" #include "filters/MovingAverageFilter.h"
#include "sensors/BaseSensor.h" #include "sensors/BaseSensor.h"
#include <float.h>
#if AM2320_SUPPORT
#include "sensors/AM2320Sensor.h"
#endif
#include "relay.h"
#include "broker.h"
#include "ws.h"
#if ANALOG_SUPPORT
#include "sensors/AnalogSensor.h"
#endif
#if BH1750_SUPPORT
#include "sensors/BH1750Sensor.h"
#endif
#if BMP180_SUPPORT
#include "sensors/BMP180Sensor.h"
#endif
#if BMX280_SUPPORT
#include "sensors/BMX280Sensor.h"
#endif
#if CSE7766_SUPPORT
#include "sensors/CSE7766Sensor.h"
#endif
#if DALLAS_SUPPORT
#include "sensors/DallasSensor.h"
#endif
#if DHT_SUPPORT
#include "sensors/DHTSensor.h"
#endif
#if DIGITAL_SUPPORT
#include "sensors/DigitalSensor.h"
#endif
#if ECH1560_SUPPORT
#include "sensors/ECH1560Sensor.h"
#endif
#if EMON_ADC121_SUPPORT
#include "sensors/EmonADC121Sensor.h"
#endif
#if EMON_ADS1X15_SUPPORT
#include "sensors/EmonADS1X15Sensor.h"
#endif
#if EMON_ANALOG_SUPPORT
#include "sensors/EmonAnalogSensor.h"
#endif
#if EVENTS_SUPPORT
#include "sensors/EventSensor.h"
#endif
#if EZOPH_SUPPORT
#include "sensors/EZOPHSensor.h"
#endif
#if GEIGER_SUPPORT
#include "sensors/GeigerSensor.h"
#endif
#if GUVAS12SD_SUPPORT
#include "sensors/GUVAS12SDSensor.h"
#endif
#if HLW8012_SUPPORT
#include "sensors/HLW8012Sensor.h"
#endif
#if LDR_SUPPORT
#include "sensors/LDRSensor.h"
#endif
#if MAX6675_SUPPORT
#include "sensors/MAX6675Sensor.h"
#endif
#if MICS2710_SUPPORT
#include "sensors/MICS2710Sensor.h"
#endif
#if MICS5525_SUPPORT
#include "sensors/MICS5525Sensor.h"
#endif
#if MHZ19_SUPPORT
#include "sensors/MHZ19Sensor.h"
#endif
#if NTC_SUPPORT
#include "sensors/NTCSensor.h"
#endif
#if SDS011_SUPPORT
#include "sensors/SDS011Sensor.h"
#endif
#if SENSEAIR_SUPPORT
#include "sensors/SenseAirSensor.h"
#endif
#if PMSX003_SUPPORT
#include "sensors/PMSX003Sensor.h"
#endif
#if PULSEMETER_SUPPORT
#include "sensors/PulseMeterSensor.h"
#endif
#if PZEM004T_SUPPORT
#include "sensors/PZEM004TSensor.h"
#endif
#if SHT3X_I2C_SUPPORT
#include "sensors/SHT3XI2CSensor.h"
#endif
#if SI7021_SUPPORT
#include "sensors/SI7021Sensor.h"
#endif
#if SONAR_SUPPORT
#include "sensors/SonarSensor.h"
#endif
#if T6613_SUPPORT
#include "sensors/T6613Sensor.h"
#endif
#if TMP3X_SUPPORT
#include "sensors/TMP3XSensor.h"
#endif
#if V9261F_SUPPORT
#include "sensors/V9261FSensor.h"
#endif
#if VEML6075_SUPPORT
#include "sensors/VEML6075Sensor.h"
#endif
#if VL53L1X_SUPPORT
#include "sensors/VL53L1XSensor.h"
#endif
#if ADE7953_SUPPORT
#include "sensors/ADE7953Sensor.h"
#endif
//--------------------------------------------------------------------------------
struct sensor_magnitude_t { struct sensor_magnitude_t {
BaseSensor * sensor; // Sensor object BaseSensor * sensor; // Sensor object


+ 0
- 3
code/espurna/sensors/ADE7953Sensor.h View File

@ -8,9 +8,6 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h> #include <Arduino.h>
#include <Wire.h> #include <Wire.h>


+ 1
- 3
code/espurna/sensors/AM2320Sensor.h View File

@ -7,10 +7,8 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include "Arduino.h"
#include "I2CSensor.h" #include "I2CSensor.h"
// https://akizukidenshi.com/download/ds/aosong/AM2320.pdf // https://akizukidenshi.com/download/ds/aosong/AM2320.pdf


+ 2
- 4
code/espurna/sensors/AnalogSensor.h View File

@ -7,11 +7,9 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "../debug.h"
#include "BaseSensor.h" #include "BaseSensor.h"
class AnalogSensor : public BaseSensor { class AnalogSensor : public BaseSensor {


+ 1
- 3
code/espurna/sensors/BH1750Sensor.h View File

@ -7,10 +7,8 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include "Arduino.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#define BH1750_CONTINUOUS_HIGH_RES_MODE 0x10 // Start measurement at 1lx resolution. Measurement time is approx 120ms. #define BH1750_CONTINUOUS_HIGH_RES_MODE 0x10 // Start measurement at 1lx resolution. Measurement time is approx 120ms.


+ 2
- 5
code/espurna/sensors/BMP180Sensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#include "../utils.h"
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include "Arduino.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "../utils.h"
#define BMP180_CHIP_ID 0x55 #define BMP180_CHIP_ID 0x55


+ 1
- 4
code/espurna/sensors/BMX280Sensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h> #include <Arduino.h>
#include "../utils.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "../utils.h"
#define BMX280_CHIP_BMP280 0x58 #define BMX280_CHIP_BMP280 0x58
#define BMX280_CHIP_BME280 0x60 #define BMX280_CHIP_BME280 0x60


+ 8
- 7
code/espurna/sensors/CSE7766Sensor.h View File

@ -8,11 +8,12 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "../debug.h"
#include "BaseSensor.h"
class CSE7766Sensor : public BaseSensor { class CSE7766Sensor : public BaseSensor {
public: public:
@ -234,10 +235,10 @@ class CSE7766Sensor : public BaseSensor {
if ((_data[0] & 0xFC) > 0xF0) { if ((_data[0] & 0xFC) > 0xF0) {
_error = SENSOR_ERROR_OTHER; _error = SENSOR_ERROR_OTHER;
#if SENSOR_DEBUG #if SENSOR_DEBUG
if (0xF1 == _data[0] & 0xF1) DEBUG_MSG("[SENSOR] CSE7766: Abnormal coefficient storage area\n");
if (0xF2 == _data[0] & 0xF2) DEBUG_MSG("[SENSOR] CSE7766: Power cycle exceeded range\n");
if (0xF4 == _data[0] & 0xF4) DEBUG_MSG("[SENSOR] CSE7766: Current cycle exceeded range\n");
if (0xF8 == _data[0] & 0xF8) DEBUG_MSG("[SENSOR] CSE7766: Voltage cycle exceeded range\n");
if (0xF1 == (_data[0] & 0xF1)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Abnormal coefficient storage area\n"));
if (0xF2 == (_data[0] & 0xF2)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Power cycle exceeded range\n"));
if (0xF4 == (_data[0] & 0xF4)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Current cycle exceeded range\n"));
if (0xF8 == (_data[0] & 0xF8)) DEBUG_MSG_P(PSTR("[SENSOR] CSE7766: Voltage cycle exceeded range\n"));
#endif #endif
return; return;
} }


+ 5
- 3
code/espurna/sensors/DallasSensor.h View File

@ -8,11 +8,13 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <vector>
#include <Arduino.h>
#include <OneWire.h> #include <OneWire.h>
#include <vector>
#include "BaseSensor.h"
#define DS_CHIP_DS18S20 0x10 #define DS_CHIP_DS18S20 0x10
#define DS_CHIP_DS1822 0x22 #define DS_CHIP_DS1822 0x22
#define DS_CHIP_DS18B20 0x28 #define DS_CHIP_DS18B20 0x28


+ 2
- 1
code/espurna/sensors/DigitalSensor.h View File

@ -7,7 +7,8 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "BaseSensor.h" #include "BaseSensor.h"
class DigitalSensor : public BaseSensor { class DigitalSensor : public BaseSensor {


+ 3
- 1
code/espurna/sensors/ECH1560Sensor.h View File

@ -7,7 +7,9 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "../debug.h"
#include "BaseSensor.h" #include "BaseSensor.h"
class ECH1560Sensor : public BaseSensor { class ECH1560Sensor : public BaseSensor {


+ 3
- 2
code/espurna/sensors/EZOPHSensor.h View File

@ -9,10 +9,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "BaseSensor.h"
class EZOPHSensor : public BaseSensor { class EZOPHSensor : public BaseSensor {
public: public:


+ 3
- 1
code/espurna/sensors/EmonADS1X15Sensor.h View File

@ -7,9 +7,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "EmonSensor.h" #include "EmonSensor.h"
#define ADS1X15_CHANNELS (4) #define ADS1X15_CHANNELS (4)
#define ADS1X15_CHIP_ADS1015 (0) #define ADS1X15_CHIP_ADS1015 (0)


+ 1
- 4
code/espurna/sensors/EmonAnalogSensor.h View File

@ -7,11 +7,8 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "EmonSensor.h" #include "EmonSensor.h"
#define EMON_ANALOG_RESOLUTION 10 #define EMON_ANALOG_RESOLUTION 10


+ 3
- 4
code/espurna/sensors/EmonSensor.h View File

@ -7,13 +7,12 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include "Arduino.h"
#include "../debug.h"
#include "I2CSensor.h" #include "I2CSensor.h"
extern "C" { extern "C" {
#include "libs/fs_math.h"
#include "../libs/fs_math.h"
} }
class EmonSensor : public I2CSensor { class EmonSensor : public I2CSensor {


+ 3
- 1
code/espurna/sensors/EventSensor.h View File

@ -7,7 +7,9 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "../debug.h"
#include "BaseSensor.h" #include "BaseSensor.h"
// we are bound by usable GPIOs // we are bound by usable GPIOs


+ 1
- 5
code/espurna/sensors/GUVAS12SDSensor.h View File

@ -8,14 +8,10 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h> #include <Arduino.h>
#include "../utils.h"
#include "BaseSensor.h" #include "BaseSensor.h"
#include "../utils.h"
// http://www.eoc-inc.com/genicom/GUVA-S12SD.pdf // http://www.eoc-inc.com/genicom/GUVA-S12SD.pdf
// //


+ 14
- 13
code/espurna/sensors/GeigerSensor.h View File

@ -8,7 +8,9 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "../debug.h"
#include "BaseSensor.h" #include "BaseSensor.h"
class GeigerSensor : public BaseSensor { class GeigerSensor : public BaseSensor {
@ -131,38 +133,37 @@ unsigned char type(unsigned char index) {
// Current value for slot # index // Current value for slot # index
double value(unsigned char index) { double value(unsigned char index) {
unsigned char i=0; unsigned char i=0;
#if GEIGER_REPORT_CPM
#if GEIGER_REPORT_CPM
if (index == i++) { if (index == i++) {
unsigned long _period_begin = _lastreport_cpm; unsigned long _period_begin = _lastreport_cpm;
_lastreport_cpm = millis(); _lastreport_cpm = millis();
double value = _events * 60000; double value = _events * 60000;
value = value / (_lastreport_cpm-_period_begin); value = value / (_lastreport_cpm-_period_begin);
#if SENSOR_DEBUG #if SENSOR_DEBUG
char data[128]; char buffer[32];
dtostrf(value, 1, 4, buffer);
snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | CPM: %s", _ticks, (_lastreport_cpm-_period_begin), buffer);
DEBUG_MSG("[GEIGER] %s\n", data);
char buffer[32] = {0};
dtostrf(value, 1, 4, buffer);
DEBUG_MSG_P(PSTR("[GEIGER] Ticks: %u | Interval: %u | CPM: %s\n"), _ticks, (_lastreport_cpm - _period_begin), buffer);
#endif #endif
_events = 0; _events = 0;
return value; return value;
} }
#endif
#if GEIGER_REPORT_SIEVERTS
#endif
#if GEIGER_REPORT_SIEVERTS
if (index == i++) { if (index == i++) {
unsigned long _period_begin = _lastreport_sv; unsigned long _period_begin = _lastreport_sv;
_lastreport_sv = millis(); _lastreport_sv = millis();
double value = _ticks * 60000 / _cpm2sievert; double value = _ticks * 60000 / _cpm2sievert;
value = value / (_lastreport_sv-_period_begin); value = value / (_lastreport_sv-_period_begin);
#if SENSOR_DEBUG #if SENSOR_DEBUG
char data[128]; char buffer[32];
dtostrf(value, 1, 4, buffer);
snprintf(data, sizeof(data), "Ticks: %u | Interval: %u | µSievert: %s", _ticks, (_lastreport_sv-_period_begin), buffer);
DEBUG_MSG("[GEIGER] %s\n", data);
char buffer[32] = {0};
dtostrf(value, 1, 4, buffer);
DEBUG_MSG_P(PSTR("[GEIGER] Ticks: %u | Interval: %u | CPM: %s\n"), _ticks, (_lastreport_cpm - _period_begin), buffer);
#endif #endif
_ticks = 0; _ticks = 0;
return value; return value;
} }
#endif
#endif
return 0; return 0;
} }


+ 4
- 2
code/espurna/sensors/HLW8012Sensor.h View File

@ -7,10 +7,12 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <HLW8012.h> #include <HLW8012.h>
#include "../debug.h"
#include "BaseSensor.h"
class HLW8012Sensor : public BaseSensor { class HLW8012Sensor : public BaseSensor {
public: public:


+ 4
- 8
code/espurna/sensors/LDRSensor.h View File

@ -7,12 +7,12 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "AnalogSensor.h" #include "AnalogSensor.h"
extern "C" {
#include "../libs/fs_math.h"
}
#define LDR_GL5516 1 #define LDR_GL5516 1
#define LDR_GL5528 2 #define LDR_GL5528 2
@ -22,10 +22,6 @@
#define LDR_GL5549 6 #define LDR_GL5549 6
#define LDR_OTHER 99 #define LDR_OTHER 99
extern "C" {
#include "../libs/fs_math.h"
}
class LDRSensor : public AnalogSensor { class LDRSensor : public AnalogSensor {
public: public:


+ 5
- 3
code/espurna/sensors/MAX6675Sensor.h View File

@ -8,11 +8,13 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <vector>
#include <Arduino.h>
#include <MAX6675.h> #include <MAX6675.h>
#include <vector>
#include "BaseSensor.h"
#define MAX6675_READ_INTERVAL 3000 #define MAX6675_READ_INTERVAL 3000
class MAX6675Sensor : public BaseSensor { class MAX6675Sensor : public BaseSensor {


+ 3
- 2
code/espurna/sensors/MHZ19Sensor.h View File

@ -10,10 +10,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "BaseSensor.h"
#define MHZ19_REQUEST_LEN 8 #define MHZ19_REQUEST_LEN 8
#define MHZ19_RESPONSE_LEN 9 #define MHZ19_RESPONSE_LEN 9
#define MHZ19_TIMEOUT 1000 #define MHZ19_TIMEOUT 1000


+ 1
- 5
code/espurna/sensors/MICS2710Sensor.h View File

@ -7,13 +7,9 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "BaseSensor.h" #include "BaseSensor.h"
extern "C" { extern "C" {
#include "../libs/fs_math.h" #include "../libs/fs_math.h"
} }


+ 1
- 5
code/espurna/sensors/MICS5525Sensor.h View File

@ -7,13 +7,9 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "BaseSensor.h" #include "BaseSensor.h"
extern "C" { extern "C" {
#include "../libs/fs_math.h" #include "../libs/fs_math.h"
} }


+ 1
- 5
code/espurna/sensors/NTCSensor.h View File

@ -7,13 +7,9 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "AnalogSensor.h" #include "AnalogSensor.h"
extern "C" { extern "C" {
#include "../libs/fs_math.h" #include "../libs/fs_math.h"
} }


+ 4
- 3
code/espurna/sensors/PMSX003Sensor.h View File

@ -9,11 +9,12 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "../debug.h"
#include "BaseSensor.h"
// Generic data // Generic data
#define PMS_BAUD_RATE 9600 #define PMS_BAUD_RATE 9600


+ 3
- 2
code/espurna/sensors/PZEM004TSensor.h View File

@ -49,10 +49,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include <PZEM004T.h>
#include "BaseSensor.h" #include "BaseSensor.h"
#include <PZEM004T.h>
#define PZ_MAGNITUDE_COUNT 4 #define PZ_MAGNITUDE_COUNT 4


+ 3
- 1
code/espurna/sensors/PulseMeterSensor.h View File

@ -7,7 +7,9 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include "../debug.h"
#include "BaseSensor.h" #include "BaseSensor.h"
class PulseMeterSensor : public BaseSensor { class PulseMeterSensor : public BaseSensor {


+ 4
- 3
code/espurna/sensors/SDS011Sensor.h View File

@ -10,10 +10,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "BaseSensor.h"
class SDS011Sensor : public BaseSensor { class SDS011Sensor : public BaseSensor {
@ -125,7 +126,7 @@ class SDS011Sensor : public BaseSensor {
int len = 0; int len = 0;
int pm10_serial = 0; int pm10_serial = 0;
int pm25_serial = 0; int pm25_serial = 0;
int checksum_is;
int checksum_is = 0;
int checksum_ok = 0; int checksum_ok = 0;
while ((_serial->available() > 0) && (_serial->available() >= (10-len))) { while ((_serial->available() > 0) && (_serial->available() >= (10-len))) {


+ 1
- 4
code/espurna/sensors/SHT3XI2CSensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h> #include <Arduino.h>
#include "../utils.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "../utils.h"
class SHT3XI2CSensor : public I2CSensor { class SHT3XI2CSensor : public I2CSensor {


+ 1
- 4
code/espurna/sensors/SI7021Sensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h> #include <Arduino.h>
#include "../utils.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "../utils.h"
#define SI7021_SCL_FREQUENCY 200 #define SI7021_SCL_FREQUENCY 200


+ 3
- 2
code/espurna/sensors/SenseAirSensor.h View File

@ -8,10 +8,11 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "BaseSensor.h" #include "BaseSensor.h"
#include <SoftwareSerial.h>
// SenseAir sensor utils // SenseAir sensor utils
class SenseAir class SenseAir


+ 3
- 2
code/espurna/sensors/SonarSensor.h View File

@ -8,9 +8,10 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include <NewPing.h>
#include "BaseSensor.h" #include "BaseSensor.h"
#include "NewPing.h"
class SonarSensor : public BaseSensor { class SonarSensor : public BaseSensor {


+ 4
- 2
code/espurna/sensors/T6613Sensor.h View File

@ -9,10 +9,12 @@
#pragma once #pragma once
#include "Arduino.h"
#include "BaseSensor.h"
#include <Arduino.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#include "BaseSensor.h"
#define T6613_REQUEST_LEN 5 #define T6613_REQUEST_LEN 5
#define T6613_RESPONSE_LEN 5 #define T6613_RESPONSE_LEN 5
#define T6613_TIMEOUT 1000 #define T6613_TIMEOUT 1000


+ 1
- 4
code/espurna/sensors/TMP3XSensor.h View File

@ -7,11 +7,8 @@
#pragma once #pragma once
// Set ADC to TOUT pin
#undef ADC_MODE_VALUE
#define ADC_MODE_VALUE ADC_TOUT
#include <Arduino.h>
#include "Arduino.h"
#include "BaseSensor.h" #include "BaseSensor.h"
#define TMP3X_TMP35 35 #define TMP3X_TMP35 35


+ 4
- 4
code/espurna/sensors/V9261FSensor.h View File

@ -7,14 +7,14 @@
#pragma once #pragma once
#include "Arduino.h"
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "BaseSensor.h" #include "BaseSensor.h"
extern "C" { extern "C" {
#include "libs/fs_math.h"
#include "../libs/fs_math.h"
} }
#include <SoftwareSerial.h>
class V9261FSensor : public BaseSensor { class V9261FSensor : public BaseSensor {
public: public:


+ 2
- 5
code/espurna/sensors/VEML6075Sensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include <SparkFun_VEML6075_Arduino_Library.h>
#include "Arduino.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "SparkFun_VEML6075_Arduino_Library.h"
class VEML6075Sensor : public I2CSensor { class VEML6075Sensor : public I2CSensor {


+ 2
- 5
code/espurna/sensors/VL53L1XSensor.h View File

@ -7,13 +7,10 @@
#pragma once #pragma once
#undef I2C_SUPPORT
#define I2C_SUPPORT 1 // Explicitly request I2C support.
#include <Arduino.h>
#include <VL53L1X.h>
#include "Arduino.h"
#include "I2CSensor.h" #include "I2CSensor.h"
#include "VL53L1X.h"
class VL53L1XSensor : public I2CSensor { class VL53L1XSensor : public I2CSensor {


+ 5
- 5
code/test/build/emon.h View File

@ -1,10 +1,10 @@
#define ADE7953_SUPPORT 1
#define CSE7766_SUPPORT 1
#define ECH1560_SUPPORT 1
#define EMON_ADC121_SUPPORT 1 #define EMON_ADC121_SUPPORT 1
#define EMON_ADS1X15_SUPPORT 1 #define EMON_ADS1X15_SUPPORT 1
#define CSE7766_SUPPORT 1
#define PZEM004T_SUPPORT 1
#define EMON_ANALOG_SUPPORT 1
#define HLW8012_SUPPORT 1 #define HLW8012_SUPPORT 1
#define ECH1560_SUPPORT 1
#define PULSEMETER_SUPPORT 1 #define PULSEMETER_SUPPORT 1
#define PZEM004T_SUPPORT 1
#define V9261F_SUPPORT 1 #define V9261F_SUPPORT 1
#define ADE7953_SUPPORT 1
#define EMON_ANALOG_SUPPORT 1

+ 19
- 15
code/test/build/sensor.h View File

@ -1,25 +1,29 @@
#define AM2320_SUPPORT 1 #define AM2320_SUPPORT 1
#define ANALOG_SUPPORT 1
#define BH1750_SUPPORT 1 #define BH1750_SUPPORT 1
#define BMP180_SUPPORT 1 #define BMP180_SUPPORT 1
#define BMX280_SUPPORT 1 #define BMX280_SUPPORT 1
#define SHT3X_I2C_SUPPORT 1
#define SHT3X_I2C_SUPPORT 1
#define SI7021_SUPPORT 1
#define PMSX003_SUPPORT 1
#define SENSEAIR_SUPPORT 1
#define VL53L1X_SUPPORT 1
#define DALLAS_SUPPORT 1 #define DALLAS_SUPPORT 1
#define MICS2710_SUPPORT 1
#define MICS5525_SUPPORT 1
#define MAX6675_SUPPORT 1
#define DHT_SUPPORT 1 #define DHT_SUPPORT 1
#define T6613_SUPPORT 1
#define TMP3X_SUPPORT 1
#define EVENTS_SUPPORT 1
#define DIGITAL_SUPPORT 1 #define DIGITAL_SUPPORT 1
#define SONAR_SUPPORT 1
#define EVENTS_SUPPORT 1
#define EZOPH_SUPPORT 1
#define GEIGER_SUPPORT 1
#define GUVAS12SD_SUPPORT 1
#define LDR_SUPPORT 1
#define MAX6675_SUPPORT 1
#define MHZ19_SUPPORT 1 #define MHZ19_SUPPORT 1
#define MICS2710_SUPPORT 1
#define MICS5525_SUPPORT 1
#define NTC_SUPPORT 1 #define NTC_SUPPORT 1
#define LDR_SUPPORT 1
#define GUVAS12SD_SUPPORT 1
#define PMSX003_SUPPORT 1
#define SDS011_SUPPORT 1
#define SENSEAIR_SUPPORT 1
#define SHT3X_I2C_SUPPORT 1
#define SI7021_SUPPORT 1
#define SONAR_SUPPORT 1
#define T6613_SUPPORT 1
#define THERMOSTAT_SUPPORT 1 #define THERMOSTAT_SUPPORT 1
#define TMP3X_SUPPORT 1
#define VEML6075_SUPPORT 1
#define VL53L1X_SUPPORT 1

Loading…
Cancel
Save