Best format for Adruino --> Imp data exchange

Hi All

I’ve got an Imp attached to an Arduino and am wanting to send objects between the two, so I thought JSON would be a good idea. So I have my Arduino sending a simple JSON string to my Imp over serial. Then i try to decode on the device, so the object can be used, only to be reminded of the fact that the http functions don’t exist on the device, so http.jsondecode() doesn’t work.

Am I going about this the wrong way? It seems silly to implement my own way of formatting data when JSON is so prevalent, but with no JSON decoding on the device, I’m somewhat stuck!

Any advice?

Found an exciting little class for JSON for squirrel, however it relies on the compilestring function in squirrel to simply turn the string into an object (as JSON syntax is a valid way of declaring tables in squirrel). Compilestring isn’t available in Imp however, so it’s back to square 1!!

You could always send the JSON up to the agent to parse, assuming indeed that the data is going to be sent onwards to the internet anyway?

@opb , as I understand you want to use imp just as wireless module?
Why not remove Arduino and use just imp?

Thanks @Hugo, that’s what I was thinking, but I’ve gone back to using a more simple proprietary format - I’m not writing an API or anything, so just a simple protocol which each end understands and can easily parse will probably be a better idea.

@PeterAP - I’m integrating an NRF24L01 module, requiring SPI plus two additional pins, and some DS18B20 modules with the OneWire interface. Arduino currently has better software support for both those, and a lot more pins! The Arduino will be a dumb unit just taking temperature values and acting as an interface between the Imp and the NRF module. All logic will be in the Imp itself.

@opb, a bit “complicated”:slight_smile: what is the reason for NRF24L01? Transceiver and WiFi - to make a bridge?

@PeterAP A network of wireless temperature sensors for uploading to Xively.

If you had a greenhouse (for example) and needed 20 temperature sensors, couldn’t you use 20 Imps, and each one uploads it’s own data?

@mlseim well, I guess you could, but to me that would see awfully wasteful. An adruinino pro mini clone, plus NRF wireless module, would come in at £8 in total on eBay, vs £20 for the Imp.

Plus, with my solution, the Arduinos are essentially just dumb units which report their temperature. All logic and fancy stuff is done in one place. If I change my Xively API key, I do it in 1 agent, not 20. Aggregating the data together and POSTing just once is also arguably a lot better practice than POSTing 20 times.