HX711 ADC Node or Arduino Serial In Help

Hello! I’m working to build a first raspberry pi project measuring weight using a strain gage and HX711 chip. There’s a number of resources available online, and I’m able to read in the values with a python script today.

I’d like to use the dashboard features in Node-Red as well as the visual programming features offered in this environment. It looks like there are a few ADC nodes avaialble now, but none of them seem to work with the HX711.

I did use the python shell node to interact with the script I was using. This worked, but brought the system to a crawl with 100% cpu utilization and very very low refresh rates.

Does anyone have experience interfacing with this chip? Is there something I’m missing?

I also used the GPIO input node without much success. Any help is appreciated.

As an addendum...

The python script that works with the HX711 along with the interface library was taken from here:

Update: I'm trying a new approach. I've been able to connect an arduino to the sensor and get realtime data output over the serial connection.

The data is visible in the Arduino IDE through the serial monitor. I'd like to feed this data into node-red but get the below error when trying to use the serial in node.

"serial port /dev/ttyACM0 error: Error: Error Resource temporarily unavailable Cannot lock port"

See attached screenshot for additional setup details.

You need to make sure the Arduino IDE is shut down… only one application can talk the the serial port at one time as it will grab/lock it.

dceejay - thanks for the reply.

I was able to achieve some success by unplugging and replugging the arduino after node-red was initialized. Even performing a

sudo apt-get remove arduino

didn't allow for initialization of the arduino on this port. Do you know if there's a way to see what process has current lock on the port?

Follow-up question... now that I'm reading data in I'd like to have a scaling factor on the UI to make the data meaningful. I've been able to scale and send to a gage on the UI but the gage doesn't appear to move correctly with the input data. The numbers update but needle and color doesn't change. See screenshot.

My node-red code is shown below.

[{"id":"30dbbd28.058392","type":"serial in","z":"35ffcac2.987306","name":"","serial":"52a6404b.fbe1f","x":119,"y":136.00000190734863,"wires":[["2ee5e003.0e98c","5af18179.fcd98","bf9788a4.24c078"]]},{"id":"2ee5e003.0e98c","type":"ui_gauge","z":"35ffcac2.987306","name":"","group":"f832cd52.75118","order":1,"width":0,"height":0,"gtype":"gage","title":"Current Sensor Reading","label":"mV/V","format":"{{value | number:5}}","min":"-1","max":"1","colors":["#ff0000","#00ff00","#ff0000"],"seg1":"","seg2":"","x":618.0999908447266,"y":59.787503242492676,"wires":},{"id":"5af18179.fcd98","type":"file","z":"35ffcac2.987306","name":"Write TorqueData to File","filename":"TorqueDataNodeRed","appendNewline":true,"createDir":false,"overwriteFile":"false","x":619.1000442504883,"y":174.20000648498535,"wires":},{"id":"90ae52d4.f1ac9","type":"function","z":"35ffcac2.987306","name":"Store Data As 'scalefactor'","func":"global.set("scalefactor", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":564.1000518798828,"y":578.3999860286713,"wires":[]},{"id":"404d1da7.4d3994","type":"ui_numeric","z":"35ffcac2.987306","name":"","label":"Torque Scaling Factor","group":"9a796473.dd45f8","order":1,"width":0,"height":0,"passthru":true,"topic":"","format":"{{value}}","min":"-50000","max":"50000","step":1,"x":183.16665649414062,"y":560.5555856227875,"wires":[["90ae52d4.f1ac9"]]},{"id":"bf9788a4.24c078","type":"function","z":"35ffcac2.987306","name":"Scaled Data","func":"var output = global.get ("scalefactor")*msg.payload\nmsg.payload = output;\nreturn msg;","outputs":1,"noerr":0,"x":500.1666717529297,"y":332.55558490753174,"wires":[["ebc5697e.fbe708"]]},{"id":"ebc5697e.fbe708","type":"ui_gauge","z":"35ffcac2.987306","name":"","group":"8e2fb3e7.a1a1a","order":0,"width":0,"height":0,"gtype":"gage","title":"System Torque","label":"lb-ft","format":"{{value|number:0}}","min":"-5000","max":"5000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":871.1666717529297,"y":285.1111135482788,"wires":},{"id":"52a6404b.fbe1f","type":"serial-port","z":"","serialport":"/dev/ttyACM0","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\n","bin":"false","out":"char","addchar":false},{"id":"f832cd52.75118","type":"ui_group","z":"","name":"Raw System Data","tab":"687596ee.ce9f08","order":4,"disp":true,"width":"6","collapse":false},{"id":"9a796473.dd45f8","type":"ui_group","z":"","name":"User Input","tab":"687596ee.ce9f08","order":2,"disp":true,"width":"6","collapse":false},{"id":"8e2fb3e7.a1a1a","type":"ui_group","z":"","name":"Realtime System Data","tab":"687596ee.ce9f08","disp":true,"width":"6","collapse":false},{"id":"687596ee.ce9f08","type":"ui_tab","z":"","name":"Bennington Wastewater RBC #5","icon":"dashboard"}]

Well in your initial screen shot I can see two tabs that are the Arduino IDE running. so I would guess that had grabbed it in the first place… both need to be closed.

If you were using the Arduino nodes you may need to remove some old config nodes - under menu (top right three bars) - Configuration nodes - select unused. If there are any then double click each - then top left button - delete) - redeploy.

Look at the range node that can rescale a range of numbers for you.

dceejay, you're a miracle worker. The serial connection problem I was having wasn't the arduino IDE, it looks like it was the arduino nodes locking the connection before the serial connection did.

I'm still having a problem with the output gauge on the scaled data not moving with the input data (per screenshot 2 "system torque"). Any ideas here?

I may move to the range node if I can't figure this gauge out, but was hoping to have a scale factor on the UI to adjust on-the-fly.

EDIT: I used a smooth node to round the data coming in to the gauge rather than using the gauge {{value | number:0}} to round display data and got the desired operation out of the gauge. Only changing to the range node vs using the function to scale with the UI input did not change the gauge operating characteristic.

Hey, sorry to drag up an old post but I am trying to doing the same as you have achieved. I have an arduino running a HX711 chip, with one loadcell. I'm outputting to the serial monitor & an LCD display no dramas.

My problem is I can't get my serial node to talk to my arudino . If I try firmatastandard example sketch I am able to connect & communicate through node Red and control my pins, but when i try including libraries of firmata in my sketch I am unable to communicate to Node Red.

Was wondering if you had any thoughts or maybe a copy of you arudino sketch to see where I've gone wrong?

Cheers.

If your sketch is just using Serial just fine, then use the serial nodes in Nide-RED, no need for the arduino nodes or Firmata..

1 Like

Yeah! I was hoping it was supposed to be that simple but just hasnt been working for me. I now realise im getting some error messages coming through my command prompt.

Any Ideas? Nothing else is using the Com port & Arduino IDE is closed.

it looks like you still have an arduino config node in there. You should delete that as well.

1 Like

After a little bit of research I had to delete the user directy and start again, that was the only way to get the serial node talking. Cheers for the help!