senda data to Emoncms

Hi! I have a emoncms server on my Raspi and use an SD120c connected via modes in order to collect the data.
I have written this code in python:

 

import os
import time
import requests

while 1:
  dati = os.popen("sdm120c -a 1 -b 2400 /dev/ttyUSB0 -q").read()
  print dati
  dati2 = "csv=" + dati
  print dati2
  # Send to emoncms
  r = requests.post("http://10.0.1.16/emoncms/input/post.json?node=1", params=dati2)
  print(r.url)
  r.status_code == requests.codes.ok
  time.sleep(5)

 

the url created by the program is correct but the emoncms server does not receive data... but if i try to copy and paste the url generated by the script in my browser, the server receive all data!!

where I'm wrong?

Thanks!

pb66's picture

Re: senda data to Emoncms

It looks like you are missing an apikey, when you you C&P into browser chances are you are already logged in perhaps.

Paul

Robert Wall's picture

Re: senda data to Emoncms

The "read&write" APIkey of course. See the Input API Help for the key and the format.

loop_1's picture

Re: senda data to Emoncms

wow!!! Thanks!

Comment viewing options

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