Hi all,
I would like to announce a project I have been working on for some months.
The basic idea is to implement a low cost Smart Energy Monitor based on the RaspberryPi. In short, it is a simplified (light) version of a combination of the emonTX, emonGLCD and emonBase modules. Everything runs on the RPi, no custom hardware required. All you need is an energy meter with pulse (SO) output and (optionally) an LCD display.
The device software I developed interfaces with the EmonCMS server where the data processing can be done just like with any other OpenEnergyMonitor project. The software is written in the good old C language.
These are the main features:
- Instant power measurement using energy meter pulses
- Daily and monthly energy calculation
- Filtering of short glitches on the pulse counting GPIO line
- Display of measurements on local LCD display (via integrated lcdproc client)
- Transmission of measurements to EmonCMS (via WebAPI)
- Easy customization of parameters via configuration file
The source code and documenations is available on GitHub:
https://github.com/ondrej1024/emond
This system has been running at my home for some time now and it is working great for me.
If you are interested, have any feedback, comments or suggestions, or want to contribute, please let me know. I will be happy to share my experience.
Ondrej
Re: Project announcement: Energy monitor light
Nice work Ondrej! Thanks for sharing! The github page documentation is very clean too.
Re: Project announcement: Energy monitor light
Glad you like the project. The idea behind this is to create a software that can run on any cheap Single Board Computer and that provides the input data for EmonCMS. I am using the RaspberryPi but other small Linux boards with GPIO support should also work fine.
I am aiming at providing the same functionality that the EmonTX module provides, except the current measurements which would require additional hardware components. Everything needs to be handled in the software to keep the setup simple.
I just pushed a new version with some improvements to GitHub and published a somewhat nicer home page:
http://ondrej1024.github.io/emond/
Ondrej
[4 further identical copies of this post deleted - Moderator (RW) ]
Re: Project announcement: Energy monitor light
Hi all
please find a new version of the smart energy monitor software for the RaspberryPi on the GitHub page:
http://ondrej1024.github.io/emond/
Latest changes:
- Improvement of false pulse detection
- Periodic saving of daily and monthly energy counters to persistent storage
- Loading of saved energy counters at startup (resume counting)
If you find this useful or would like to contribute, please let me know.
Cheers, Ondrej
Re: Project announcement: Energy monitor light
Hello Ondrej,
I set up your program on my Rpi. Install and all went well I just have some questions;
1. Is it possible to change the data feed to log to my local emoncms? If so how? Might be nice if this could be done in the config.
2. Is there a way to test if pulses are coming in to the system okay? Nothing shows up in the media/data/emon.data
3. I am using DRS155D (kwh meter) pulse connected to Rpi io with following config settings for Emond.
pulse_input_pin = 25
wh_per_pulse = 1
pulse_length = 90
max_power = 1000
Can you tell me if this is correct?
Thanks for the great program.
Re: Project announcement: Energy monitor light
Hi herbie4,
I will try to answer your questions.
1. The data api url is currently not configurable but you can modify the source code in webapi.c
/* EmonCMS API definitions */
#define EMONCMS_API_BASE_URI "http://emoncms.org" // change this to point to you local EmonCMS
#define EMONCMS_API_INPUT_URI EMONCMS_API_BASE_URI"/input/post.json"
2. emond logs some info and error messages to /var/log/syslog, so you should check this first to see if there are any messages related to the pulse detection. For some more verbose logging (e.g. each detected pulse) you can enable debug mode in emond.c:
#define DEBUG 0 // change to 1 for debug mode
3. Your settings look correct. Please check your connection to the energy meter. SO+ should be connected to the GPIO pin 25 and SO- to GND on the RPi.
Hope this helps,
Ondrej
Re: Project announcement: Energy monitor light
Thank you Ondrej.
- I had to change the input pin. I have to use the BCM numbers, so should connect puls positive to pin number 22 on rpi as I set 25 in the config. Now I can see data accumulate in /media/data/emond.dat
- Changed the EmonCMS API definitions and now data is coming in to local emoncms.
- Had to change the pulse_time to auto detect as there where a lot of 'Detected invalid pulse' in the /var/log/daemon.log. Most pulses are 67ms should I set this as value?
Thank you again for the info. I'll keep you up to date about the progress...
Re: Project announcement: Energy monitor light
Hi Herbie,
it's great to hear that you got this working. It's always nice to have some feedback and know how this software is working for other. Please see some comments below:
On 04/30/2015 08:56 AM, herbie4 wrote:
Thank you Ondrej,
- I had to change the input pin. I have to use the BCM numbers, so should connect puls positive to pin number 22 on rpi as I set 25 in the config. Now I can see data accumulate in /media/data/emond.dat
Yes, the pin number you specify in the config file is actually the Kernel Id and not the pin number on the header. Maybe I should make this clearer.
- Changed the EmonCMS API definitions and now data is coming in to local emoncms.
Note that emond will send the data every time it detects a pulse, which could be quite often if your energy meter generates a pulse every Wh. My energy meter generates a pulse only every 100Wh, so I never had problems with that. But I realise that I should implement a configurable update rate limit, so you can specify that you don't want the data to be sent more than once every minute or so. It's already on my TODO list, just need the time to do it.
- Had to change the pulse_time to auto detect as there where a lot of 'Detected invalid pulse' in the /var/log/daemon.log. Most pulses are 67ms so I set this as value. Seems to be running better now.
Mmmh, it is strange that your energy meter generates pulses which are so far off from the spec. But in this case the auto detection should work. It just measures the length of the first pulse and uses this to validate all subsequent pulses (within some tolerance). However, if the first pulse is just some disturbance, this goes horribly wrong . This also could be improved.
Thank you again for the info and the nice program.
Herbie
Re: Project announcement: Energy monitor light
Hi Ondrej,
I use your Software on my Pi, which seams to work fine, but I still have some problems.
Well first, i got connected to the online emoncms. Emoncms got the data for 15minutes, and then the input haven't updated for around 2hours. Then again, it started again with 15min logging, then 2 hours break.
First I thoughed the wlan device was on sleeping mode, but i deactivated it, and nothing changed.
So I installed emoncms on the raspberry, changed the api, but i dont get any inputs.
My 2 questions are, do you have any idea for the regular logging break?
And any idea, why my offline emoncms don't get any signals? Where is the difference between online and offline setup?
Would be cool, if you could answer my questions?
Have a nice day
Re: Project announcement: Energy monitor light
Hi Flogo,
just saw your comment (haven't had comment notifications turned on).
The issue with your data not always getting through to the emoncms.org server sounds like a network problem. To check closer what happens you could try to run emond from the command line in foreground and look at the debug messages from the webapi.c file. Debugging mode should already be turned on. BTW, I have to improve that and write also the error messages from the webapi module to syslog.
Another problem could be that you are getting too many impulses from the energy meter and since a Web API request is sent for every impulse, the connection somehow gets blocked after a while. I really need to implement a Web API update rate limit to prevent sending too many API requests.
What is the usual time you see between two pulses from the energy meter? What is your Wh/pulse setting?
Regarding the local EmonCMS server not getting any data, you could test the correct setup of your server by sending an API request manually, using "curl" or just a web browser.
Let me know if you manage to solve these issues.
Ondrej
Re: Project announcement: Energy monitor light
Hi all,
here is an update for emond. It improves the WebAPI handling:
- Added configurable WebAPI URI
- Added configurable WebAPI update rate limit
- Handling of WebAPI request in seperate thread
- Bug fixes
Get it here, as usual:
http://ondrej1024.github.io/emond/
@Flogo, this might also solve the issue you reported. Please try the latest version and get back with some feedback. Thanks.
Re: Project announcement: Energy monitor light
Well, with the latest software update a little bug has crept in. It took me a while to notice and find the root cause. The symptom is that API updates to EmonCMS stop after some time (hours, days, depends on your update rate). The latest version 0.7.1 of emond fixes this. And I have learned something more about thread programming :-)
So please update to the new release.
Ondrej
Re: Project announcement: Energy monitor light
Ondrej
Thank you for the awesome work you have done.
I installed emond to my Pi that has emonPi running with 3 CT sensors. I used a circuit board from Lechacal.com to connect the CT sensors to the Pi and EmonPi image also from them. The EmonPi software uploads the data to emoncms.org every 30s.
I got the emond running ok in the same Pi but the updating stops after five minutes or so. I have tried changing the API request interval but it doesn't help.
I'm a noob in linux. How can I view the debug messages from webapi.c file?
Re: Project announcement: Energy monitor light
Hi Tuomas,
are you using the latest version 0.7.1 of the emond software from Github? This should have fixed the problem you see.
To print the debug messages from webapi.c to syslog uncomment line 27 (remove //)
//#define DEBUG
Ondrej
Re: Project announcement: Energy monitor light
Sorry for the delayed reply. I was busy with the family.
Yes I'm using the latest version from Github. I managed to get the debug messages to print in the syslog and I found the problem. The debug showed that the pulse length is too long and I also noticed that the pulse length was changing all the time. I'm using emond to read the output from LDR+555 timer circuit. It gives out 100 ms positive pulse every time the led flashes in my energy meter. The pulse length was changing because the electricity consumption was changing and emond was measuring time between the pulses because the trigger was the falling edge of the pulse(LOW in line 363 in emond.c). I changed the LOW to HIGH and it worked.
Is the S0 pulse output always positive and when the pulse comes the output goes to 0 V?
Re: Project announcement: Energy monitor light
Well, it's kind of funny that most people who report issues here never send any feedback on the proposed solution. Would be very helpful to know if the problem was solved. Feedback from the users is the only way to improve the software. That's why it's open source after all.
Ondrej
Re: Project announcement: Energy monitor light
Hi Tuomas,
AFAIK the S0 interface is a standard and it is implemented as shown in this picture:
The simple open collector circuit between S0+ and S0- is normally open and will be closed only during the positive pulse from the meter hardware. The emond software assumes that S0- is connected to RPi GND and S0+ to the GPIO pin. The software enables the internal pullup resistor on the GPIO pin. Therefore emond sees a "1" (high) when there is no pulse. The actual pulse will shorten S0+ and S0-, therefore the GPIO pin is pulled down to GND and emond sees a "0". That's why emond uses the negative logic (active low).
With your LDR circuit you probably keep the GPIO pin pulled low during inactivity and generate a positive pulse when its active. So you were right to invert the logic in the software. To make this easier I should make this configurable in the emond.conf file with active low logic the default.
Thanks for reporting back. I'm glad the program is working for you now.
Ondrej
Re: Project announcement: Energy monitor light
Yes you are right about my LDR circuit. Input pin is pulled low during inactivity. Sound like a good idea to add that to the configuration file.
I'm also planning to measure my water consumption and input the data to emoncms. I will use optical pulse sensor to read my water meter and I was planning to use emond for that. How can I use emond to read two different GPIO inputs in the same Pi? Or do I have to use another Pi.
Re: Project announcement: Energy monitor light
I think it should be possible to run 2 instances of emond on the same RPi, though I have never tried. You just have to change the hardcoded config file name for one of them so you can have two different configurations (which you need to specify 2 different GPIO inputs).
As an alternative emond could be transformed into a multi threaded program which could handle multiple GPIO inputs natively. But this would required quite some work.
Note that emond being focused on electrical energy, it calculates the electrical power from the time between two pulses, so this wont make sense for a water meter. But, of course, you can just use the total counter value to count litres.
Re: Project announcement: Energy monitor light
I will figure it out when I get the pulse sensor and mounted it to the water meter. I have another Pi running my Pimatic automation system and I can setup emond in to that Pi. I just have check that I have a free input pin.
Thank you for all the help.