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....
4 out of 4
Suggested Topics
-
Update RF24 library to latest version
Bug Reports • 23 Mar 2014, 23:37 • andriej 24 Mar 2014, 22:52 -
ESP32 with LoRa
General Discussion • 31 Jan 2023, 11:06 • dhanushmh 25 days ago -
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 -
Meet in Malmö, Summer 2016?
General Discussion • 1 Feb 2016, 15:34 • bjacobse 4 Mar 2025, 00:29 -
Why is the output of ACS712 current measurement module unchanged?
General Discussion • 19 Jul 2021, 09:09 • Tessie T 29 days ago -
Email notifications received twice
General Discussion • 6 Feb 2023, 16:15 • Jodaille 27 Mar 2025, 06:07