Tag Archives: Arduino

Dog Water Bowl Scale, Part 3: Final assembly and installation

In my previous post, I covered the mechanical construction of the scale. In this post, I finish assembling the scale, calibrating it, and installing it.

After painting I put feet on the scale so it won’t soak in water spilled on the floor.

Adding feet to the scale
Adding feet to the scale

…then bolted the Arduino 101, Load Cell, and Load Cell Amplifier to the bottom plate. Continue reading Dog Water Bowl Scale, Part 3: Final assembly and installation

Dog Water Bowl Scale, part 1: initial design work

Now that my Dog Bed Weight Scale is sending data, I’m going to have a go at a water bowl scale. The idea is that, like the bed, the bowl will periodically send its weight to a cloud. This data should tell me when Pippa drinks, when we refill her bowl, and (maybe) how much she drinks.

The work-in-progress sources on Github, contain the beginnings of the Arduino 101 Sketch, Bill of Materials (Parts List), mechanical design/construction details, and a day-by-day project diary. Continue reading Dog Water Bowl Scale, part 1: initial design work

Dog Weight Scale Part 9: Soldering the V2 circuit together

In my previous post I described how to use long break-away headers, and started soldering the circuit together.  In this post I finish transferring the scale circuit from the breadboard to a protoboard, and do a quick test mount of the circuit on the plywood scale base.

A reminder: I found that the Load Cell Amplifier was (by design) so sensitive to changes in resistance that just touching the resistors on my solderless breadboard caused large changes in the Amplifier output.  So I wanted to solder all the parts down.

I’m generally terrible at soldering on protoboards, so I tried out one of Sparkfun’s Solder-able Breadboards.  This board has internal connections that copy those of a solderless breadboard, making it easy to transfer your circuit from a solderless breadboard to this Solder-able Breadboard, without redesigning the layout and without having to solder two wires together – everything is soldering one wire into one hole.

Ready to solder more of the circuit
Ready to solder more of the circuit

In almost no time, I had transferred the half Wheatstone bridge per Load Sensor to the board, and soldered the wires, resistors, Load Sensor connectors, and Load Cell Amplifier connectors in place.

The completed, soldered circuit
The completed, soldered circuit

Once I had everything soldered together, I plugged in the whole circuit and (temporarily – that’s another story) mounted the parts to the plywood bottom part of the scale.

The scale circuit temporarily mounted to the plywood base
The scale circuit temporarily mounted to the plywood base

You can see in the above circuit the four Load Cell Amplifier board (the small red boards), one per Load Sensor, the protoboard in the center, and the Arduino. Each Load Sensor is also plugged into the protoboard.  Compare this picture to the one of the solderless breadboard in my previous post – it’s very, very similar.

In my next post, I 3d-print a Load Sensor holder.

Dog Weight Scale Part 8: Electronics, version 2

It’s a good time to recap: This project is a scale that will sit underneath my dog Pippa’s bed, so that I can measure her weight automatically, at night while she sleeps.  The project-in-progress is Open Source, at my CurieBLEWeightMonitor Github repository.  I occasionally tweet about it (among other things) as @bneedhamia.

In my previous post I covered how to choose matching resistors for the Load Sensor to convert the Load Sensor into a Load Cell that can be wired into Sparkfun’s Load Cell Amplifier.  In this post, I nearly finish building the breadboarded circuit and start transferring it to a soldered protoboard.

It’s probably worth saying a word about Long Break-Away Headers. These headers are longer than regular ones, and are great for plugging connectors into connectors and (for this project) plugging connectors into a solderless breadboard.  Standard length headers are designed to be soldered in, and aren’t long enough to use in solderless breadboards or to attach connectors to Arduino I/O pins.

Step 1: snap off the number of pins you need for the connector.  For example, I’m using a lot of 4-pin Molex connectors, so I use a pair of needle-nose pliers to snap off a set of 4 pins.

I snapped off 4 pins for a connector
I snapped off 4 pins for a connector

