Wireless Digital Scale

by jbike in Circuits > Arduino

13403 Views, 97 Favorites, 0 Comments

Wireless Digital Scale

20160514_090744.jpg
Hummingbird Scale

This scale is wireless. It may be useful where you can't operate a normal scale, due to the weather outside, or if you don't want to scare birds or other creatures away. With this scale you can weigh them. In this instructable, I used a 0 to 1 Kg load cell since I wanted to weigh hummingbirds and orioles that visited our nectar feeder. One end of the load cell was attached to the eaves, and the other end has a hook from which the support string for the feeder hangs. Many other load cells are available in different weight ranges, and they all can be hooked up the same way, the only difference being the zero factor and range factor which can be changed in the Arduino sketch.

Supplies Required

20160514_182428.jpg

The parts are all very low cost, but will take 4 to 5 weeks to arrive from China.


The remote end contains the load cell (0 to 1 Kg), the amplifier, an ATtiny85, and a HM-10 Bluetooth low energy transmitter/receiver slave. The display module contains: 2 x 16 line LCD, HM-10 configured as master, software latching on/off switch, buttons, toggle switches, USB battery bank, and an Arduino Pro Mini 8 Mhz 3.3 volt micro controller.

1 ea. Load cell: 0-1 Kg load cell

1 ea. HX711 amplifier/ 24 bit A to D converter HX711

1 ea. ATTiny85 micro controller ATtiny85

2 ea. HM-10 Bluetooth Low Energy modules, one configured as master, one as slave HM-10 serial

1 ea. 2 cell AA battery holder Battery Holder

1 ea. pin Adapter Adapter

1 ea. USBasp Programmer USBasp programmer

1 ea free Aduino IDE Arduino IDE

1ea. 2 x 16 LCD, I2C interface LCD

1 ea. Arduino Pro Mini 8 Mhz 3.3v 3.3v Pro Mini ATmega328

1 ea. USB to TTL serial adapter FTDI adapter

1 ea. USB battery bank Battery bank

10 ea. push type toggle switch ( 8 spare) latching switch

10 ea. momentary tactile button (8 spare) buttons

1 ea. clear soap dish enclosure for display, from Daiso.

Assorted: wires, small perfboard, 3 2N2222 transistors, IRF9540 Mosfet, resistors, and diodes.

Programming the HM-10 Modules

20160514_200601.jpg

The HM-10 modules come configured as slave units, and no auto sleep. They need to connect immediately, master to slave, without a password or other negotiation. To program them, use the FTDI 232 adapter (set to 3.3 volts). You connect pins 3.3v, Gnd, Rx to Tx and Tx to Rx; it will be helpful to have a female header to stick on the FTDI pins, then solder small flexible wires to the female header pins, and from there solder the wires to the HM-10. See the circuit diagram for the HM-10 Manual , the mode led on pin 24, the reset wiring on pin 23, and the connection of grounds to pins 13,14, 21, and 22 needs to be accomplished- it takes a fine tipped soldering iron and a steady hand (plus a 3rd hand accessory to hold the board) . You will need some sort of terminal program, the best is Realterm because it allows you to send AT modem commands to change the configuration. See this excellent instructable to familiarize yourself on the steps required Programming the HM-10 .

/////////////////////////////////////////////////////////////////////////////////////////////////

Program the slave as:

MODE 2, data and AT commands in same data stream. send AT+MODE2

PWRM 0, auto sleep mode, send AT+PWRM0

ROLE 0, slave/remote/peripheral unit, send AT+ROLE0

PCTL 1, power output, max. send AT+PCTL1

FLOW 0, flow control not used. send AT+FLOW0

ADDR ?, you need to find the MAC address for this device, write it down. Used to set CONN in master.

send AT+ADDR?

CONN XXYYZZ etc., set the slave to connect to master's MAC address.

send AT+CON22C22FF22DA2 [whatever the master MAC address is]

BAUD 0, default baud rate 9600 baud (as fast as the ATtiny85 can send) send AT+BAUD0

POWE 1, -6 dBm transmit power (to save a bit of power), send AT+POWE1

VERS ?, version. My version was v533. send AT+VERS?

With HMSoft V540, see notes below.

///////////////////////////////////////////////////////////////////////////////////////////////////////

Program the master as:

MODE 2, data and AT commands in same data stream. send AT+MODE2

PWRM 1, no sleep mode (master has external soft latch power down), send AT+PWRM1

ROLE 1, master/central unit, send AT+ROLE1

PCTL 1, power output, max. send AT+PCTL1

FLOW 0, flow control not used. send AT+FLOW0

ADDR ?, you need to find the MAC address for this device, write it down. Used to set CONN in slave. send AT+ADDR?

CONN XXYYZZ etc., set the master to connect to slave's MAC address. send AT+CON22C22FF22DA2 [whatever the slave MAC address is]

BAUD 0, default baud rate 9600 baud (as fast as the ATtiny85 can send) send AT+BAUD0

POWE 2, default 0 dBm transmit power, send AT+POWE2

VERS ?, version. My version was v533. send AT+VERS?

With HMSoft V540, see notes below.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

Notes: V540 uses AT+TYPE set to 2 as default (use PIN code), so set it back to 0 (no PIN code).

Also, V540 does not connect immediately on power on, display unit must send AT+CONxxyyzz...... (MAC address of slave) to connect, add that to Setup section of the sketch.

