Community
OpenEnergyMonitor

Community

Emoncms on raspberry, no inputs from esp8266

esp8266
emonpi
emoncms
Tags: #<Tag:0x00007f880ba2bad0> #<Tag:0x00007f880ba2b8a0> #<Tag:0x00007f880ba2b648>
(Oliver Kohl) #1

Hi there,

what I’ve successfully done so far:
Sketch on NodeMCU that reads data from bme280 sensor and upload it to emoncms.org. After starting the sketch the first time, I was immediately able to see the datas from the nodemcu as inputs on emoncms.org.
Now I want to have emoncms on a raspberry pi B+ and therefore I flashed the emonSD-30Oct18 (Stable) from github. At the very first start, as recommended, I connected the pi via LAN cable in order to let it do its updates.
After that, in a webbrowser with the correct IP adress, I was able to create an account and log into it. Everything seems to work fine, but:
There are no inputs anymore from my sensor/nodemcu. I replaced the host with the correct ip adress (and no it doesn’t change anything, if adding input subfolder after the ip adress) and also replaced the input API in the code.
No success at all
What’s working though, is to copy a jason example from the inputAPI documentation page.

What am I missing here ?
this is part of the code I use:

//emoncms settings, change node ID for every node
const char* host = "192.168.0.133";
const char* nodeId   = "Kitchen";
const char* privateKey = "emoncmsapireadandwritekey";
float h = 0;
float t = 0;
float p = 0;
int vcc;
ADC_MODE(ADC_VCC);
char temperatureCString[6];
char humiditiyString[6];
char pressureString[7];
const int httpPort = 80;

Edit - fixed code formatting. BT, moderator.

(Brian Orpin) #2

Are you sure it is the Read Write Input API key?

Do you access the web interface via the same IP address?

(Oliver Kohl) #3
  1. Thanks for your reply
  2. Definitely, yes !!
(Brian Orpin) #4

Is there anything in the log window on the admin page to indicate if there are any errors? If not, in the emoncms folder you will find a file settings.php. Look for the logging option and change it to INFO level.

When the NodeMCU posts to emoncms, you should see some entries in the log.

(Celso Henriques) #5

@borpin, sorry but in the question can you edit and delete his private key? i think is the read/write key.
Sorry but i can’t edit his question.

@chalkmaroon, Welcome to the forum. Just a small note: don’t leave unhidden your read/write keys please. Please delete it and write something like “EMONCMSKEYS”, if @borpin didn’t did it first.

1 Like
(Oliver Kohl) #6

borpin:
will try this, thanks !

CelsoHenriques:
Ok, but this is a private network without internet connection, so this wasn’t too important for me in this case…

1 Like
(Oliver Kohl) #7

I just reflashed emonSD-30Oct18 (Stable) and started fresh
Still the same issue and at the admin page the following is shown:

2018-10-30 17:00:08.740|WARN|phpmqtt_input.php|Not connected, retrying connection
2018-10-30 17:00:08.846|WARN|phpmqtt_input.php|Connecting to MQTT server: Connection 
Accepted.: code: 0
2018-10-30 17:00:23.035|WARN|phpmqtt_input.php|Not connected, retrying connection
2018-10-30 17:00:23.057|WARN|phpmqtt_input.php|Connecting to MQTT server: Connection 
Accepted.: code: 0
2019-05-06 16:49:35.944|ERROR|feedwriter.php|Starting feedwriter script
2019-05-06 16:49:37.052|WARN|emoncms_mqtt.php|Not connected, retrying connection
2019-05-06 16:49:37.081|WARN|emoncms_mqtt.php|Connecting to MQTT server: Connection 
Accepted.: code: 0

Besides of the date 2018-10-30 in the first lines, it looks ok to me, when there is the info "Connection Accepted.: code: 0

(Oliver Kohl) #8

Blockquote
Is there anything in the log window on the admin page to indicate if there are any errors? If not, in the emoncms folder you will find a file settings.php . Look for the logging option and change it to INFO level.

Hmm, I cannot find the folder emoncms and settings.php, I’m sorry…

(Brian Orpin) #9

It is in the root www folder so /var/www/emoncms or /var/www/html/emoncms/

(Oliver Kohl) #10

now the log looks like this:

LAST ENTRIES ON THE LOG FILE

2019-05-06 18:54:41.815|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:41.818|INFO|rememberme_model.php|clearCookie

2019-05-06 18:54:41.818|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:41.834|INFO|index.php|feed/list

2019-05-06 18:54:42.231|INFO|index.php|feed/list.json

2019-05-06 18:54:42.282|INFO|index.php|schedule/list.json

2019-05-06 18:54:42.293|INFO|index.php|input/list.json

2019-05-06 18:54:42.286|INFO|index.php|process/list.json

2019-05-06 18:54:42.381|INFO|index.php|feed/list.json

2019-05-06 18:54:44.174|INFO|index.php|device/list.json

2019-05-06 18:54:44.180|INFO|rememberme_model.php|login

