Running Emoncms straight from an Arduino?

I've been poking around the forums for a few days, but I'm not really sure I'm barking up the right tree, so I thought I'd post my question - can I run this without the tx-rx and emonbase hardware?

I'm building a power monitoring system.  I have arduinos, and an old EeePC running Ubuntu kicking around, and I only need to monitor a single electrical panel to start with.  It would seem to me that I could just plug the Arduino with the voltage and current sensors (a la http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor) straight into the EeePC, and run emoncms there, without doing the whole wireless and emonbase setup.  

The electronic and electrical work is no problem for me, but I'm a bit fuzzy on the emoncms side - are there any examples I could follow of an arduino connected directly to the computer running emoncms?  Also, are there any reasons I shouldn't do it this way?  In my situation, and arduino and eeepc costs about the same as the whole wireless setup, and I get wifi wireless to my network included via the eeepc.

I've got most of the odds and ends collected, just waiting for the current transducers to arrive.  Should be interesting!

TrystanLea's picture

Re: Running Emoncms straight from an Arduino?

Yes you can do it that way no problem, you just need to create a relay script to read the serial printed output from the arduino and relay the result as requests to emoncms. It can be done relatively easily with python:

https://github.com/openenergymonitor/EmoncmsPythonLink/blob/master/pylin...

or you might be interested in having a look at the raspberrypi module implementation which uses php serial: 

https://github.com/emoncms/raspberrypi/blob/master/raspberrypi_run.php

 

wbortz's picture

Re: Running Emoncms straight from an Arduino?

Thanks!  I got as far as running the pylink.py program, and it's getting data from the Arduino and printing it to stdout.  My Emoncms is up and running; I managed to get some canned data through by accident, but the format of the conn.request bit of code seems all wrong for my Emoncms setup (freshly installed via the standard Ubuntu install).

I'll have to sleep on it and try again in the morning, but I think I'm very close.  Just need to figure out the formatting.

 

Wade

wbortz's picture

Re: Running Emoncms straight from an Arduino?

Thanks for the help Trystan - got it running now, had an issue where dashboards wouldn't work due to my user name, but that's sorted now.  

Check it out:

http://halehee.no-ip.org/emoncms/wade

Pretty sweet!

Only outstanding issues are the currency setting in the zoom visualization on page 3 won't save, and figuring out how to run that python script automatically at boot.  Off to google some more!

Wade

redson's picture

Re: Running Emoncms straight from an Arduino?

Hi Wade,

 

I did the same but its not working, i am newbie

i can c the output from python script and added to my own server link in the script like

"import serial, sys
import httplib

conn = httplib.HTTPConnection("localhost")
ser = serial.Serial('/dev/ttyUSB0', 9600)

while 1:
        sys.stdout.write(ser.readline())
        conn.request("GET", "/emoncms3/api/post?apikey=5002770a0e9ecc14ba4b2c2479d20266&json="+ser.readline())
        response = conn.getresponse()

and its showing me result like

0.23 0.19 0.26 234.89

 

but i m unable to get any feeds (all are inactive)

Is their any guide to do that , or how can i troubleshoot ?

redson

ukmoose's picture

Re: Running Emoncms straight from an Arduino?

Redson,

 As a newbie, it is not helpful to post the same message in 2 different places.

1) The people who give support here are all unpaid volunteers and it just wastes time.

2) Often the answers come from more than one post. So if the posts are all in the same place it makes it easier for you as well.

 

see answer in the other post you made with exactly the same content...

http://openenergymonitor.org/emon/node/1554

redson's picture

Re: Running Emoncms straight from an Arduino?

Sorry for the double post.

 

I have tried the same way as in the manual, moreover if by the default method for demo given, it works,

but when tried with python script it wont ,

I can c the output on stdout but cannot on webpage

 

I have installed emoncms3 on centos

Please let me know trouble shooting steps.

 

redson

ukmoose's picture

Re: Running Emoncms straight from an Arduino?

When you say you can see the data on stdout is this using the serialtest.py script?

If this works have you installed the following python library, httplib ?

If you have, what version of python have you got installed?

If it is python3  httplib is been renamed to http://docs.python.org/3.0/library/http.client.html and you will need to modify your script to reflect this.

 

redson's picture

Re: Running Emoncms straight from an Arduino?

Its python 2.4 in centos 5.8 default installed..

redson's picture

Re: Running Emoncms straight from an Arduino?

Hi Ukmoose,

I was checking the apache logs i am sending only power at stdout as below

223.97
224.22
223.77
223.93
223.74
223.98

But when i check the apache logs

GET /emoncms3/api/post?apikey=1f247d1e79f88ad35f0c5e6980d48f81&json= 224.91" 400 581 "-" "-"

where as my pyserial.py is

conn.request("GET", "/emoncms3/api/post?apikey=1f247d1e79f88ad35f0c5e6980d48f81&json="+ser.readline())

i m unable to get from where is 400 581 "-" "-"  coming
I am using emontx with sketch "emonTx_CT123_Voltage.ino", can you pls guide me where am i getting wrong.

redson

 

ukmoose's picture

Re: Running Emoncms straight from an Arduino?

Not sure how you can be getting 5 values!

You are passing the serial output across so it looks as if somehow the values being sent by your sketch aren't whet you think they are. 

You need to look at how you have configured emonTx_CT123_Voltage.ino

if you are not using CT2&CT3 change the following lines from 1 to 0  e.g.

const int CT2 = 0;                                                    

const int CT3 = 0;

 

You can also use the serial output to check to see what is being broadcast

nigel91's picture

Re: Running Emoncms straight from an Arduino?

Hie . I also want to connect directly to emoncs without going through  the raspberry pi  or tx-rx and the ethernet shield . However i am running a windows pc . is this possible and how would i proceed . I get all the reading i want but putting them up online is my issue. 

nigel91's picture

Re: Running Emoncms straight from an Arduino?

hie is it possible to get these readings from a windows pc straight from the arduino . since this post was using ubuntu . dont know if the same applies for windows 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.