Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff POW - Measurement at Off state #1420

Closed
Kniri opened this issue Dec 23, 2017 · 6 comments
Closed

Sonoff POW - Measurement at Off state #1420

Kniri opened this issue Dec 23, 2017 · 6 comments
Labels
good tip Type - Very useful information

Comments

@Kniri
Copy link

Kniri commented Dec 23, 2017

A standard Sonoff POW is unable to measure the electrical power, when the relay is Off. If the measurement would work independent of the relay state, the Sonoff POW could be used as a simple master/slave switch, for example.

I would like to share my modification of a Sonoff POW. The objective was the ability to measure the power independent of the relay state. Fortunately the Sonoff got 2 electrical connectors which are not used by the Sonoff. They are marked with the letter „E“ and are intended to connect the protected earth of input and output. The Sonoff doesn’t use protective earth internally, so the connection could be made outside of the Sonoff. The “E“ connectors could be used for different purposes. I have used that connectors to lead the other relay contact out of the device (see the black wire on the left side of the photo). This connection makes power measurement possible, independent of the relay’s state.

For good documentation I’ve scratched off the black colour of the letter „E“ and modified it to „L“. Additionally I’ve labeled the output connectors “Switched“ and “Non Switched“ with a little sticker. That’s all on the hardware side.

The software needs a little modification, because the power will not be shown if the relay is in the OFF state.

I made two changes in the module “xsns_03_hlw8012.ino“

