• WORK
  • CONTACT
JC Ehle
  • WORK
  • CONTACT

Sensing weight with Raspberry Pi

Overview

For the weight sensing project I started experimenting with the SEN-10245 mainly due to its price point - $9.95 per unit.  The current setup uses two of these units to form a complete wheatstone bridge so current cost for weight measurement would come in around $20 per board. 

The load sensor I am testing next to a US Quarter and a Limey 10 p coin for scale reference.  Weight is calculated by placing a load on the plate and measuring the change in resistance.

The load sensor I am testing next to a US Quarter and a Limey 10 p coin for scale reference.  Weight is calculated by placing a load on the plate and measuring the change in resistance.

To create the circuit to get meaningful data back into the raspberry pi requires a few steps.  As the changes in resistance are tiny, the signal from the sensor must first be amplified - I am using the AD620AN  ( datasheet ) and use a 50Ω resistor to set the gain to 1000.  After the signal is amplified it then needs to be sent to an A/D converter before we can read it back into the Pi.  Currently we are using the MCP3008 ( datasheet ).

The weight-sensing circuit.  Pictured is the Pi cobbler, the op-amp, and the A/D converter. 

The weight-sensing circuit.  Pictured is the Pi cobbler, the op-amp, and the A/D converter. 

Once the circuit is in place, we can begin calibrating the sensor and taking measurements:

The weight is placed on the sensor on top of an analog scale.  We can see the current load on the sensor is about 9 lbs. 

The weight is placed on the sensor on top of an analog scale.  We can see the current load on the sensor is about 9 lbs. 

Highlighted in yellow we can see the Pi calculates the current load at 8.7 lbs - very close to the analog scale reading

Highlighted in yellow we can see the Pi calculates the current load at 8.7 lbs - very close to the analog scale reading

So there we have it!  Reading weight with the Raspberry Pi. 

Next steps

I've learned quite a bit through this process and am happy with the results so far, however it must be said this current approach may not be the best solution.  There are quite a few issues with taking weight measurements that have come to light in this process:

  • Temperature compensation - I have read many places and noticed in my own research that the readings from these sensors are prone to "drift" due to changes in temperature.  This means that the same weight reading taken at different times of the day (i.e. different temperatures) can be inconsistent; my initial testing has seen up to 6lbs difference!
  • Mounting the sensor - in order for the readings to be consistent, the load must be placed squarely on the sensor plate.  The form factor of the sensor might make this a little tricky.
  • Constant strain drift - when these sensors are placed under constant load/strain the readings will drift - something in the neighborhood of a few percentage points of the weight every half hour.   It may be worth experimenting with better sensors.  The current ones are the cheapest on the market.

Despite these issues, I think its good to press on.  The next steps is to tidy up all of the sensor code I have then start to write the logging software in order to keep track of our readings.  I will also start looking to design a prototype PCB so all the circuitry can come off the breadboard and go onto a custom PCB. 

tags: raspberry pi, GPIO, weight
categories: raspberry pi
Wednesday 10.16.13
Posted by jc ehle
Comments: 26
 

Bee box - audio analysis + wieght sensing

Audio Recording

As I learned from the last test, the mic I was using was adding lots of noise/distortion to the recorded sample so the first step was to try and clear that up by trying a different mic.  I ended up going with the Logitech Labtech 600

mic.jpg

We'll need to find cheaper alternative somewhere down the road but for initial tests this is a good option. As soon as I ran a few tests with this mic through the Pi's sound card I immediately started getting cleaner sounding recordings. 

Audio Analysis

The next step was trying to figure out if there is a easy way on the Pi to run audio analysis on board to save the hassle of uploading audio clips to a server then processing them there.  After looking around I found a neat little C library called aubio that says one of its main functions is pitch detection in audio clips.  In order to test I hacked an openFrameworks app that lets me change the frequency on a tone generator:  

tone-generator.jpg

Once this was up and running, I can play this tone on my laptop, put the mic from the Pi next to the laptop's speakers and record a 5-second sample, then run the pitch detection software on the resulting loop.  After doing several different tests at different frequencies I'm pretty satisfied with the accuracy; here is the result of running the pitch detection on a .wav that was recording a tone at 1218 Hz: 

A recorded 1218Hz sample is detected to be: 1217.92988804 Hz (highlighted yellow) - very accurate!

A recorded 1218Hz sample is detected to be: 1217.92988804 Hz (highlighted yellow) - very accurate!

Weight Sensing

This still needs a bit of work: I've played around with a few different components and finally settled on a few that I think will work.  I still need to get the output of this circuit back into the Pi and write software that will translate the A/D signal into pounds/kilos.  I hope to have some time soon to get to that, but in the meantime here are a couple of shots:

 

Circuit w/ op-amp measuring analog voltage difference on weight sensor

Circuit w/ op-amp measuring analog voltage difference on weight sensor

Circuit with weight sensor on scale to record reference points of analog voltage

Circuit with weight sensor on scale to record reference points of analog voltage

Now the circuit has the A/D converter integrated... need to take output from this back into Pi

Now the circuit has the A/D converter integrated... need to take output from this back into Pi

So that's where we are at for now... hopefully I'll get some time soon to take this further! 

Saturday 09.21.13
Posted by jc ehle
Comments: 1