I am wondering about sending data back to the emonGLCD. I know the base sends the time back but I would also like to have the base look-up the power cost and send that back as well. Can anyone Brief me on how the base sends the time back and the feasibility of sendin power cost as well. Has anyone done this?
»
Re: Sending data back to the emonGLCD
Time is sent to emonGLCD in the form of a structure containing two integers (3 if you choose to send seconds as well):
typedef struct { int hour, mins; } PayloadBase;
PayloadBase emonbase;
The base gets the time from the server by sending a request like:
"http://emoncms.org/time/local.json?apikey=[YOURAPIKEY]"
and the server replies with a string: "t13,27,36" (try it in your browser!) which the base packs into the struct and transmits. In general terms, you will need to replicate this with your costs data, but the interesting question is, where will you get the cost data from in the first place? If you don't have your own server, that could be quite a problem. If you do, you need to extend the server code to look up the cost, presumably from somewhere - a file - that you will update from time to time, else you still have the problem of getting the rates from somewhere and parsing the data into the format you require.
Re: Sending data back to the emonGLCD
Thanks a lot. I am using my own server so I do plan to initially use a flat text file and eventually grab the power cost from the government website. We are charged different rates at different times so I will need to retrieve this number at least hourly.
So, I guess, as you said, I'll look at the emonCMS code first and figure out how to reply with the cost, then I'll look at the base and work from there. Lastly, the emonGLCD. How often does the GLCD grab the time? Does it do it just on initialization? What about the base? How often does it query?
Re: Sending data back to the emonGLCD
I think you'll find all the answers to those questions in the code! My inclination would be to do as much of the processing as possible in the server, because memory is severely limited in the GLCD (to the extent that you might have to take some features out to include the new cost display), and only a little less so in the base.