other interesting AT commands:

TEMP ? send AT+TEMP? to get the temperature

RSSI ? received signal strength send AT+RSSI?

BATT ? battery voltage (has A/D converter!), send AT+BATT?

PIO4, PIO7 etc. set or clear output pins (used to power up and down the ATtiny85) send AT+PIO41 to set HIGH, AT+PIO40 to set to low.

Wiring Up the Scale and Program ATtiny85

20160514_195024.jpg

Assemble the parts for the scale on the perfboard. Solder wires between components according to wiring diagram. You can program the ATtiny85 externally by making or buying a 6 pin programming adapter for the ATtiny85, or you can just wire a 6 pin header to the perfboard like I did (the wiring diagram does not show the extra connections to the header). I used the Arduino IDE to program the ATtiny, but first add the ATtiny to the boards manager, see ATtiny In the tools tab of the Arduino IDE, program the ATtiny to run the 8 Mhz internal clock, port doesn't matter (it uses the USB port), and Programmer: USBasp. On a new ATtiny, you need to "burn bootloader" first (at bottom of tools list- actually just sets fuses for the internal clock speed etc.). The ATtiny is great in that it runs at low power, but the internal clock has the drawback that the clock isn't very accurate. Therefore, because the Attiny needs to send serial data gathered from the HX711, an OSCCAL calibration procedure is required or the serial data at 9600 baud will likely be garbage. I used Tiny Tuner , the "Using serial communication" method.

Program the ATtiny with the sketch ATtiny85_Hummingbird_Bluetooth_SLEEP_net1_1.ino The HX711.h include file can be found by following this link HX711 hookup and code library

I am currently using 2 AA batteries for a power supply, as that, and the circuit board will fit into the small plastic food container I bought from Daiso. If that doesn't work long term, I will add a step up boost dc to dc converter; I found such a dc to dc converter that has a 500uA idle current draw.

Assembling the Display and Programming It

20160514_090713.jpg
20160514_105732.jpg
20160514_123013.jpg
20160515_204256.jpg
20160514_105431.jpg
20160513_115230.jpg
20160514_105338.jpg
20160514_105659.jpg
20160513_115300.jpg

Hot glue the Arduino Pro Mini to a bit of Popsicle stick, and hot glue the Popsicle stick to the lcd so as to keep the Pro Mini above the tabs on the lcd display. Build the Softlatch on/off circuit on a piece of perfboard according to the circuit diagram- credit to Ardweeny and wire it to Ground and Raw input of the Pro Mini, and control lines to pins 5 and 6 of the Pro Mini. Wire the on/off button lead and ground to an case mounted button. Hot glue the Softlatch circuit to the lcd.

Since the power supply needed to power the lcd with 5 volts, but the HM-10 needs 3.3 volts, a Pro Mini with an onboard 3.3 volt regulator was chosen. That simplified logic level interfacing between the Pro Mini and HM-10, and even to the I2C backpack (5V I2C components can be connected to the SDA and SCL lines of the 3.3V Pro Mini I2C-bus), while still giving the lcd 5 volts for a normal display. A common USB battery bank was chosen to provide the 5 volts because it was easily rechargeable via USB, fit well in the project box (soap dish), and came in a pleasing color to show through the clear soap dish case. Because lengthwise space is limited in the soap dish, a USB connector was cut down and wires soldered to the cut down connector (outer 2 pins) and extended to the Softlatch circuit board power input.

Carefully drill 4 holes for mounting the lcd in the soap dish lid, and attach lcd to lid with 4 ea. 1/2" long miniature screws and matching nuts. Drill holes for the toggle switch pushbutton, and hold in place temporarily with earthquake putty on the sides of the toggle. Apply 30 minute epoxy sparingly to top and bottom of toggle and allow to cure. Do the same for the 2 buttons. Wire according to circuit diagram.

Program the Pro Mini with the sketch using the FTDI adapter plugged into the female programming header.

Position the HM-10 so the built in Antenna faces towards the front of the case, clear of metal or wiring, and in such a position that the HM-10 mode led can be seen. Secure with hot glue to the lcd.

Installing the Scale and Testing

20160516_151335.jpg
20160516_142851.jpg
20160516_145514.jpg
20160516_151509.jpg
20160516_151650.jpg
20160516_151750.jpg

Since our house has wood eaves, a bracket that holds the load cell and electronics/battery was fabricated out of 1-7/16" x 1/8" aluminum stock, using a vise and pipe wrench to bend it. The load cell should attach at one end via screws to the bracket, the other end of the load cell has screws to attach a hook. The fishing line attaches to the hook, supporting the feeder. Be sure the free end of the load cell is clear of the plastic container and wires.

Test the scale without the feeder, and note the reading. Zero can be adjusted in the sketch for the display, try different factors until it reads zero. Then attach a known weight (weigh a nickel on a separate scale, should be around 5 grams). Adjust the scale factor in the sketch until the scale reads the same as the known weight. Attach the feeder and note the reading. When you see a bird about to land on the feeder, set the toggle for net weight instead of gross weight, thereby zeroing the scale before the bird lands. The hummingbirds weigh around 3.5 to 4.5 grams, and an oriole, 25 grams. Do the weighing when the wind is calm, as a swinging feeder makes it difficult to get a reading.