I have a very uncommon device SmartDGM PP-W162 equipped with BL0937 sensor. I've previously flashed it with normal_ESP8266_1M - completely normal build. Shortly after I noticed my device contains energy meter, I wanted to try it out. Unfortunately, all energy builds are too big to fit in 1M flash, so I compiled my own, custom version containing basically only P076 plugin and OTA Updates by defining PLUGIN_BUILD_MINIMAL_OTA in my Custom.h (I really want the OTA functionality since this device's construction makes it very hard to connect serial ports, and when they're connected it is impossible to connect device to high voltage because circuit lacks isolation. I'd have to do soldering every time I wanted to flash firmware).
From Tasmota users, I know this device has following pin configuration:
gpio4 - CF
gpio5 - CF1
gpio12 - SEL
After creating sensor device in Devices tab, it indeed downloaded calibration values, and comparing to what other people saw on their devices running Tasmota, those seem to be correct.
However, I'm unable to get a reading on Voltage, Current, Power and PowerFactor values.
No matter how I set CF1 and CF interrupt edge, all values stay set to 0.00.
Only when I switch my relay off to disable my 80W bulb, Power and PowerFactor momentarily change to some junk values.
Here's my Custom.h file. Do I need to include anything else to make it work? Did I compile something wrong?
Config.h
```CPP
#ifndef ESPEASY_CUSTOM_H
#define ESPEASY_CUSTOM_H
#include
/*
To modify the stock configuration without changing the EspEasy.ino file :
1) rename this file to "Custom.h" (It is ignored by Git)
2) define your own settings below
3) define USE_CUSTOM_H as a build flags. ie : export PLATFORMIO_BUILD_FLAGS="'-DUSE_CUSTOM_H'"
*/
/*
#######################################################################################################
Your Own Default Settings
#######################################################################################################
You can basically ovveride ALL macro defined in ESPEasy.ino.
Don't forget to first #undef each existing #define that you add below.
But since this Custom.h is included before other defines are made, you don't have to undef a lot of defines.
Here are some examples:
*/
#ifdef BUILD_GIT
# undef BUILD_GIT
#endif // ifdef BUILD_GIT
#define BUILD_GIT "My Build: " __DATE__ " " __TIME__
#define DEFAULT_NAME "MyEspEasyDevice" // Enter your device friendly name
#define UNIT 0 // Unit Number
#define DEFAULT_DELAY 60 // Sleep Delay in seconds
// --- Wifi AP Mode (when your Wifi Network is not reachable) ----------------------------------------
#define DEFAULT_AP_IP 192, 168, 4, 1 // Enter IP address (comma separated) for AP (config) mode
#define DEFAULT_AP_SUBNET 255, 255, 255, 0 // Enter IP address (comma separated) for AP (config) mode
#define DEFAULT_AP_KEY "configesp" // Enter network WPA key for AP (config) mode
// --- Wifi Client Mode -----------------------------------------------------------------------------
#define DEFAULT_SSID "xxx" // Enter your network SSID
#define DEFAULT_KEY "xxx" // Enter your network WPA key
#define DEFAULT_SSID2 "" // Enter your fallback network SSID
#define DEFAULT_KEY2 "" // Enter your fallback network WPA key
#define DEFAULT_WIFI_INCLUDE_HIDDEN_SSID false // Allow to connect to hidden SSID APs
#define DEFAULT_USE_STATIC_IP false // (true|false) enabled or disabled static IP
#define DEFAULT_IP "192.168.0.50" // Enter your IP address
#define DEFAULT_DNS "192.168.0.1" // Enter your DNS
#define DEFAULT_GW "192.168.0.1" // Enter your Gateway
#define DEFAULT_SUBNET "255.255.255.0" // Enter your Subnet
#define DEFAULT_IPRANGE_LOW "0.0.0.0" // Allowed IP range to access webserver
#define DEFAULT_IPRANGE_HIGH "255.255.255.255" // Allowed IP range to access webserver
#define DEFAULT_IP_BLOCK_LEVEL 1 // 0: ALL_ALLOWED 1: LOCAL_SUBNET_ALLOWED 2:
// ONLY_IP_RANGE_ALLOWED
#define DEFAULT_ADMIN_USERNAME "admin"
#define DEFAULT_ADMIN_PASS ""
#define DEFAULT_WIFI_CONNECTION_TIMEOUT 10000 // minimum timeout in ms for WiFi to be connected.
#define DEFAULT_WIFI_FORCE_BG_MODE false // when set, only allow to connect in 802.11B or G mode (not N)
#define DEFAULT_WIFI_RESTART_WIFI_CONN_LOST false // Perform wifi off and on when connection was lost.
#define DEFAULT_ECO_MODE false // When set, make idle calls between executing tasks.
#define DEFAULT_WIFI_NONE_SLEEP false // When set, the wifi will be set to no longer sleep (more power
// used and need reboot to reset mode)
#define DEFAULT_GRATUITOUS_ARP false // When set, the node will send periodical gratuitous ARP
// packets to announce itself.
#define DEFAULT_TOLERANT_LAST_ARG_PARSE false // When set, the last argument of some commands will be parsed to the end of the line
// See: https://github.com/letscontrolit/ESPEasy/issues/2724
#define DEFAULT_SEND_TO_HTTP_ACK false // Wait for ack with SendToHttp command.
#define DEFAULT_AP_DONT_FORCE_SETUP false // Allow optional usage of Sensor without WIFI avaiable // When set you can use the Sensor in AP-Mode without beeing forced to /setup
#define DEFAULT_DONT_ALLOW_START_AP false // Usually the AP will be started when no WiFi is defined, or the defined one cannot be found. This flag may prevent it.
// --- Default Controller ------------------------------------------------------------------------------
#define DEFAULT_CONTROLLER false // true or false enabled or disabled, set 1st controller
// defaults
#define DEFAULT_CONTROLLER_ENABLED true // Enable default controller by default
#define DEFAULT_CONTROLLER_USER "" // Default controller user
#define DEFAULT_CONTROLLER_PASS "" // Default controller Password
// using a default template, you also need to set a DEFAULT PROTOCOL to a suitable MQTT protocol !
#define DEFAULT_PUB "sensors/espeasy/%sysname%/%tskname%/%valname%" // Enter your pub
#define DEFAULT_SUB "sensors/espeasy/%sysname%/#" // Enter your sub
#define DEFAULT_SERVER "192.168.0.8" // Enter your Server IP address
#define DEFAULT_SERVER_HOST "" // Server hostname
#define DEFAULT_SERVER_USEDNS false // true: Use hostname. false: use IP
#define DEFAULT_USE_EXTD_CONTROLLER_CREDENTIALS false // true: Allow longer user credentials for controllers
#define DEFAULT_PORT 8080 // Enter your Server port value
#define DEFAULT_PROTOCOL 0 // Protocol used for controller communications
// 0 = Stand-alone (no controller set)
// 1 = Domoticz HTTP
// 2 = Domoticz MQTT
// 3 = Nodo Telnet
// 4 = ThingSpeak
// 5 = Home Assistant (openHAB) MQTT
// 6 = PiDome MQTT
// 7 = EmonCMS
// 8 = Generic HTTP
// 9 = FHEM HTTP
#define DEFAULT_PIN_I2C_SDA 4
#define DEFAULT_PIN_I2C_SCL 5
#define DEFAULT_I2C_CLOCK_SPEED 400000 // Use 100 kHz if working with old I2C chips
#define USE_I2C_DEVICE_SCAN true
#define DEFAULT_SPI 0 //0=disabled 1=enabled and for ESP32 there is option 2 =HSPI
#define DEFAULT_PIN_STATUS_LED (-1)
#define DEFAULT_PIN_STATUS_LED_INVERSED true
#define DEFAULT_PIN_RESET_BUTTON (-1)
#define DEFAULT_USE_RULES true // (true|false) Enable Rules?
#define DEFAULT_RULES_OLDENGINE true
#define DEFAULT_MQTT_RETAIN false // (true|false) Retain MQTT messages?
#define DEFAULT_MQTT_DELAY 100 // Time in milliseconds to retain MQTT messages
#define DEFAULT_MQTT_LWT_TOPIC "" // Default lwt topic
#define DEFAULT_MQTT_LWT_CONNECT_MESSAGE "Connected" // Default lwt message
#define DEFAULT_MQTT_LWT_DISCONNECT_MESSAGE "Connection Lost" // Default lwt message
#define DEFAULT_MQTT_USE_UNITNAME_AS_CLIENTID 0
#define DEFAULT_USE_NTP false // (true|false) Use NTP Server
#define DEFAULT_NTP_HOST "" // NTP Server Hostname
#define DEFAULT_TIME_ZONE 0 // Time Offset (in minutes)
#define DEFAULT_USE_DST false // (true|false) Use Daily Time Saving
#define DEFAULT_LATITUDE 0.0f // Default Latitude
#define DEFAULT_LONGITUDE 0.0f // Default Longitude
#define DEFAULT_SYSLOG_IP "" // Syslog IP Address
#define DEFAULT_SYSLOG_LEVEL 0 // Syslog Log Level
#define DEFAULT_SERIAL_LOG_LEVEL LOG_LEVEL_INFO // Serial Log Level
#define DEFAULT_WEB_LOG_LEVEL LOG_LEVEL_INFO // Web Log Level
#define DEFAULT_SD_LOG_LEVEL 0 // SD Card Log Level
#define DEFAULT_USE_SD_LOG false // (true|false) Enable Logging to the SD card
#define DEFAULT_USE_SERIAL true // (true|false) Enable Logging to the Serial Port
#define DEFAULT_SERIAL_BAUD 115200 // Serial Port Baud Rate
#define DEFAULT_SYSLOG_FACILITY 0 // kern
#define DEFAULT_SYNC_UDP_PORT 0 // Used for ESPEasy p2p. (IANA registered port: 8266)
#define BUILD_NO_DEBUG
// Special SSID/key setup only to be used in custom builds.
// Deployment SSID will be used only when the configured SSIDs are not reachable and/or no credentials are set.
// This to make deployment of large number of nodes easier
#define CUSTOM_DEPLOYMENT_SSID "" // Enter SSID not shown in UI, to be used on custom builds to ease deployment
#define CUSTOM_DEPLOYMENT_KEY "" // Enter key not shown in UI, to be used on custom builds to ease deployment
#define CUSTOM_SUPPORT_SSID "" // Enter SSID not shown in UI, to be used on custom builds to ease support
#define CUSTOM_SUPPORT_KEY "" // Enter key not shown in UI, to be used on custom builds to ease support
// Emergency fallback SSID will only be attempted in the first 10 minutes after reboot.
// When found, the unit will connect to it and depending on the built in flag, it will either just connect to it, or clear set credentials.
// Use case: User connects to a public AP which does need to agree on an agreement page for the rules of conduct (e.g. open APs)
// This is seen as a valid connection, so the unit will not reconnect to another node and thus becomes inaccessible.
#define CUSTOM_EMERGENCY_FALLBACK_SSID "" // Enter SSID not shown in UI, to be used to regain access to the node
#define CUSTOM_EMERGENCY_FALLBACK_KEY "" // Enter key not shown in UI, to be used to regain access to the node
#define CUSTOM_EMERGENCY_FALLBACK_RESET_CREDENTIALS false
#define CUSTOM_EMERGENCY_FALLBACK_START_AP false
#define CUSTOM_EMERGENCY_FALLBACK_ALLOW_MINUTES_UPTIME 10
#define USES_SSDP
#define USE_EXT_RTC // Support for external RTC clock modules like PCF8563/PCF8523/DS3231/DS1307
#define PLUGIN_BUILD_MINIMAL_OTA
// #define USE_SETTINGS_ARCHIVE
// #define FEATURE_I2CMULTIPLEXER
// #define USE_TRIGONOMETRIC_FUNCTIONS_RULES
/*
#######################################################################################################
Defining web interface
#######################################################################################################
*/
#define MENU_INDEX_MAIN_VISIBLE true
/*
#define MENU_INDEX_CONFIG_VISIBLE false
#define MENU_INDEX_CONTROLLERS_VISIBLE false
#define MENU_INDEX_HARDWARE_VISIBLE false
#define MENU_INDEX_DEVICES_VISIBLE false
#define MENU_INDEX_RULES_VISIBLE false
#define MENU_INDEX_NOTIFICATIONS_VISIBLE false
#define MENU_INDEX_TOOLS_VISIBLE false
*/
#define MAIN_PAGE_SHOW_SYSINFO_BUTTON true
#define MAIN_PAGE_SHOW_WiFi_SETUP_BUTTON true
#define MAIN_PAGE_SHOW_BASIC_INFO_NOT_LOGGED_IN false
#define MAIN_PAGE_SHOW_NODE_LIST_BUILD true
#define MAIN_PAGE_SHOW_NODE_LIST_TYPE true
#define SETUP_PAGE_SHOW_CONFIG_BUTTON true
//#define WEBPAGE_TEMPLATE_HIDE_HELP_BUTTON
/*
#######################################################################################################
CSS / template
#######################################################################################################
*/
/*
#define WEBPAGE_TEMPLATE_DEFAULT_HEADER "
I have a very uncommon device SmartDGM PP-W162 equipped with BL0937 sensor. I've previously flashed it with
normal_ESP8266_1M
- completely normal build. Shortly after I noticed my device contains energy meter, I wanted to try it out. Unfortunately, allenergy
builds are too big to fit in 1M flash, so I compiled my own, custom version containing basically onlyP076
plugin and OTA Updates by definingPLUGIN_BUILD_MINIMAL_OTA
in my Custom.h (I really want the OTA functionality since this device's construction makes it very hard to connect serial ports, and when they're connected it is impossible to connect device to high voltage because circuit lacks isolation. I'd have to do soldering every time I wanted to flash firmware).From Tasmota users, I know this device has following pin configuration: gpio4 - CF gpio5 - CF1 gpio12 - SEL
After creating sensor device in Devices tab, it indeed downloaded calibration values, and comparing to what other people saw on their devices running Tasmota, those seem to be correct. However, I'm unable to get a reading on Voltage, Current, Power and PowerFactor values. No matter how I set CF1 and CF interrupt edge, all values stay set to
0.00
. Only when I switch my relay off to disable my 80W bulb, Power and PowerFactor momentarily change to some junk values.Here's my Custom.h file. Do I need to include anything else to make it work? Did I compile something wrong?
Config.h
```CPP #ifndef ESPEASY_CUSTOM_H #define ESPEASY_CUSTOM_H #includeESP Easy Mega: {{title}}
" #define WEBPAGE_TEMPLATE_DEFAULT_FOOTER "