2019-05-06 18:54:44.181|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:44.200|INFO|index.php|input/list.json

2019-05-06 18:54:44.206|INFO|rememberme_model.php|login

2019-05-06 18:54:44.206|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:47.226|INFO|index.php|feed/list.json

2019-05-06 18:54:49.184|INFO|index.php|device/list.json

2019-05-06 18:54:49.190|INFO|rememberme_model.php|login

2019-05-06 18:54:49.191|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:49.211|INFO|index.php|input/list.json

2019-05-06 18:54:49.217|INFO|rememberme_model.php|login

2019-05-06 18:54:49.218|INFO|rememberme_model.php|getCookieValues: not present

2019-05-06 18:54:50.437|INFO|index.php|admin/view

2019-05-06 18:54:51.787|INFO|index.php|admin/getlog

2019-05-06 18:54:51.787|INFO|index.php|feed/buffersize.json

(Brian Orpin) #11

When your system posts the data, you should see a specific entry relating to your posting of the data and then the processing of it.

If you use

 tail -f /var/log/emoncms.log | grep input

You should be able to see just the entry. If you get that try

tail -f /var/log/emoncms.log to get the whole log.

You can test it by using one of the sample links on the Input API page.

If you do not see anything, then the URL is not formatted correctly. Can you do a print of the actual URL you have generated from your script?

(Oliver Kohl) #12
[email protected]:~ $ tail -f /var/log/emoncms.log | grep input
2019-05-06 20:24:32.907|INFO|index.php|input/list.json   2019-05-06 
20:24:37.903|INFO|index.php|input/list.json
2019-05-06 20:24:42.907|INFO|index.php|input/list.json

 [email protected]:~ $ tail -f /var/log/emoncms.log
 2019-05-06 20:22:42.892|INFO|rememberme_model.php|getCookieValues: not present
2019-05-06 20:22:42.906|INFO|index.php|input/list.json
2019-05-06 20:22:42.913|INFO|rememberme_model.php|login
2019-05-06 20:22:42.913|INFO|rememberme_model.php|getCookieValues: not present
2019-05-06 20:22:47.883|INFO|index.php|device/list.json

And so on…

(Brian Orpin) #13

Can you tell which one relates to the input from your device?

You need to look at the actual URL you generate from your script or else use something like tshark on the Pi to determine what is actually being sent.

Can you post all the code?

[edit] you will need to install tshark (do some Googling) but something like this may help

(Oliver Kohl) #14

Ok, I’ll take a look at tspark. Sounds complicated, though…
Thank you for your help !!

(Brian Orpin) #15

Unless you can put a print statement into your code and get the URL it is sending and if there is nothing in the emoncms log, it is the only way of tracing the issue.

You could post all the code and someone may spot the issue. The API with emoncms.org is slightly different IIRC.

(Oliver Kohl) #16

Unless you can put a print statement into your code and get the URL it is sending

This is exactly what I mean with complicated… :slight_smile:
I’m a totally newby who just copy code together, which I may can adjust to my needs and that’s it…
I’ll do a research and give it a try, I want to get this going !

1 Like
(Oliver Kohl) #17
tshark -Y http.request -T fields -e http.request.full_uri

and resetting the node gives me immediately the following output:

http://172.23.56.146/input/post.json?node=Kitchen&apikey=emonpicmsreadandwriteapikey&json={temperature:22.20,humidity:23.42,pressure:957.39}

The IP differs from my first post, since the node connects to a different router now.
For my humble knowledge it looks all good, but there are still no inputs, yet.
I also put the whole link from above, except the measured values, in the host line of the emoncms setting section,
but again, no success…

1 Like
(Paul) #18

If you cut and paste that request into a browser bar and enter, what response do you get?

Should it not be

http://172.23.56.146/emoncms/input/post.json?node=Kitchen&apikey=emonpicmsreadandwriteapikey&json={temperature:22.20,humidity:23.42,pressure:957.39}

I get a 404 on my emonSD image if I omit the /emoncms sub-directory.

1 Like
(Oliver Kohl) #19

Oh, I missed that, thanks !!
… and cannot try it out before tomorrow, because I forgot the sd card at work…

1 Like
(Oliver Kohl) #20

The request from tshark from my last post wasn’t from the node.
I ran it again and from the node comes nothing, but every 5 min an output, that mqtt server got 0 data…

I get a 404 on my emonSD image if I omit the /emoncms sub-directory.

So do I and with /emoncms I also get an error, but didn’t copy it, because this seems to be a dead end for me.
I do not understand what’s going on here and can’t get it to work. I’m not able to expand the code for posting a print line to get the url, too. Maybe I find some ohter code for the nodemcu and emoncms. I just wanted something neat to display temperature and humidity with a little bit of logging and the code that I have was exactly what I wanted, when using it with “emoncms.org” as host for the cms.
But since it is not possible for me to run emoncms locally, I’ll may check for something else.

Thanks all for your help, it was definitely educational
Cheers,
Oli