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
-
@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....
1 out of 4
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
Which device I have to use to connect with accelerometer before connecting to my pc?
General Discussion • 24 Jan 2023, 17:16 • Yada Kijsathan 16 Mar 2025, 20:17 -
No merge into master in the last 5 years, should we use development?
General Discussion • 23 Sept 2024, 17:48 • kiesel 25 Mar 2025, 15:30 -
ESP-NOW
General Discussion • 22 Apr 2018, 05:58 • NeverDie 17 Feb 2025, 22:24 -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 4 Mar 2025, 00:29 -
Is it possible to extract child ID from a just sent message?
General Discussion • 8 Nov 2021, 09:21 • Nigel31 26 days ago