We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

jsn-sr04t v2 ultrasonic sensor working on omega2 via node red



  • Hello, Some days ago I was trying to make work my ultrasonic sensor to upload data to mqtt server, so I want to share my code, first, you need to install node red on omega2, second, you need to put a resistor on ultrasonic sensor accordin to the datasheet

    https://www.makerguides.com/wp-content/uploads/2019/02/JSN-SR04T-Datasheet.pdf

    we are going to work in mode three, so put the resistor of 120k

    finally just upload my flow to your omega, you can use uart 0 or uart1 on omega or use a ttl usb converter, thats your choice

    
    [{"id":"fca4437d.e3677","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"7f286ed6.303ef","type":"function","z":"fca4437d.e3677","name":"Convert to Hex","func":"msg.payload = msg.payload.toString('hex');\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":300,"wires":[["19982236.8d258e"]]},{"id":"19982236.8d258e","type":"split","z":"fca4437d.e3677","name":"Split","splt":"4","spltType":"len","arraySplt":"4","arraySpltType":"len","stream":false,"addname":"","x":770,"y":300,"wires":[["3e2d31b4.f9b71e"]]},{"id":"3e2d31b4.f9b71e","type":"switch","z":"fca4437d.e3677","name":"Use fist two values","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":300,"wires":[["af5f9c86.6c77e"]]},{"id":"91198752.988f18","type":"exec","z":"fca4437d.e3677","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Execute","x":1400,"y":300,"wires":[["ca7aad52.dacd7"],[],[]]},{"id":"7ed8dbb2.80b684","type":"debug","z":"fca4437d.e3677","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1830,"y":380,"wires":[]},{"id":"ca7aad52.dacd7","type":"change","z":"fca4437d.e3677","name":"Convert to Number","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(msg.payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1610,"y":280,"wires":[["3a0223e1.d43b1c"]]},{"id":"3a0223e1.d43b1c","type":"function","z":"fca4437d.e3677","name":"Payload in centimeters","func":"msg.payload = msg.payload/10\nreturn msg;","outputs":1,"noerr":0,"x":1860,"y":280,"wires":[["7ed8dbb2.80b684"]]},{"id":"af5f9c86.6c77e","type":"template","z":"fca4437d.e3677","name":"Template to decimal","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"echo $((0x{{payload}})) | awk '{printf $1}'","output":"str","x":1200,"y":300,"wires":[["91198752.988f18"]]},{"id":"d859b96b.ffcbe8","type":"serial request","z":"fca4437d.e3677","name":"Serial Port","serial":"a1611668.300668","x":410,"y":300,"wires":[["7f286ed6.303ef"]]},{"id":"31a935ff.b7ad0a","type":"inject","z":"fca4437d.e3677","name":"Start Request","topic":"","payload":"[85]","payloadType":"bin","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":300,"wires":[["d859b96b.ffcbe8"]]},{"id":"a1611668.300668","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"0xff","bin":"bin","out":"char","addchar":"","responsetimeout":"10000"}]
    
    

    1_1574590271847_IMG_20191124_035302168.jpg 0_1574590271841_IMG_20191124_035252120.jpg



  • Hi, could you help me to install the serial port on node-red?
    I'm trying to install it using Node-Red 1.29 from the palette and I have an error.

    Error:
    2022-07-24T22:01:28.311Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-node-serialport@1.0.1
    2022-07-24T22:02:22.730Z [out]
    2022-07-24T22:02:22.730Z [out] > @serialport/bindings-cpp@10.7.0 install /root/.node-red/node_modules/@serialport/bindings-cpp
    2022-07-24T22:02:22.730Z [out] > node-gyp-build
    2022-07-24T22:02:22.730Z [out]
    2022-07-24T22:03:08.526Z [err] gyp
    2022-07-24T22:03:08.540Z [err] ERR! UNCAUGHT EXCEPTION
    2022-07-24T22:03:08.542Z [err] gyp
    2022-07-24T22:03:08.544Z [err]
    2022-07-24T22:03:08.546Z [err] ERR!
    2022-07-24T22:03:08.550Z [err] stack TypeError: Object.fromEntries is not a function
    2022-07-24T22:03:08.552Z [err] gyp
    2022-07-24T22:03:08.556Z [err] ERR! stack at Object.<anonymous> (/usr/lib/node_modules/node-gyp/node_modules/@npmcli/fs/lib/fs.js:6:23)
    2022-07-24T22:03:08.556Z [err] gyp
    2022-07-24T22:03:08.558Z [err]
    2022-07-24T22:03:08.560Z [err] ERR!
    2022-07-24T22:03:08.570Z [err] stack at Module._compile (module.js:652:30)
    2022-07-24T22:03:08.570Z [err] gyp ERR! stack at Object.Module._extensions..js (module.js:663:10)
    2022-07-24T22:03:08.570Z [err] gyp ERR! stack at Module.load (module.js:565:32)
    2022-07-24T22:03:08.570Z [err] gyp
    2022-07-24T22:03:08.572Z [err]
    2022-07-24T22:03:08.574Z [err] ERR!
    2022-07-24T22:03:08.576Z [err]
    2022-07-24T22:03:08.591Z [err] stack at tryModuleLoad (module.js:505:12)
    2022-07-24T22:03:08.591Z [err] gyp ERR! stack at Function.Module._load (module.js:497:3)
    2022-07-24T22:03:08.591Z [err] gyp ERR! stack at Module.require (module.js:596:17)
    2022-07-24T22:03:08.591Z [err] gyp ERR! stack at require (internal/module.js:11:18)
    2022-07-24T22:03:08.593Z [err] gyp
    2022-07-24T22:03:08.595Z [err]
    2022-07-24T22:03:08.598Z [err] ERR!
    2022-07-24T22:03:08.601Z [err] stack
    2022-07-24T22:03:08.610Z [err] at Object.<anonymous> (/usr/lib/node_modules/node-gyp/node_modules/@npmcli/fs/lib/index.js:2:6)
    2022-07-24T22:03:08.610Z [err] gyp ERR! stack at Module._compile (module.js:652:30)
    2022-07-24T22:03:08.610Z [err] gyp
    2022-07-24T22:03:08.612Z [err] ERR!
    2022-07-24T22:03:08.614Z [err]
    2022-07-24T22:03:08.616Z [err] System
    2022-07-24T22:03:08.630Z [err] Linux 4.14.81
    2022-07-24T22:03:08.630Z [err] gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    2022-07-24T22:03:08.630Z [err] gyp ERR! cwd /root/.node-red/node_modules/@serialport/bindings-cpp
    2022-07-24T22:03:08.630Z [err] gyp ERR! node -v v8.10.0
    2022-07-24T22:03:08.630Z [err] gyp
    2022-07-24T22:03:08.632Z [err]
    2022-07-24T22:03:08.634Z [err] ERR!
    2022-07-24T22:03:08.636Z [err]
    2022-07-24T22:03:08.646Z [err] node-gyp -v v9.1.0
    2022-07-24T22:03:08.646Z [err] gyp ERR! Node-gyp failed to build your package.
    2022-07-24T22:03:08.646Z [err] gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
    2022-07-24T22:03:10.401Z [err] npm
    2022-07-24T22:03:10.403Z [err]
    2022-07-24T22:03:10.406Z [err] ERR!
    2022-07-24T22:03:10.410Z [err] code ELIFECYCLE
    2022-07-24T22:03:10.415Z [err] npm
    2022-07-24T22:03:10.417Z [err]
    2022-07-24T22:03:10.420Z [err] ERR!
    2022-07-24T22:03:10.422Z [err]
    2022-07-24T22:03:10.430Z [err] errno 7
    2022-07-24T22:03:10.446Z [err] npm
    2022-07-24T22:03:10.449Z [err]
    2022-07-24T22:03:10.451Z [err] ERR!
    2022-07-24T22:03:10.460Z [err] @serialport/bindings-cpp@10.7.0 install: node-gyp-build
    2022-07-24T22:03:10.460Z [err] npm ERR! Exit status 7
    2022-07-24T22:03:10.470Z [err] npm ERR!
    2022-07-24T22:03:10.470Z [err] npm ERR! Failed at the @serialport/bindings-cpp@10.7.0 install script.
    2022-07-24T22:03:10.470Z [err] npm ERR!
    2022-07-24T22:03:10.472Z [err] This is probably not a problem with npm. There is likely additional logging output above.
    2022-07-24T22:03:10.593Z [err]
    2022-07-24T22:03:10.597Z [err] npm
    2022-07-24T22:03:10.602Z [err] ERR! A complete log of this run can be found in:
    2022-07-24T22:03:10.602Z [err] npm ERR! /.npm/_logs/2022-07-24T22_03_10_537Z-debug.log
    2022-07-24T22:03:10.644Z rc=7



Looks like your connection to Community was lost, please wait while we try to reconnect.