Step 2: The plastic separator needs to be centered on the length of the pins. An easy way to do this is to plug the long ends of the pins into a breadboard, then use needle-nose pliers to press the plastic part down to the surface of the breadboard.  The plastic is often stiff, so I hold the pliers with one hand and press the tip of the pliers down with my thumb, using strong, even pressure (don’t bend the pins).

Ready to press the plastic part down to the surface of the breadboard
Ready to press the plastic part down to the surface of the breadboard
I've used the pliers to press the plastic part down to the level of the breadboard
I’ve used the pliers to press the plastic part down to the level of the breadboard

Once this is done, the header’s plastic separator is close to half way along the length of the connector, and the pins are ready to be plugged into a connector.

showing how the plastic is now near the middle of the pin length. Perfect!
showing how the plastic is now near the middle of the pin length. Perfect!

Meanwhile, I’ve finished everything on the breadboarded scale circuit except choosing the final pair of matching resistors.  It’s all going well. In the picture below you can see the four Load Cell Amplifier boards (the small rectangular boards), the 3-pin connectors for each of the Load Sensors, and of course, the Arduino.

The breadboarded circuit is nearly complete
The breadboarded circuit is nearly complete

Earlier I’d noticed that the breadboarded circuit tends to drift: small changes in the mechanics of the circuit (like touching a resistor) make significant changes in the measured Load Cell Amplifiers’ outputs, which might affect the measured weight from the scale.

I found Sparkfun sells the perfect thing for me: a solderable breadboard.  It has the same mechanical layout and electrical connections as a standard  half-sized solderless breadboard,   So it’s easy to transfer a circuit from a breadboard to the protoboard, and solder all the parts down.  It’s especially nice for me because my protoboard connection skills are terrible: my protoboard circuits usually look like a mess, and are very difficult for me to wire up.

At any rate, I’ve transferred the first Load Sensor circuit to the protoboard and soldered it together – it works great!

I've transferred one of four load sensor circuits to the protoboard
I’ve transferred one of four load sensor circuits to the protoboard

In my next post, I solder the rest of the scale circuit to the protoboard and test-mount it onto the plywood base.

Dog Weight Scale Part 7: Choosing Matching Resistors

In my previous post, I worked through the calculations of weight and center of gravity when using four Load Cell Amplifiers instead of one.  In this post, I build the circuit for the first of the four Load Sensor / Load Cell Amplifier combinations I’ll be using.

The Sparkfun Load Cell Amplifier is designed to connect a Load Cell to an Arduino.  A Load Cell contains a full (4 resistor) Wheatstone Bridge, but a Load Sensor contains only half of a Wheatstone bridge.  To connect a Load Sensor to a Load Cell Amplifier, I need to add two resistors: R3 and R4 in the following diagram.  The dotted box represents the Load Sensor. The triangle in the middle of the diagram represents the Load Cell Amplifier.  As the weight on the Load Sensor increases, R1 decreases, which causes the voltage V1 to increase, causing the digitized amplifier output to increase.

A Load Sensor paired with two external resistors
A Load Sensor paired with two external resistors

Once I’d built the circuit, the next task was to find the right pair of resistors, R3 and R4. In the photo below, R3 and R4 are the two resistors at the left; the Load Cell Amplifier is the small red board in the center, and of course the Arduino is on the right.

The breadboard of one Load Sensor plus Amplifier
The breadboard of one Load Sensor plus Amplifier

R3 and R4 need to have a ratio that is close to the ratio of the two (matched) resistors that are in the corresponding Load Sensor, so that the digitized voltage difference, V1 and V2 in the above schematic, is near zero.

The tricky part is that a normal multimeter shows that the two resistors of the Load Sensor are equal, and that R1, above, changes by only an ohm or so with pressure.  That multimeter isn’t accurate enough to show the differences in resistance that you need to measure.

So either you can buy a high-precision multimeter (expensive), or you can use the Load Cell Amplifier to measure the resistances. I decided the use the Amplifier.

I ordered a bunch of 1Kohm, 0.1% resistors.  Then I picked 4 of them (I could have used more, but that’s more work), labeled them A, B, C, and D, then started measuring the ADC values of various pairings of those resistors.

