Introduction: FluidTrakker Intro
We built a prototype of a fluid tracking sensor application. The prototype has three components:
1. A Tabletop sensor that tracks the weight of a bottle of water in grams and sends the data to the Intel Analytics cloud.
2. A portable sensor that also tracks the weight of a bottle of water in grams while it is in a sleeve.
The tabletop sensor uses the Intel Edison Dev Kit with HX711 weight sensor.
The portable sensor uses the HX711 weight sensor with a SparkFun kit with the Edison chip.
Step 1: Build the Pressure Plate Platform
For this step, you will need a HX711 load amp board a load cell, and a platform for the scale.
The HX711 can be acquired from Spark Fun: https://www.sparkfun.com/products/13230
The load cell is basically a metal bar with strain gauges to measure the stress and distortion from a force or "load". This is fed into the HX711 which converts the readings into a digital value. For this project, we chose the Seeed Studio 5kg load cell: http://www.seeedstudio.com/depot/Weight-Sensor-Loa... Four (4) M6 flat head machine screws are used to mount the load cell to the base and hold the presure plate.
The base can be a piece of plywood with holes for accepting the load cell. Nylon washers provide the spacing needed so that the load cell can float freely (e.g. cantilever design).
The pressure plate is placed on the top of the load cell with the appropriate spacers and held down with M6 screws.
Step 2: Hook Up the Load Amp
Connect the HX711 to the load amp per the the wiring hookup.
The instructions to hook it up can be found at Spark Fun: https://learn.sparkfun.com/tutorials/load-cell-amp...
In this project, I hooked up the wires as follows:
Load cell side:
- Red wire to RED on the HX711 board
- Black wire to BLK
- White wire to WHT
- Green wire to GRN
- Bare wire to YLW
Edison using Arduino breakout board
- 5V Power to VCC on the HX711 board
- Pin 3 to DAT
- Pin 2 to CLK
- Ground to GND
Step 3: Calibrate the Load Cell
Before you can used the load cell / load amp combo, you will need to first run on a program to calibrate the load cell.
Download the code and open the code in the Intel XDK IoT Edition (https://software.intel.com/en-us/intel-xdk). Then upload the code to the Edison using the XDK. Unlike other Node.js applications, you cannot run the calibration app using just the "play button" from the XDK as the app requires interactive keyboard input. However, the SSH Terminal in the XDK works fine.
The calibration app is designed for measuring grams, but it can be easily modified to support ounces. This is because the HX711 simply returns a 24-bit number and it is up to you to scale to the desired units.
- Remove all weights from the scale
- Logon to the Edison via the ssh terminal
- # cd to ~/.node_app_slot
- # node main.js
- Allow the calibration app to tare (zero out) the scale
- After a few readings, put a known weight on the scale (for example, a 500 ml water bottle)
- Press + or - on the keyboard to match the weight of the known weight
- Ctrl-C to exit
Once you have the calibration_factor, you can put the constant in your application.
There are a couple of things to be aware when using the calibration app:
- Once the scale is tared and there are no weights on the scale, the value returned may be a very large integer value, such as 4719744.5. This is because the jsupm_hx711 (version 0.6.2) stock library does not handle the sign bit to return negative numbers. Negative numbers are to be expected when the scale is around +/- 0.0 or you create a "negative weight" on the pressure plate.
- The scale may produce a few erroneous misreads when weight is put on the scale. An app should eliminate outliers and smooth the data.
Step 4: Develop the NodeJS Application
The next step is to develop a NodeJS application that reads the load cell and does something with it.
For the 4/23/2016 Denver IoT Hackathon, we chose to send the reading to the Intel IoT Analytics Cloud.
To setup the Intel IoT Analytics (Beta), follow the instructions in one or more of the following resources:
For the app, we created in the Iot Analytics a custom component called "scale.v1.0". The component is added to the Catalog ( Account -> Catalog -> Add Component).
A sample app that sends data to the Intel Iot Analytics cloud can be found on GitHub. See https://github.com/coloradocarlos/iotanalytics_hx7...
Step 5: Going Portable
The previous steps showed how to build a static weight scale.
But how about a portable, battery operated scale for an on-the-go application? One that fits in a hydration bottle sleeve?
To "go portable", gather a few more parts:
- Nalgene insulated bottle sleeve: https://www.rei.com/product/852426/nalgene-insulat...
- SparkFun Edison base block: https://www.sparkfun.com/products/13045
- SparkFun Edison GPIO block: https://www.sparkfun.com/products/13038
- SparkFun Edison battery block: https://www.sparkfun.com/products/13037
- SparkFun Edison hardware kit: https://www.sparkfun.com/products/13187
- Portable load cell based scale
The following steps show how to build a portable scale.
Step 6: Assembling the SparkFun Blocks
The SparkFun blocks snap together like Legos. We suggest reading the tutorials on the blocks at https://learn.sparkfun.com/tutorials/general-guide...
The order of the blocks are:
- Console block with Edison
- GPIO block
- Battery block
Care must be taken with the battery block. The power connectors to the 3.7 Li-Iom battery can potentially short other blocks which is why it is a good idea to put it under the GPIO block (also Kapton tape may help).
Hooking up the Edison using GPIO block:
- 3.3V Power to VCC on the HX711 board
- GP12 to DAT
- GP128 to CLK
- Ground to GND
Step 7: Making a Portable Scale
A small version of the scale can be easily built that can fit inside the Nalgene sleeve.
We removed a 5 kg load cell from a retail food scale purchased from a department store: http://www.amazon.com/Taylor-Stainless-Digital-Kit...
Then we used a Dremel tool to create 2 circular disks for the pressure plates using oak paneling purchased from a home improvement center.
After drilling offset counter-sink holes on our drill press, we created the classic cantilever "Z" configuration using washers, the load cell, and circular pressure plates.
See photo for details.
Step 8: Calibrating a Portable Scale
We will use the same calibration code used for the static scale, but there are a couple of changes. The first thing to change in the software is the GPIO pin mapping. Before we had an Arduino breakout board and used the pin numbering of the Arduino. With the SparkFun blocks, we will use the MRAA numbering.
Change the code to use MRAA:
Second, calibration should be performed over the wireless interface using a fully charged battery to minimize variation in the reads. As the battery begins to drain, the 3.3V power rail may not deliver enough power to the load amp to properly read the load cell. A little experimentation may be in order to determine if the on-battery vs. on-USB affects calibration.
Step 9: Final Assembly
Place the scale at the bottom of the Nalgene insulated sleeve and use tape to secure the wires to the sides.
The Edison blocks can be secured to the exterior of the sleeve using a clear plastic bag.
After loading the HX711 application onto the Edison, remember to allow the Edison to tare the scale at boot up. this means removing the bottle from the sleeve before starting up. As an alternative, the calibration code prints out a "zero factor" value that can be used for permanent scales where taring is not feasible. The Edison UPM code for the HX711 should be consulted on how to apply the zero factor.
We have a be nice policy.
Please be positive and constructive.