ESPproMon Integration


#11

@Tokn59 been working on your account and some of it was easier than I remember.

The API uses the following format including sample data:
https://emoncms.org/input/post?node=1&fulljson={"P1":896.19,"RP1":663.18,"E1":10233.48,"PF1":0.74,"V1":242.9,"C1":3.69,"T1":26.1}&apikey=xxxx

I deleted all the inputs and feeds from your account and if you enter that url in a web browser with your read-write API key it automatically populates the EmonCMS database with this:

You don’t need to use a browser as the app will do it for you but it’s useful to test it in a browser first as there are some edits required once the database has been populated.

I will continue editing the Inputs and setting up the feeds and then I will post further details.


#12

Set up a process list for each of the 7 inputs by clicking the spanner icon and this will create 7 feeds.


The area marked in red in the image is where you overwrite the default description with whatever you want to use e.g. Current , Temperature etc and they can be in any language as the app only uses the Key names.
Leave all process details as default i.e. 10s intervals (which are actually 15s in the app) and click add.
When all 7 log to feed processes are added it will look like this:

As shown in red in the image above it indicates that the names that we allocated for each feed are not shown in the description field but if you switch from inputs to feeds (by selecting the spanner at the top right of the screen) you will see this image.

I have made all the feeds publicly accessible by clicking on the globe image against each feed. if you want them to be private just click the globe again (default is private but I like mine to be available to the public).
Now let’s go back to the 7 inputs as we have a few mods to do including adding the descriptions as they are currently only shown in the feeds page. Actually adding the descriptions is a little difficult in the input screen as it keeps refreshing the page at 10s intervals so you have to be quick when typing each description. The description field is accessed by clicking the pen icon against each input. You should now have something like this.

The only other thing left to do in this section is to get the Real Power to keep a sum of the total energy used. The Peacefair Pzem actually already has this data and its input E1 Energy WH. Our app is not just for the Pzem though so we also create a cumulative energy used to date for use by the EmonCMS database. Select the Real Power input and click the spanner at the end of the row.

Select the Power to Kwh process from the drop down list, over type Real Power with KWH and leave all the other settings as default and click add.
Few more details to follow in the next post.


#13

What we have done so far for EmonCMS might look like a lot of work with all the screenshots but once you know what you are doing it only takes a few minutes to get to this stage.

You will now have 7 inputs and 8 feeds as the real power input generates 2 feeds (real power now and cumulative real power). The cumulative real power can be different to the cumulative data from the Pzem as it’s normal to reset the cumulative on the Pzem when you receive each of your energy bills whereas the EmonCMS record will just keep rolling on.

@Tokn59 I have added your API key to your account on our cloud server to save you having to enter it via the app but also for me to check all is working OK.
You should recognise the data below as your live feed as it is now.


In theory the data should never be more than about 15s old but sometimes the EmonCMS server does get a backlog of data to process but it normally catches up over time.

You can add the EmonCMS app to your smartphone now and login with the credentials you gave me to see your data. I use the app on Android but I have checked and it’s also available for iOS.

I’m going to leave it there for now but there are 2 things left to cover.

  1. The process of requesting a weekly summary of your energy usage.

  2. Creating the EmonCMS dashboard with interactive charts and other widgets.

I’m going to let users create their own dashboards but you can see ours online and covered earlier in this thread to get an idea of what it possible.

Will document 1. above as soon as possible.

If anyone has any questions regarding EmonCMS please ask away.


#14

@Tokn59 your public dashboard is set up at https://emoncms.org/dashboard/view&id=47845

I have only added a gauge to show Amps and will leave it to you to add other widgets to the dashboard.

The weekly email report is accessed by clicking Extras and then Email Reports towards the top right.
As you will see in the screenshot below you can disable it at anytime. I have added your live address and you should have received a test report.

The emails are sent out by EmonCMS every Monday morning.


#15

Yes ! I did receive the email ! Great ! Thank you so much ! Will have a good look at everything ASAP and let you know !

Big thanks !!!


#16

@Tokn59 sent you a message about setting your local timezone in the app and added it to our quick start guide at Smart Meter Quick Start Guide

I looked at your dashboard and I see the text of “26.9 Kwh today” but I’m thinking this is the cumulative KWH for the Pzem not today’s usage.


#17

As some of you will be aware Open Energy Monitor (OEM) in Wales are going to start charging for data stored on their EmonCMS.org server from 1st July 2018.

There is a thread on their Community site which provides details of how the fees will be charged including rebates for anyone that has bought hardware from them in recent years.

The cost is very reasonable at £1 per feed per year. I am using 8 feeds so £8 per year wouldn’t be a problem for me. However in some parts of the world, and where users have lots of Pzem’s wired up the cost could mount up.

OEM are quite happy for individuals to use EmonCMS server on a local machine. This will require a firmware modification which we have started working on.

Meanwhile here are a couple of guides on setting up a local EmonCMS server on a $10 Raspberry Pi and copying the data across from the EmonCMS.org server.

I was originally have a problem backing up the remote server but as per this post I have it running OK now.

Even if you don’t plan to run a local EmonCMS server it might be worth at least backing up your EmonCMS.org data from time to time.

I will post here if I get the firmware mods to update my local EmonCMS server.


#18

One of my Pzem’s is now updating my local EmonCMS server on the Raspberry Pi W.

Once we have completed the testing we will look to do an automatic OTA update of the firmware.

