Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. maggie
    3. Topics
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by maggie

    • maggie

      How can I implement this?
      Development • • maggie  

      4
      0
      Votes
      4
      Posts
      755
      Views

      Nca78

      Hello, you can probably get some inspiration from this project made by students GLiP Project - Demo – 02:22— Harken33
    • maggie

      Separate msg.payload into Temperature,Humidity,Luminosity objects.
      Troubleshooting • • maggie  

      2
      0
      Votes
      2
      Posts
      3044
      Views

      Yveaux

      @maggie How about something like this? The Humidity/Temperature injects simulated data coming in from your sensors. This data gets split on a semicolon: var fields = msg.payload.trim().split(':'); msg.type = fields[0]; msg.value = parseInt(fields[1]); return msg; and the switch determines on msg.type where to route the data. If you want to try this code then just copy/paste he following block into Node-Red: [{"id":"d56d943.4bfae68","type":"switch","z":"3ce68302.c3197c","name":"","property":"type","propertyType":"msg","rules":[{"t":"cont","v":"Humidity","vt":"str"},{"t":"cont","v":"Temperature","vt":"str"},{"t":"else"}],"checkall":"true","outputs":3,"x":500.8333511352539,"y":823.6666984558105,"wires":[["7f9e7e7f.48016"],["e23d0ce6.78b9d"],["82fc1542.5faa18"]]},{"id":"68c3690d.519a88","type":"inject","z":"3ce68302.c3197c","name":"","topic":"","payload":"Humidity:45","payloadType":"str","repeat":"","crontab":"","once":false,"x":150.8333282470703,"y":807.6667022705078,"wires":[["9e7dc36.f3b074"]]},{"id":"4da4d5e4.5a276c","type":"inject","z":"3ce68302.c3197c","name":"","topic":"","payload":"Temperature:23","payloadType":"str","repeat":"","crontab":"","once":false,"x":164.3333282470703,"y":866.3333129882812,"wires":[["9e7dc36.f3b074"]]},{"id":"9e7dc36.f3b074","type":"function","z":"3ce68302.c3197c","name":"Split","func":"var fields = msg.payload.trim().split(':');\nmsg.type = fields[0];\nmsg.value = parseInt(fields[1]);\nreturn msg;","outputs":1,"noerr":0,"x":354.83333587646484,"y":824.3333625793457,"wires":[["d56d943.4bfae68"]]},{"id":"7f9e7e7f.48016","type":"debug","z":"3ce68302.c3197c","name":"Humidity","active":true,"console":"false","complete":"value","x":680.8333282470703,"y":805.0000152587891,"wires":[]},{"id":"e23d0ce6.78b9d","type":"debug","z":"3ce68302.c3197c","name":"Temperature","active":true,"console":"false","complete":"value","x":694.3333129882812,"y":852.3333129882812,"wires":[]},{"id":"82fc1542.5faa18","type":"debug","z":"3ce68302.c3197c","name":"Other","active":true,"console":"false","complete":"value","x":676.3333129882812,"y":904.3333129882812,"wires":[]}]