Suggestions on debouncing USB scale input

I’m building a shipping interface that uses a USB scale connected by WebHID. The WebHID code takes the scale weight and puts the value into a page data property.

I want to trigger a function to create a shipping label when weight is on the scale, but the weight needs to be constant. If the weight is still fluctuating as the person puts the package on the scale, the label will be incorrect.

I’m thinking about running a timer to see if the weight is the same over a sample time period, but I wanted to see if anyone had a better suggestion.

Thanks,
Tim

Hi. I think this is a client level task, not the server one. You have to continuously (e.g. in a cycle) read the values from the scales and process them locally (in browser in your case), and only after the weight is stable during some period of time (may be configured), the client send the value to the server.

Thanks, @oleg-vyalyh. That is what I do currently, and I wanted a sanity check.

I appreciate the help!

Tim

Hi @Tim_Jones ,

Your code looks good to me.

Regards, Andriy

1 Like

Thank you!

1 Like