Energy (AC) - CSE7766

This plugin is specifically made for Sonoff devices Sonoff S31, Sonoff Pow R2 and Sonoff POW/Dual R3 models.

Plugin details

Type: Energy (AC)

Name: CSE7766

Status ESP32: ENERGY

Status ESP8266: ENERGY

GitHub: P077_CSE7766.ino

Maintainer: TD-er

Used libraries: ESPEasySerial

Warning

This device is intended to be connected to mains power (110V/220V). Safety is of utmost importance, so the unit should not be connected to a computer if it also connected to the mains power, and it should be sufficiently isolated to prevent touching parts that can be connected to mains power!

See Safety

Supported hardware

Sonoff S31, Sonoff Pow R2, Sonoff POW R3xx(D), Sonoff Dual R3

Sonoff POWR3xx

Introduction

To measure the power used by an electric device, the Sonoff POW units, running either on an ESP8266 or ESP32, can be used. The installed power-sensor is the CSE7766, that makes the measured data available via a serial output at 4800 baud.

This plugin can read the measured data, and apply a correction value to show calibrated values for Voltage, Power and Current, and it will also make available a pulse count.

Configuration

../_images/P077_DeviceConfiguration.png
  • Name A unique name should be entered here.

  • Enabled The device can be disabled or enabled. When not enabled the device should not use any resources.

Sensor

See: Serial Helper configuration

Device Settings

  • U Ref: The calibration value for the Voltage measurement. When set to 0, a default value of 1950 will be used, see Calibration, below.

  • I Ref: The calibration value for the Current measurement. When set to 0, a default value of 3500 will be used, see Calibration, below.

  • P Ref: The calibration value for the Power measurement. When set to 0, a default value of 12530 will be used, see Calibration, below.

Data Acquisition

This group of settings are standard available configuration items.

  • Single event with all values: When this setting is enabled, all available values will be sent in a single event <TaskName>#All, with all values in order as arguments to the event.

  • Show derived values: When checked, the Devices overview page, and the /json endpoint (used for updating the Devices overview page) will include any Derived values as defined. See the TaskValueSetDerived and TaskValueSetPresentation commands.

  • Event & Log derived values: When checked, the Derived values will be generated as Events, to be handled in Rules, and sent to logging devices like the Syslog server and/or SD-card logging.

(The derived values options are only available if String variables feature is included in the build.)


  • Send to Controller: Select the Controller(s) to send the Values to, either on a TaskRun command applied to the task, or on an Interval time action.

Send to Controller is only visible when one or more Controllers are configured.

Depending on the controller capabilities, some configuration settings may be shown:

../_images/Task_config_page_Controllers_section.png

All configured Controllers are shown here, including the enabled or disabled state (multiple Controllers can be enabled, only a single MQTT Controller can be enabled at one time!).

For each controller the user can select wether the data should be sent on each Interval (or explicit TaskRun).

For the Domoticz controllers the value index (IDX) has to be configured.

For some controllers, like Home Assistant/openHAB, there are extra options available.

  • Group: This represents the group id to combine all values from multiple tasks into a single grouped-device during MQTT AutoDiscovery. Groups, by design, can span multiple ESPEasy devices, if desired, as long as the Task/Valuename combinations are unique. If a group should only combine Tasks from a single ESPEasy unit, the group id should be unique across multiple ESPEasy units. The group description, default Group <n>, can be adjusted in Home Assistant. If the Group value matches the current Unit nr, the Unit name, %sysname%, is used instead of Group <nr>.

  • Retained: For MQTT Controllers, this setting can be enabled to send the values for the current task with the Retain flag set. The Publish Retain flag in the Controller settings will override this by sending all task values with Retain flag enabled.

  • Send derived: This checkbox determines if any configured Derived values should also be sent to the controller (and included in the AutoDiscovery if that’s available and enabled).

  • Resend MQTT Discovery: When checked, will start a resend of the MQTT Discovery process for this task after a random delay, when Submit is clicked, so any changed settings will be updated in the MQTT broker. This setting is only available if the controller is enabled, the Auto Discovery feature is available and enabled for the controller. This setting is not stored.

Other controllers, like f.e. FHEM HTTP, do not support additional settings besides the checkbox to enable sending the data.


  • Interval By default, Interval will be set to 0 sec. as this is optional for this plugin.

Values

The measured values are available in Voltage, Power, Current and Pulses. A formula can be set to recalculate. The number of decimals is by default set to 2, and can be set to 0 for Pulses, as no decimals are provided from the measurement. When enabling the Stats checkbox for a value, statistics will be gathered and a graph of the last 16 (ESP8266) or 64 (ESP32) measurements will be shown.

Calibration

Easiest way to calibrate the plugin is to connect a known (resistive) load to the unit, measure the actual voltage, calculate the current from the power and voltage (current = power/voltage) and use the csecalibrate,<voltage>,<current>,<power> command (the Command input on the Tools page in the web UI will doen fine for that) to set the calibration values.

Commands available

Command

Extra information

csecalibrate,[<Voltage>],[<Current>][,<Power>]

Examples:

csecalibrate,229 to set the current reported voltage to 229V AC

csecalibrate,,0.1 To set the calibration to report 100 mA as actual current.

Will set the used calibration reference factors to some known current value. For example, if the device using this sensor is plugged into mains power, it may report 200 Volt AC, while it actually is 229V. So the value given to this command should then be 229, since that’s what is supposed to be read.

The last two parameters are optional, but their position determines what unit it represents. If the setting for current has to be updated, at least 2 parameters must be given of which the first must then be set to 0.

csereset

Will reset the calibration values to the default values, causing auto-calibration.

cseclearpulses

(Added: 2024-01-16) Will reset the CF-pulse counter. N.B. this also clears the kWh counter as it is derived from the CF-pulse counter.

Change log

Changed in version 2.0:

changed 2023-02-11 Use ESPEasySerial to allow more flexible Serial/GPIO configuration and support new Sonoff POW models (ESP32)

added Major overhaul for 2.0 release.

Added in version 1.0:

added Initial release version.