Measuring the results of using various pairings of resistors
Measuring the results of using various pairings of resistors

First I removed the two resistors and connected S+ to S-, (V1 to V2 in the schematic above) to give the ADC a 0V value.  I then measured the ADC output. It was 5720, so 5720 corresponds to 0V difference between V1 and V2 in the schematic above. That number is the 0V goal: I want to choose a pair of resistors that produces an ADC value that’s closest to 0V.

So I disconnected V1 from V2, plugged in a pair of resistors (say, A = R3 and B = R4) and read the raw value from the HX711 library, via hx711.read().

After a few tests I found that C = R3 and D = R4 produced an ADC value of -29993.  That value was the one that was a) negative and b) closest to the 0V value of 5720. Even though -29,993 is much bigger (in absolute value)  than 5,720, the other combinations produced values 10 times that of the C and D combination.

I wanted a negative number, to give more range for the Load Sensor.  As the weight on the Load Sensor increases, the voltage read by the Load Sensor Amplifier increases, so starting from a slightly negative voltage gives the amplifier more range than if you started from a slightly positive voltage.  I’m still not quite sure whether the ideal zero-weight offset would be 0V, or some slightly negative voltage.

In my next post, I show the progress of the circuit so far, show how to use Long Break-Away Headers, and start transferring the circuit to a soldered protoboard.

 

Dog Weight Scale Part 4: Calibration and its difficulties

Calibrating the scale using exercise weights
Calibrating the scale using exercise weights

In my previous post I finished assembling the Dog Bed Weight Scale, at least enough to allow testing it. In this post, I relate how I calibrated and tested it.

Using the Bogde HX711 Load Cell Amplifier library and examples, and the Sparkfun HX711 Example Arduino Sketches, I quickly wrote a little Sketch to output the raw value from the scale (SCALE = 1.0 and OFFSET = 0L).  The library made talking to the HX711 trivial.

The HX711 library assumes a linear relationship of load sensor output to weight.  Using small exercise weights, I measured the average output for 5, 10, 15, 20, and 25 pounds. I’m using Pounds for the moment for my convenience; once all this works, I’ll switch to kg.

X Weight (lbs) Y Average reading
5 314463.125
10 368162.167
15 422683.000
20 477253.222
25 531089.727

Now for a little Algebra: the formula for a line is Y = MX + B, where M is the slope of the line and B is the intercept.  Put in terms of the HX711 library, M is the SCALE and B is the OFFSET.   Given two (X, Y) pairs, you can calculate the slope and intercept of the line:

M = (Y2 – Y1) / (X2 – X1)

B = Y – MX                      (using the M value calculated above)

I calculated M and B using the 5 and 10 lbs weights, the 10 and 15 lbs weights, etc.  I then averaged the M values and the B values, resulting in

M = 10831.330         B = 260248.752

So I plugged in the M value via hx711.set_scale() and the B value (rounded to an integer) via hx711.set_offset(). Impressively, my scale now reported in lbs; math works!

Next I wanted to check how linear the output was.

Because each sensor can take up to 50kg (about 110 lbs) and there are 4 sensors, the sensors (but not the plywood) can take a combined weight of 200kg (about 440 lbs).

I weighed myself on my bathroom scale (264.1 lbs) and stood in the center of my new Dog Scale (266.063 lbs).  If the scale were perfectly linear, and the calibration numbers were exactly correct, I should have weighed the same on the Dog scale as on the bathroom scale.  Instead, the Dog Scale weighed 0.7% high relative to the bathroom scale.  For our 44 lb dog, Pippa, that percentage would be about 1/3 lb (or about 150g), which isn’t too bad.

Another measurement I made was short-term noise.  I made 24 measurements of a zero weight and calculated the Standard Deviation.  3 Standard Deviations covers a good amount of the range of noise; for this measurement 3 Standard Deviations = 0.007 lbs.  That tells me that most of the time a single measurement will be +/-0.007 lbs from the average, which means that I don’t really have to average multiple readings to get a good measure (but I probably will anyway, just to be safe).

I also measured creep: the slow change in the reading of a constant weight over a long time. I don’t know much about creep, but Nate Seidle’s Beehive scale article talks about it in detail.  To measure it, I placed 25 lbs on the scale and left it for 2 days.  What began as 25.122 lbs ended up reading as 24.917 lbs, a creep of about 0.8%, with no sign of stopping.  So I should expect some creep during the 8-12 hours that Pippa might spend in bed.

Unlike a beehive, Pippa will shift about in her bed, sometimes lying near one edge, sometimes near another edge, and sometimes in the center.  To test how matched the load sensors are, I measured a 15 lb weight in the center of the scale and directly over each of the 4 sensors.

Measured weight of a 15 lb weight at the center and over each sensor
14.861
14.721
14.513
14.912
15.239

So Pippa’s measured weight could vary from reality by as much as 0.7 lbs depending only on her position in her bed.  That’s too much for what I want to do.

Unfortunately, I can’t correct for mismatch in the individual load sensors’ response curves.  The 4 sensors are wired together in one Wheatstone bridge, and calibration happens on the amplified output of that bridge.

I want to redesign the scale to have each load sensor connected to a separate amplifier and separate pins on the Arduino, so I can get a more accurate measure of Pippa’s weight as she shifts around on her bed.  Interestingly, that change will also enable the Arduino to calculate where Pippa is lying in the bed – that is, where her center of gravity is – which might be interesting information.

In my next post, I find the center of gravity of the top plywood piece, and attempt a way to mount the Load Sensors to the bottom plywood piece.

Dog Weight Scale part 3: the woodworking and assembly

In my previous post I described the electronics of the Dog Bed Weight Scale. In this post, I’m doing the final woodworking and assembly – at least enough assembly to test the thing.

First I needed to design some sort of support for the load sensors.  Because of the design of the sensor – a “T” bar surrounded by a “C” shaped bar – I needed to make blocks that were 1) tall enough to keep the top piece of plywood from resting on or crushing the electronics and 2) cut out to allow the “T bar to bend below the “C” shaped part as weight was added.  You can find plenty of videos of people trying to use load sensors by mounting them on a flat surface; that won’t work.

So, to design the blocks, I first measured the dimensions of the load sensor, using a Caliper, then drew up a simple design from that.

Measuring a load sensor using a caliper
Measuring a load sensor using a caliper

Meanwhile, I drilled the mounting holes for the boards.  Because the plywood base is so large (~41″ in diameter), I couldn’t use the drill press.  So to make nicely perpendicular holes, I used a Drill Guide. I really like the one I use because it’s metal and it has a guide for each drill bit I use, creating nicely straight holes.

Because I was feeling a bit lazy, I didn’t measure and mark the holes for the electronics boards.  Instead I used the old “mark and drill” method.

Step 1: holding the board in place, drill just enough to mark the first hole – don’t drill deep.

Marking the first hole to drill
Marking the first hole to drill

Step 2: remove the board (so the drilling doesn’t damage it) and use a Drill Guide to complete the marked hole.

Drilling a vertical hole, using a drill guide
Drilling a vertical hole, using a drill guide

Step 3: Place the board back, drop the first bolt into the new hole, then mark the second hole as in step 1.  Repeat for all the board’s holes.

Marking the 3rd hole
Marking the 3rd hole

To prevent the bolts from sticking out from the bottom of the plywood, I chose 3/4″ bolts for 3/4″ plywood.  Because the bolts don’t stick out, I needed to counterbore the bottom of these holes so I can attach the nuts.  Again I couldn’t do this on the drill press, so I used a plunge router, set to bore just a little into the plywood.

Setting the router to counterbore holes
Setting the router to counterbore holes
Counterboring the mounting holes
Counterboring the mounting holes

Because the router bit I used has a space in the middle, the counterbore holes leave a little disk of wood, I used a chisel to clean out the remaining little disk of wood to make the counterbore flat.

Chiseling out the little disk of leftover wood
Chiseling out the little disk of leftover wood

Here’s what the 3 boards look like, fastened to the plywood base.

The boards mounted onto the plywood base
The boards mounted onto the plywood base
The back of the plywood base, showing the counterbored holes
The back of the plywood base, showing the counterbored holes

