Hello,
I'd like to do an approach to OpenEnergyMonitor (actually I have an Efergy), and I'm not familiar to emoncms and it's inputs/feeds. Before buying any OpenEnergyMonitor product, I'd like to do some test. First step, installing emoncms in a RaspberryPi is done.
With RaspberryPi is very easy to measure it's own CPU temp with a simple command line. How can I export this temp as a feed? (same Raspberry as emoncms install)
I have several RaspberryPi in my home, and it's quite easy to setup a DS18B20 or a DHT22 to measure temp, but, how can I export to a new input/feed?
Thanks in advance!
BYE!
Re: Feeding Raspberry's temperature and sensors connected to raspi.
Hi,
just log on to your emoncms instance and go to the Input Help page:
/emoncms/input/api
On that page you'll find all the info you need to post data to your instance, single feeds, bulk import and eventually how to query them from an external app
Regards
Re: Feeding Raspberry's temperature and sensors connected to raspi.
Thanks!
There I can see different input methods. I suppose that I must do any kind of script to put this temp read into a json string. This is for the local raspi temp, but I'm quite lost (...still more) with the remote raspis.
Re: Feeding Raspberry's temperature and sensors connected to raspi.
Let's assume the raspberry you have installed emoncms on has ip address 192.168.2.1, and that you did a standard install, so you access it with this url: http://192.168.2.1/emoncms
Let's assume your write API key is cd7921341d9e2eb7b800ce8c40029068
Let's assume you have two remote raspberries, raspi1 and raspi2, and one arduino with network access
Let's assume you want to use node id 101 for raspi1, node id 102 for raspi2 and node 201 for you arduino
Let's assume on every remote node you have sensors for temperature, pressure and humidity
then feeding data into your emoncms instance will be a matter of calling these urls:
raspi1: http://192.168.2.1/emoncms/input/post.json?node=101&csv=2200,1001,86&apikey=cd7921341d9e2eb7b800ce8c40029068
raspi2: http://192.168.2.1/emoncms/input/post.json?node=102&csv=2200,1001,86&api...
arduino: http://192.168.2.1/emoncms/input/post.json?node=201&csv=2200,1001,86&api...
Once you call these URLs you will find that new inputs have been created in the inputs tab, for which you can then assign a name and create feeds
How you get you nodes to place the call to emoncms is left as an exercise for you (since I don't know what you are using to read the sensors), it could be a php script, a python, perl or bash script ... whatever
Re: Feeding Raspberry's temperature and sensors connected to raspi.
Thanks!
That's the clue I was looking for. Now I have to work in a python script to read what I need and post via json.
BYE!
Re: Feeding Raspberry's temperature and sensors connected to raspi.
Hello,
here is the code I'm using (working!):
#!/usr/bin/python
import subprocess
import time
import os
import urllib2
serverIP = "your_server_IP"
nodeID = "node_id"
apikeyRW = "your_apikey_RW"
interval = interval_in_secs
while True:
currentTemp = subprocess.check_output(["/opt/vc/bin/vcgencmd","measure_temp"])
currentTemp = float(currentTemp.split("=")[1][:-3])
urllib2.urlopen("http://" + serverIP + "/emoncms/input/post.json?node=" + nodeID + "&csv=" + str(currentTemp) + "&apikey=" + apikeyRW)
time.sleep(interval)
BYE!