Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. Help parsing a string to grab a value?

Help parsing a string to grab a value?

Scheduled Pinned Locked Moved General Discussion
4 Posts 3 Posters 1.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TommySharp
    wrote on last edited by
    #1

    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.....

    mfalkviddM 1 Reply Last reply
    1
    • F Offline
      F Offline
      flopp
      wrote on last edited by flopp
      #2

      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
      
      1 Reply Last reply
      0
      • T TommySharp

        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.....

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by mfalkvidd
        #3

        @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"];
        
        1 Reply Last reply
        1
        • T Offline
          T Offline
          TommySharp
          wrote on last edited by
          #4

          Thanks for your help guys! I got it resolved....

          1 Reply Last reply
          1
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          20

          Online

          11.7k

          Users

          11.2k

          Topics

          113.1k

          Posts


          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular