Tip! Using EmonCMS servers with ESP8266 Wifi module
A
Andrew Baker
started a topic
over 8 years ago
Hello!
I did some poking around and noticed that simply changing the server and API key was not enough to let the default ESP8266 development firmware.
It seems that the strings being sent to the server wants to be formatted slightly differently for the Emoncms server. Right now, data.openevse likes a "devicekey" to precede the API key, like THIS:
(and it needs to be the read-write API key, obviously)
To make these changes, you of course need to change the server in the code by commenting out (that's the two forward slashes) the OpenEVSE server, and UNcommenting the EMONCMS server.
//const char* host = "data.openevse.com"; //Default to use the OpenEVSE EmonCMS Server
const char* host = "www.emoncms.org"; //Optional to use Open Energy EmonCMS servers
THEN just as importantly, you need to change the JSON string in the section called " // Create the JSON String"
// s += "}&devicekey="+String(apikey); // If using data.openevse
s += "}&apikey="+String(apikey); // if using emoncms - What's an elegant way to do this?? I'm not a programmer
I copied the line with the devicekey, commented it out, pasted an uncomment copy of it below, and replaced devicekey with apikey, and voila! Feeds!!
For those of you that ARE programmers, I apologize for providing such detailed instructions :-)
Andrew Baker
Hello!
I did some poking around and noticed that simply changing the server and API key was not enough to let the default ESP8266 development firmware.
It seems that the strings being sent to the server wants to be formatted slightly differently for the Emoncms server. Right now, data.openevse likes a "devicekey" to precede the API key, like THIS:
https://emoncms.org/input/post.json?json={power:200}&devicekey=a3a5a30fa0rangtangdingdong9f7
but EMONCMS likes the word apikey
https://emoncms.org/input/post.json?json={power:200}&apikey=a3a5a30fa0rangtangdingdong9f7
(and it needs to be the read-write API key, obviously)
To make these changes, you of course need to change the server in the code by commenting out (that's the two forward slashes) the OpenEVSE server, and UNcommenting the EMONCMS server.
//const char* host = "data.openevse.com"; //Default to use the OpenEVSE EmonCMS Server
const char* host = "www.emoncms.org"; //Optional to use Open Energy EmonCMS servers
THEN just as importantly, you need to change the JSON string in the section called " // Create the JSON String"
// s += "}&devicekey="+String(apikey); // If using data.openevse
s += "}&apikey="+String(apikey); // if using emoncms - What's an elegant way to do this?? I'm not a programmer
I copied the line with the devicekey, commented it out, pasted an uncomment copy of it below, and replaced devicekey with apikey, and voila! Feeds!!
For those of you that ARE programmers, I apologize for providing such detailed instructions :-)
Andy