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"}]