In the meantime if you restart the app (Android or iOS) you should notice that the parameter settings in the TARIFF page has a few minor amendments. Parameter 37 is for you to enter the URL of your local server.

The URL needs to exclude the initial h (of https://) and will normally end as /emoncms/

Once you have set the URL you need to enter your WRITE API key with parameter 17. To distinguish between a local EmonCMS server and EmonCMS.org the key has to be entered in a particular way.

Local server: key=the32digitcode
EmonCMS.org: the32digitcode

The ESPproMon system should then start updating your local server.

If anyone wants to test the new firmware before it is officially released please let me know.


#19

I would like to test it please. :slight_smile:
I tried it so long but when I select option “37 Local EmonCMS URL”, it does not ask me in the terminal to add it and it did not confirm that I entered anything. Thank you for all your hard work on this Paul. You are doing a great job!


#20

We have now uploaded the new firmware to the server. As long as your ESP8266 is powered up at midnight it should automatically upgrade the firmware to include the local EmonCMS server functionality.

If you haven’t restarted the app in the last 24 hours you should do that now.

If you want to force the firmware update before midnight follow these steps:

  1. On the DATA page check that it shows NEXT VERSION as V00223.
    2.On the TARIFF page select parameter 24 Check Firmware

If your ESP8266 accepts the request it will display a message in the green terminal window that begins “System will reboot and update …”. If you don’t see this message keep requesting parameter 24 until you do.

Once the firmware has updated it will show NEXT VERSION has V00224 in the DATA page.


#21

You need to do the firmware update first as per the post before this one.


#22

Great Stuff!!! Its working great Paul!. I tested it with 2 methods incl: (And both is working)

  1. I used my dataplicity link which “ttps://elmier-vulture-0000.dataplicity.io/emoncms/” (0000 replaced by my 4 numbers)
  2. I used my EmonCMS local IP Address which is “ttp://192.168.0.74/emoncms/”

I had a slight problem where, when I select option “37 Local EmonCMS URL” my Wemos D1 Mini would reboot. It happened a few times. After I saw it logging to my local server I wanted to change my node number so when I selected option “18 Set EmonCMS node number” it rebooted again.

This was my first Wemos that I flashed and MAY have done it incorrectly, I will reflash it the correct way and will let you know in a hour or two. :slight_smile:

Thank you again Paul.


#23

I am a little surprised that the local IP address works because my understanding is that the Webhook can only access external URL’s. Blynk has previously said that is how their widget works.

I have checked the firmware and I can confirm that parameter 18 relating to node number is not currently coded.

This is the code for parameter 18 i.e. it does nothing:

case 18: // change node number for EmonCMS.org (TODO code this up)
  {

  }
  break;

Nobody has really needed this so even though the menu option appears in the app it doesn’t do anything.

Regarding parameter 37 (server URL) and also for me several other parameters like 24 check firmware I have also noticed that it is sometimes rebooting the ESP8266 rather than accepting the instruction.

The way the parameters are coded is that most of them expect a number to be entered but a few expect a text string. The firmware handles numbers and string differently but I can’t understand why it sometimes crashes the ESP8266 and sometimes it doesn’t.

For now I am going to work on the basis that the coding is OK becuase if it wasn’t it would never work. This suggests either the ESP8266 or the network is busy processing something else when the parameter is received.

It is quite annoying as it took me about 40 attempts to update the firmware for a couple of systems by selecting parameter 24 a few days ago. I will continue to monitor this.


#24

I have made a few minor adjustments to the firmware such as when you select parameter 18 the terminal widget should respond with “Node number is not currently supported”.

Similarly parameters 38, 39 and 40 should return “Parameter not coded yet”.

Selecting parameter 24 should update the firmware to show NEXT VERSION V00225 if you don’t want to wait for the automatic update at midnight tonight.

I checked the EmonCMS updating in demo mode and if the api key has been set it will send data to the server. So remove the key by entering a single character for the key if you don’t want to see demo data in EmonCMS, then re-enter the correct key when demo mode has been disabled.

The EmonCMS server URL does not need to be removed to disable server updating, just the key.

From some preliminary tests it appears that selecting the parameters is more successful if you put the app into demo mode, but remember to remove the api key first if you don’t want to see demo data in the EmonCMS system.


#25

BEFORE you start using the local EmonCMS server on your Rapsberry Pi there are 3 extra modules that you should install after setting up the server.

See the Modules section in the following page.

You should add Graph, Dashboard and App modules.


#26

We have uploaded a new version of the firmware which allows you to set the node number for EmonCMS. If you only have one device you don’t need to set a node number as it will default to node 1.
Below is a screenshot of one device which we varied the node number from 1 to 4.

If you set a node number it will be shown at the bottom of the TARIFF page.

The facility is currently only available for local EmonCMS servers. If you wanted to use it with EmonCMS.org it should work if you set the “local” URL as “ttps://emoncms.org/”. You would also need to set the write API key as key=32characters (replacing 32 characters with your actual key).


#27

Great stuff Paul! I tested and its working. Thank you very much. :slight_smile:

It did not work at first then I added my Dataplicity link and it worked. Then when I added the local IP again it worked.


#28

I will have to test this when I have time as I don’t think local IP’s are accepted by the system.


#29

I am not able to upgrade the firmware to V00225. I tried using Parameter 24, but it did not work.


#30

@Eleandro does the app show the prompt that it is checking the server for the new firmware or is it failing to notice that you have selected parameter 24?