Browse Source

Disable ADC_VCC when using ADC in Emon module

fastled
Xose Pérez 7 years ago
parent
commit
9747e571e0
4 changed files with 25 additions and 22 deletions
  1. +0
    -8
      code/espurna/config/general.h
  2. +20
    -11
      code/espurna/config/sensors.h
  3. +3
    -1
      code/espurna/emon.ino
  4. +2
    -2
      code/espurna/espurna.ino

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

@ -16,14 +16,6 @@
#define EEPROM_ENERGY_COUNT 1 #define EEPROM_ENERGY_COUNT 1
#define EEPROM_DATA_END 5 #define EEPROM_DATA_END 5
//--------------------------------------------------------------------------------
// POWER SUPPLY
//--------------------------------------------------------------------------------
#ifndef ENABLE_VCC_REPORT
#define ENABLE_VCC_REPORT 1
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// BUTTON // BUTTON
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------


+ 20
- 11
code/espurna/config/sensors.h View File

@ -1,12 +1,3 @@
//--------------------------------------------------------------------------------
// Internal popwer montior
// Enable support by passing ENABLE_VCC_REPORT=1 build flag
//--------------------------------------------------------------------------------
#if (MQTT_REPORTS | MQTT_VCC_REPORT)
ADC_MODE(ADC_VCC);
#endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// Custom RF module // Custom RF module
// Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/ // Check http://tinkerman.cat/adding-rf-to-a-non-rf-itead-sonoff/
@ -57,15 +48,19 @@
#define EMON_PROVIDER EMON_ANALOG_PROVIDER #define EMON_PROVIDER EMON_ANALOG_PROVIDER
#if EMON_PROVIDER == EMON_ANALOG_PROVIDER #if EMON_PROVIDER == EMON_ANALOG_PROVIDER
#define EMON_CURRENT_PIN 0
#define EMON_CURRENT_PIN 0
#define EMON_ADC_BITS 10 #define EMON_ADC_BITS 10
#define EMON_REFERENCE_VOLTAGE 1.0 #define EMON_REFERENCE_VOLTAGE 1.0
#define EMON_CURRENT_PRECISION 1 #define EMON_CURRENT_PRECISION 1
#define EMON_CURRENT_OFFSET 0.25 #define EMON_CURRENT_OFFSET 0.25
#if ENABLE_EMON
#undef ENABLE_ADC_VCC
#define ENABLE_ADC_VCC 0
#endif
#endif #endif
#if EMON_PROVIDER == EMON_ADC121_PROVIDER #if EMON_PROVIDER == EMON_ADC121_PROVIDER
#define EMON_ADC121_ADDRESS 0x50
#define EMON_ADC121_ADDRESS 0x50
#define EMON_ADC_BITS 12 #define EMON_ADC_BITS 12
#define EMON_REFERENCE_VOLTAGE 3.3 #define EMON_REFERENCE_VOLTAGE 3.3
#define EMON_CURRENT_PRECISION 2 #define EMON_CURRENT_PRECISION 2
@ -104,3 +99,17 @@
#define POW_ENERGY_TOPIC "/energy" #define POW_ENERGY_TOPIC "/energy"
#define POW_UPDATE_INTERVAL 5000 #define POW_UPDATE_INTERVAL 5000
#define POW_REPORT_EVERY 12 #define POW_REPORT_EVERY 12
//--------------------------------------------------------------------------------
// Internal power montior
// Enable support by passing ENABLE_ADC_VCC=1 build flag
// Do not enable this if using the analog GPIO for any other thing
//--------------------------------------------------------------------------------
#ifndef ENABLE_ADC_VCC
#define ENABLE_ADC_VCC 1
#endif
#if ENABLE_ADC_VCC
ADC_MODE(ADC_VCC);
#endif

+ 3
- 1
code/espurna/emon.ino View File

@ -9,8 +9,10 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
#if ENABLE_EMON #if ENABLE_EMON
#include <EmonLiteESP.h> #include <EmonLiteESP.h>
#include "brzo_i2c.h"
#include <EEPROM.h> #include <EEPROM.h>
#if EMON_PROVIDER == EMON_ADC121_PROVIDER
#include "brzo_i2c.h"
#endif
// ADC121 Registers // ADC121 Registers
#define ADC121_REG_RESULT 0x00 #define ADC121_REG_RESULT 0x00


+ 2
- 2
code/espurna/espurna.ino View File

@ -55,7 +55,7 @@ void hardwareLoop() {
DEBUG_MSG("[MAIN] Time: %s\n", (char *) NTP.getTimeDateString().c_str()); DEBUG_MSG("[MAIN] Time: %s\n", (char *) NTP.getTimeDateString().c_str());
DEBUG_MSG("[MAIN] Uptime: %ld seconds\n", uptime_seconds); DEBUG_MSG("[MAIN] Uptime: %ld seconds\n", uptime_seconds);
DEBUG_MSG("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap()); DEBUG_MSG("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap());
#if ENABLE_VCC_REPORT
#if ENABLE_ADC_VCC
DEBUG_MSG("[MAIN] Power: %d mV\n", ESP.getVcc()); DEBUG_MSG("[MAIN] Power: %d mV\n", ESP.getVcc());
#endif #endif
@ -72,7 +72,7 @@ void hardwareLoop() {
mqttSend(MQTT_FREEHEAP_TOPIC, String(ESP.getFreeHeap()).c_str()); mqttSend(MQTT_FREEHEAP_TOPIC, String(ESP.getFreeHeap()).c_str());
#endif #endif
#if (MQTT_REPORTS | MQTT_VCC_REPORT) #if (MQTT_REPORTS | MQTT_VCC_REPORT)
#if ENABLE_VCC_REPORT
#if ENABLE_ADC_VCC
mqttSend(MQTT_VCC_TOPIC, String(ESP.getVcc()).c_str()); mqttSend(MQTT_VCC_TOPIC, String(ESP.getVcc()).c_str());
#endif #endif
#endif #endif


Loading…
Cancel
Save