At Line 238: if (hlw_cf_pulse_length /* && (power &1) */ && !hlw_load_off) {

At Line 243: if (hlw_cf1_voltage_pulse_length /* && (power &1) */) {

@theo: It would be great, if you could take this into consideration in future versions of your code. Maybe you have an idea to make it configurable.

img_1434 png

@arendst
Copy link
Owner

arendst commented Dec 23, 2017

I thought that the always on option would provide almost the same functionality...

@Kniri
Copy link
Author

Kniri commented Dec 23, 2017

In my opinion “Always On“ is not an alternative solution. Let me show you, how I am using the modified Sonoff. In an environment where real switches should work independent from home automation, this solution can help.

Imagine, you have a corridor with 3 regular switches, to turn on/off the light from different positions. Without home automation you have to use an impuls switch (ELTAKO).

It looks like this:
eltako-schematic

If you want to add home automation, but won’t loose the given functionality, the modified Sonoff POW is a good choice.

Then it looks like this:
eltako-sonoff

With this solution you have the same functionality, even if your home automation system is not working.
If your home automation system is working fine, you are able to determine if the light is on or off. Additionally the system can switch the light, (e.g. with PulseTime 5 and Power 1 command).

This is only 1 application. You can use the modified Sonoff POW also as a Master/Slave switch. This means that you can switch the relay depending on the amount of payload (for example: switch on a vent if power is greater than 100 Watt). Or for power savings (for example: switch off the Active Subwoofer if power is less than 20 Watt).

The advantage of a modified Sonoff POW is that the switching capability remains the same.

@arendst
Copy link
Owner

arendst commented Dec 23, 2017

Convinced.

@majekw
Copy link

majekw commented Jan 10, 2018

My use cases:

  1. I have a bench with lot of things connected to mains. Also laptop with docking station and 5.1 speaker set. Speakers draw constantly about 10W.
    My goal:
  • measure power utilization of all these devices alltogether
  • switch on speakers only when laptop is docked and active
  • switch off speakers when laptop is put to sleep or undocked
  • everything else should be powered all the time.
  1. I want to measure my home server power draw, but I don't want ANY interruption in ANY case (firmware update, some error etc.), so simplest thing is to bypass relay. Now I have reliable power source and I can use relay for switching on/off other things like additional fan in hot days:-)

With this hack (thanks @Kniri) in every case I can do it with only one POW :-)

arendst added a commit that referenced this issue Feb 4, 2018
5.11.1i
* Fix some Energy Monitoring related issues
* Add command SetOption21 1 to allow Energy Monitoring when power is off
on Sonoff Pow and Sonoff S31 (#1420)
@arendst
Copy link
Owner

arendst commented Feb 4, 2018

There will be an option SetOption21 1 to always allow energy monitoring in version 5.11.1i

arendst added a commit that referenced this issue Feb 9, 2018
5.12.0 20180209
* Change library PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to
1000 for Home Assistant  support
* Change relation of define MESSZ being dependent on PubSubClient.h
define MQTT_MAX_PACKET_SIZE
* Change command color parameter input checks to less strict for Home
Assistant support
* Change command Ina219Mode into command Sensor13
* Change commands HlwPCal, HlwUCal and HlwICal to PowerCal, VoltageCal
and CurrentCal to be used for both Pow and S31 calibration
* Change commands HlwPSet, HlwUSet and HlwISet to PowerSet, VoltageSet
and CurrentSet to be used for both Pow and S31 calibration
* Change uptime from hour to second resulting in a display of
123T13:45:21 where 123 is days
* Change module name Wemos D1 mini into Generic (#1220)
* Change HTML from width=100% to style=width:100% supporting HTML5
(#1358)
* Change OSWATCH_RESET_TIME (Blocked loop) from 30 to 120 seconds to
allow slow networks (#1556)
* Change WIFI_MANAGER_SEC into WIFI_CONFIG_SEC (#1616)
* Change function pointers code to save code space and memory (#1683)
* Change webserver argument processing gaining 5k code space (#1705)
* Change weblog memory usage (#1730, #1793, #1819)
* Update TasmotaSerial library to 1.1.0
* Update language files Italian (#1594), Dutch (#1723) and Spanish
(#1722)
* Fix Non-English JSON temperature unit attachement
* Fix Arilux RF induced exception by moving interrupt handler to iram on
non ESP8266/Arduino lib v2.3.0
* Fix truncated command names and wrong response for DomoticzSwitchIdx
(#1571)
* Fix %-sign issue as printf escape character in Humidity and Sonoff SC
(#1579)
* Fix DS18B20 temperature JSON decimal dot (#1561)
* Fix Energy JSON message (#1621)
* Fix IRSend parameter translation (#1636)
* Fix TSL2561 device detection (#1644, #1825)
* Fix BME680 teleperiod resistance measuring (#1647)
* Fix Energy Monitoring Energy Today and Energy Total reading after
restart (#1648)
* Fix IRReceive Data value (#1663)
* Fix Energy Monitoring Energy Period roll-over (#1688)
* Fix compiler warnings (#1774)
* Fix command PWM response if no PWM channel is configured (#1783)
* Add locale Decimal Separator to Web sensor page
* Add ColorTemperature to light status message
* Add command PowerOnState option 5 which inverts PulseTime and allows
for delayed always on after power on
* Add OtaMagic two step Web server OTA upgrade using filename-minimal
image if OTA free space is too small
* Add support for PMS5003 and PMS7003 particle concentration sensor
* Add command SetOption21 1 to allow Energy Monitoring when power is off
on Sonoff Pow and Sonoff S31 (#1420)
* Add Chinese language file (#1551)
* Add French language file (#1561)
* Add Spanish language file (#1589)
* Add HTTP Allow Cross Origin removed from ESP8266/Arduino lib v2.4.0
(#1572)
* Add Home Assistant MQTT Discovery for switch and light to be enabled
by command SetOption19 1 (#1534) or define
HOME_ASSISTANT_DISCOVERY_ENABLE in user_config.h (#1685)
* Add command State to retrieve device state information (same data as
teleperiod state and status 11 in slightly different JSON format)
* Add optional login to Webserver AP mode (#1587, #1635)
* Add command Sensor15 2 to start MHZ19(B) Zero Point Calibration
(#1643)
* Add support for Sonoff S31 Smart Socket with Power Consumption
Detection (#1626)
* Add command SetOption20 to allow update of Dimmer/Color/Ct without
turning power on (#1719, #1741)
* Add NTP sync time slot based on chip id (#1773)
* Add cursor pointer to web button (#1836)
@stale
Copy link

stale bot commented Jun 4, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Jun 4, 2018
@ascillato ascillato added good tip Type - Very useful information and removed stale Action - Issue left behind - Used by the BOT to call for attention labels Jun 4, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.11.1i
* Fix some Energy Monitoring related issues
* Add command SetOption21 1 to allow Energy Monitoring when power is off
on Sonoff Pow and Sonoff S31 (arendst#1420)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good tip Type - Very useful information
Projects
None yet
Development

No branches or pull requests

4 participants