I then cut the blocks that will support the load sensors.  These are just temporary blocks, to let me test the circuit. The real blocks will (somehow) hold the load sensors in place and keep them from slipping from side to side.

The load sensor support blocks
The load sensor support blocks
Cutting slots with a scrollsaw
Cutting slots with a scrollsaw
The slot lets the sensor's "T" bar move
The slot lets the sensor’s “T” bar move

I chose the thickness of the blocks to make sure that the plywood top wouldn’t rest against or crush the electronics. See how the cross-section of the load sensor support block is taller than the circuitry.

The load sensor support block keeps the top plywood circle from crushing the electronics
The load sensor support block keeps the top plywood circle from crushing the electronics

I then cut out the top plywood circle. This circle will lay on top of the four load sensors.

The top circle of the scale
The top circle of the scale

For good measure, I placed Pippa’s bed on the top piece of plywood.  It’s a good fit.  Yes, that’s an Encyclopedia Britannica and a VCR in the cabinet…Pippa’s a Retro Girl (seriously, what can you do with old encyclopedias? I can’t bring myself to cut them up for papier mache).

Test-fitting the dog bed to the top plywood circle
Test-fitting the dog bed to the top plywood circle

I then assembled the whole thing and started testing.  Pippa helped.

The assembled base of the weight scale
The assembled base of the weight scale
Pippa resting on the assembled scale
Pippa resting on the assembled scale

In my next post, I get to try out the circuit and try to weigh some standard weights.

Dog Weight Scale, part 2: the electronics

As I said in the previous post, I’m using 4 Sparkfun load sensors, a Load Sensor Combinator board, a Load Cell Amplifier board, and an Arduino 101 to build a scale I can put under our dog’s bed, to passively weigh her whenever she’s in bed.

In the previous post, I cut the base for the scale from a sheet of plywood.  In this post, I’m assembling the circuit.

To begin with, the load sensors come with about 14″ of wire attached.  Because my scale has a 20″ radius, I need to solder more wire to each load sensor wire.  For convenience I used some (very) old CAT3 cable I have lying around. CAT3 cable was made for old phone lines, and has two twisted pairs of cables inside an insulating sleeve.

First, so you don’t forget, cut a length of heat-shrink tubing for each load sensor wire, and slip it over the wire. I admit I’ve soldered wires together in the past and too late discovered I didn’t add the heat shrink tubing before I soldered. Choose a tube diameter about twice the diameter of the wire you’re using.

Preparing to solder (note the heat shrink tubing is on the wire)
Preparing to solder (note the heat shrink tubing is on the wire)

I really like the gooseneck quad soldering tool here. It’s similar to Sparkfun’s Third Hand Kit.

You can look up how to solder wires together. The method I prefer is to hold the two wires in an “X” pattern, then wind each one around the other, then solder.  This gives a nice “in-line” solder.

Once the soldering is done, slide the piece of heat shrink tubing into place and heat it to form a nicely insulated connection. I like using a heat gun rather than messier things like a hair drier or matches.

Using a heat gun to shrink the heat-shrink tubing
Using a heat gun to shrink the heat-shrink tubing

Once the connections are done, it’s good to double-check the connections with a multimeter.  In this case, the Load Sensor’s White-to-Blue/Black resistance should be about twice the resistance between White and Red or Red and Blue/Black.

Double-checking that the connections are good
Double-checking that the connections are good

The Load Sensor board and Load Cell Amplifier board come without headers.  I like to connect everything with removable connections (like a header and plug) in case I need to replace or fix a part later. So the next step is to solder headers on all the connections of these two boards.

The boards as they come from Sparkfun
The boards as they come from Sparkfun
The same boards, with all the headers soldered in place
The same boards, with all the headers soldered in place

It turns out I didn’t need to put headers in for the side pins labeled GND, SIG, and 5V; those are for an optional temperature sensor.

The next step is to crimp Molex connectors onto the wires. I’m sure I’m not doing this like a pro, but it works well enough.

To start strip a small amount of insulation from the wire.

