Raspberry PI GLCD looking good ! but how to use GET feed in C++ script?

Hi all,

I'm building a Graphic LCD screen right on top of my Raspberry PI and I make use of the GeneralPins I/O to connect a Digole 128x64 LCD with the I2C protocol.

I use C++ to control it and I managed to get it working with the API that is on the LCD driver board:

first screens here:

 

So now I'm upto getting feeds into the C++ application. But I'm not a really good wizkid in programing so I need a bit of help here.

Does anybody have an example to use the emoncms GET (json) command in C++ ? I tried to "port" the Python code from @Mharizanov on his OLED topic (I use the same GLCD drive chip here!)  but no luck.

This is what I tried:

void  getFeedVal (uint8_t feedId){
    conn = httplib.HTTPConnection("energy.#####.nl")
    conn.request("GET", "/feed/value.json?apikey=9b69c7f3c39e30a39##key##&id=" + feedId)
    response = conn.getresponse()
    data = response.read()
    conn.close()
    data = data.replace("\"", "")
    return data[:4]
}

(## = hide some url and key info)

Jérôme's picture

Re: Raspberry PI GLCD looking good ! but how to use GET feed in C++ script?

Did you actually try that ?

I mean it looks like python code inside a C++ prototype... but without the porting.

alco's picture

Re: Raspberry PI GLCD looking good ! but how to use GET feed in C++ script?

No, I know that this won't work and that you need a decent libary for it like libcURL. So I'm wondering/asking if somebody already used a lib for getting feed data out of the emoncms. or know a tutorial that explain libCurl of other libary with the GET command.

/ P.S. I just screwed my LCD connector pff. pulling a bit to mutch at the connector, stupid...

glyn.hudson's picture

Re: Raspberry PI GLCD looking good ! but how to use GET feed in C++ script?

Nice LCD! Do you think you could post you code your using to draw the LCD from Pi. We're currently evaluating options for the Raspberrry Pi

alco's picture

Re: Raspberry PI GLCD looking good ! but how to use GET feed in C++ script?

Hi Glyn,

Off course, I will upload the code to my github and also to www.bluemotica.nl. I know that you made a first eaglecad drawing for the PI :) and I also had a short conversation with you (or trystan) on twitter @bluemotica.nl

I'm making some new screens on the moment, and I have to learn or get some code examples for the emoncms GET stream. It's wordless if it isn't getting some data :s on it.

 

Comment viewing options

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