Integrating SONOFF-POW into EmonCMS?

Just recently discovered ITEAD/SONOFF devices, basically income WIFI relay switches marketed as IOT. They have some basic ones that can do ON/OFF over Wifi.

However I have noticed they have a version which does real time power monitoring.

Anyone managed to connect the powering monitoring on this to EmonCMS as an additional feed?

I would like to add these inline to some of my devices (computers, servers, Amps, etc) to remotely kill power, but it also makes sense to monitor power if I can.

1 Like

I’ve been using several Sonoff S20 plugs in my home for a while now. Their really great.

I re-flashed the units with Sonoff-Tasmota firmware to give MQTT support, this works really well:

Looking at the wiki it look like Sonoff-Tasmota supports Sonoff-POW and reporting power value to MQTT:

Once the data is in MQTT it’s easy to log to Emoncms. Either post to emon/<node-name>/<feed-name MQTT topic and the data will appear in local emoncms (emonPi / emonBase) or just node-red to forward the data to Emoncms.

Node-red and MQTT are pre-installed and configured on all emonPi / emonPi. See MQTT user guide:

1 Like

After a few hours I found the final solution to the above question

1: configure tasmota to use emoncms mqtt server
2: use a rule, like: rule1 on energy#power do publish emon/sonoffpow/test %value% endon

This way you will get the power in emoncms in input section. Then you can modify it as you see fit


That is an excellent solution Every day a learning day.

I’d never thought of using a rule to do that. I process everything from Tasmota devices in Node-RED to get it into a format for emonCMS. This is the second thing I have seen done using rules recently - really need to investigate them more. Thanks.

Having spent several hours trying to get data from a tasmota-flashed POW R2 into my emonPI via Node-RED, i’m close to waving the white flag. I’m a newbie to MQTT and JSON and wondered if anyone might kind enough to point me in the right direction

As I hit a wall with @4est 's elegant rule solution I decided to try with a Node-RED exercise.

Per screenshot, I am getting good data from Tasmota every 30s via MQTT but not sure how to convert the JSON string in Node-Red into something the Pi can read? I am just getting NULL values in emonCMS currently. @borpin sounds like you have achieved this successfully and wondered what your Node-red config looked like if still available? Much obliged.

Null values in emonpi

Ok, so a few things to understand (teach a man to fish and all that).


In Node red, the base ‘object’ is msg and one element of that is the payload or msg.payload. You are likely to also have a msg.topic element as well (the topic the msg object came in on). If you just have msg.payload if the debug node, that is all you see - often I find it better to see the whole message.

Second tip, in the top right of the debug console, there is a copy value icon.


This copies the value at that level into the buffer. If you use you can format that JSON and more easily see what is going on.

Next, you do not need the JSON node as you can tell the MQTT node to output JSON in the first place


Now the data you are getting back is of the form msg.payload.ENERGY but emoncms, wants the data for the Inputs directly in the msg.payload

As a starter, put in a change node and set msg.payload to msg.payload.ENERGY

Each of the elements in the ENERGY object should now appear as Inputs.

I’d also use the option in Tasmota time 3 which returns the time as a unix integer (although emoncms will not use it, it only likes numbers)

Thanks so much @borpin, learnt a lot there. I’ll have a go at implementing this over the next day or so and report back. Much appreciated.

Thanks again, i followed your instructions @borpin and they worked a treat. Every day a learning day for sure.

1 Like