A stripped wire ready for the crimp connector
A stripped wire ready for the crimp connector

Then use crimping pliers to crush the crimp connector around the wire.  The outside crimp should grip the insulation of the wire; the inside crimp should grip the uninsulated wire.  I’ve recently switched from non-ergonomic pliers to crimping pliers that automatically release when you’ve pressed hard enough – old-style pliers can contribute to repetitive stress injuries, which you want to avoid.

Crimping the connector onto the wire
Crimping the connector onto the wire

With these pliers there are 3 wrong ways to crimp the connector, and one right way.  You may need to experiment to find which jaw to use (front or, as pictured, back) and which way the connector has to face (the left or, as pictured, right side of the pliers).

Once you have all the pins for a connector crimped onto their wires, it’s time to press the connectors into the shroud (the black plastic cover).  Line up each pin’s “barb” with the hole in the shroud so that once you slide the pin in a bit, it latches.

One connector with the three pins pushed to the first stop
One connector with the three pins pushed to the first stop

Once you have pushed all the pins to the first stop, you then can push them further to the second, final stop.  You may need to use needle nose pliers to push the end of the wire until each “barb” clicks into place. Having all the pins click into place means that they won’t pull out accidentally, and you have a nice, solid connector.

All the pins are pushed to the second 'click'
All the pins are pushed to the second ‘click’
The connector pushed into the corresponding header
The connector pushed into the corresponding header

You need to connect each load sensor to the Load Sensor Combinator board, the Combinator board to the Load Cell Amplifier board, and the Amplifier board to an Arduino.  I’m first using an Arduino Uno to get the weight measurement working before I switch to an Arduino 101.

The completed circuit
The completed circuit

At this point, I did a test layout of the circuit on the plywood base. I wanted to double-check that the Load Sensor wires were long enough before I started the mechanical work.

Testing that the circuit fits the plywood base correctly
Testing that the circuit fits the plywood base correctly

In my next post, I complete the assembly of the scale.

 

Detecting heart rate using an Arduino 101

I’ve finished an Arduino Pulse Sensor library based on Joel Murphy’s and Yury Gitman’s Pulse Sensor Amped Sketch. The library and example code running on an Arduino 101 communicates with Joel’s and Yury’s Processing Visualizer that graphs the pulse waveform.

The cool thing about this library and example code is that it runs on all sorts of Arduino compatibles without using ARM-specific Timer Interrupt setup code. So it runs on the Intel-based Arduino 101 “out of the box” as it were.

The code is at https://github.com/bneedhamia/PulseSensorBPM, and I’ve put a demo video on You Tube. Party On, Arduino 101!

Arduino 101 detecting pulse rate
Arduino 101 detecting pulse rate

The library can be used either with or without Interrupts.  The library example PulseLooper in github works on Arduino 101 and Arduino Uno, without using interrupts; the example PulseInterrupter uses ARM-specific interrupts and so runs only on ARM-based Arduinos such as the Uno.

Mounted the Lunar Clock opto-interrupter

In my last post about the Lunar Clock I described the opto-interrupter that will detect the slot in the lunar images disk. At that time I wasn’t sure how to mount the opto-interrupter to the strip that holds the stepper motor that turns the lunar images disk.

Recently I bought an angle bracket to mount the opto-interrupter.  Although it’s the smallest bracket I could find, it’s still pretty big, with holes that are far too large for my use.

the angle bracket holes are too large
the angle bracket holes are too large

So I used a hacksaw to cut one side of the angle bracket down to a size I could use.

hacksawing the angle bracket, using a board as a guide
hacksawing the angle bracket, using a board as a guide

Next I drilled new, smaller mounting holes the size of the short bolts I have used in the clock.

drilling the base mounting holes
drilling the base mounting holes
drilling the size hole that will connect to the opto-interrupter
drilling the size hole that will connect to the opto-interrupter

I then bolted the opto-interrupter to the bar of wood that holds the stepper motor.

Opto-interrupter fastened to the clock
Opto-interrupter fastened to the clock

Now it’s time to design the artwork that will be on the front of the clock.