Help parsing a string to grab a value?
-
Is anyone able to help me parse a string using arduino code that is getting returned by a IP based temperature sensor?
I have a URL that I can call and this is what is returned...
{"temp":19.3,"id":"373650"}
I need to just grab the 19.3 so I can store it.....
I appreciate I may not be asking in the best forum based on this not being specifically related to MySensors but any help would be appreciated.....
-
This may help you in the correct direction
It is a LUA script that I run in Domoticz.
commandArray = {} cmd = otherdevices_svalues["!!nodename!!"] local watt, energy, a, b print(cmd) _,_,watt, energy, a, b = string.find(cmd, "(.+):(.+):(.+):(.+)") print(watt) print(energy) print(a) print(b) return commandArray -
Is anyone able to help me parse a string using arduino code that is getting returned by a IP based temperature sensor?
I have a URL that I can call and this is what is returned...
{"temp":19.3,"id":"373650"}
I need to just grab the 19.3 so I can store it.....
I appreciate I may not be asking in the best forum based on this not being specifically related to MySensors but any help would be appreciated.....
@TommySharp you can use a json library. Example: https://github.com/bblanchon/ArduinoJson
StaticJsonBuffer<200> jsonBuffer; JsonObject& root = jsonBuffer.parseObject(thetextfromurl); float temp = root["temp"]; -
Thanks for your help guys! I got it resolved....
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login