Introduction: Internet Connected Scale
Imagine if you never had to worry about running out of your favorite things, because a new package of them would arrive just before you did!
That's the idea of NeverOut - the internet connected scale. Store something on it and never run out, because the cloud knows how much you have.
You will need:
Intel Edison & Grove Starter Kit Plus
Digital scale (the one shown is a $15 digital kitchen scale from Walmart)
Dual or quad rail-to-rail opamp (recommend the [MCP617](http://www.digikey.com/product-detail/en/microchip-technology/MCP617-I%2FP/MCP617-I%2FP-ND/319485), pictures show TLV2374).
Two 10k, two 1k, one 100 ohm resistors.
Solderless breadboard
Wires
Strongly recommended:
Soldering iron, solder
Hot glue gun
Perfboard
Step 1: Set Up the Edison and Peripherals
Follow this tutorial to set up the Eclipse IDE for the Edison, if you haven't already.
Plug the Edison into the Edison Arduino breakout board, the Grove breakout board into that, and the Grove LCD-RGB Backlight into one of the connectors marked I2C.
Create a new project in eclipse called adc_test.
In the IoT Sensor Support tab on the right check Displays->i2clcd
adc_test.cpp:
#include <jhd1313m1.h> #include <mraa.hpp> #include <sstream> #include <iomanip> int main() { upm::Jhd1313m1 display(0); mraa::Aio a0(0), a1(1); std::stringstream ss; while (1) { ss.str(""); display.setCursor(0, 0); ss << "a0: " << std::fixed << std::setprecision(4) << a0.readFloat(); display.write(ss.str()); ss.str("");
display.setCursor(1, 0); ss << "a1: " << std::fixed << std::setprecision(4) << a1.readFloat(); display.write(ss.str()); } return 0; }
Plug the potentiometer ("Rotary Angle Sensor ") into connector A0. Run adc_test. You should see the ADC value change on the display as you turn the potentiometer.
Step 2: Hack the Scale
Unscrew the back of the scale to reveal the contents.
This scale has four load cells. A load cell is a combination of strain gauges and a cantilever structure which works as a force sensor.
Load cells come in a few varieties. This scale has half bridge (resistor divider) load cells.
Each load cell has three wires top (red) middle (white) and bottom (black).
Cut the wires from the load cells and strip the insulation. We're only going to use two of the load cells.
Solder on wires to go to the amplifier (next step). Connect red from one cell to black from the other and vice versa, to "flip" one cell's signal.
Hot glue the wires down thoroughly for strain relief. All the bending and pulling you'll do while setting it up can easily break these tiny wires.
Step 3: Build an Instrumentation Amplifier
This is only using two of the load cells from the scale. Not sure if paralleling the other two would cause problems. You'll want A to increase in voltage when weight increases and B to decrease. Depending on the scale you got, this might mean using one of the load cells backwards (black to red and red to black).
You need to use a rail-to-rail opamp here (one that works on 5V). I recommend the MCP617. AREF comes from the Edison arduino compatible board.
This is a 2 opamp instrumentation amplifier. You can read a bit about it on page 9 of this pdf.
I strongly recommend constructing this on a perfboard and soldering it together. Then you can use stranded wire which is less likely to break.
Step 4: Hook It All Together
Connect the output of two load cells to the + and - inputs of the instrumentation amplifier
Connect power and ground for the load cells and instrumentation amplifier and VREF to the amplifier.
Fire up the adc test program. You see the ADC value change when you press on the load cells. Use this to make sure the polarity of the cells is set up right so that they don't cancel each other out.
Record the ADC value with nothing on the scale, then put an object of known weight on the scale and record that value. I used a 2L soda bottle and assumed it weighed 2kg.
Now set up the actual software. You should be able to get http://github.com/mdejean/NeverOut/ and open it with Eclipse.
Edit Scale.cpp line 22 with the two ADC values (0.51, 0.562) and the known weight in grams (2000g)
`int grams = (raw - 0.51) * 2000.0 / (0.562 - 0.51);`
Step 5: Connect It to the Cloud
NeverOut was written in less than a day for a hackathon, so it's cloud features are pretty sparse. `CloudConnection.cpp` just runs `wget` to send data points (by accessing a URL). In `CloudConfig.h` you can set the base URL it will use.
https://github.com/paulcdejean/neverout-backend is a simple [Heroku](http://heroku.com) app that displays a graph of the past values using [Bokeh](http://bokeh.pydata.org/en/latest/)