Author Archives: paynterf

Digital Tension Scale, Part V

posted 09 January 2019,

In my previous post on this subject I described the components I planned to use for my Digital Tension Scale project, and also the design for a box that would mount directly on the S-shaped load cell assembly.

This post describes the ‘final’ (to the extent than anything I do can be considered final) assembly of the completed system into my 3D-printed housing, and the results of some initial battery-powered testing.

As shown in the following photos, the major components (Teensy 3.2 microcontroller, HC-05 Bluetooth Module, HX-711 load cell amp/A-D, and Sparkfun ‘Basic’ LiPo Charger) were mounted on perfboard, which was then in turn attached to the box lid via a set of custom-printed standoffs.  A short piece of ribbon cable connects the Teensy to the LCD display.  The general idea behind this physical layout is to allow easy access to the electronics for troubleshooting, and to allow for battery charging and/or Teensy programming without having to open the box.

3D-printed housing. Note the glow from the Sparkfun charger LED

View of housing showing the access port for supplying USB power and/or programming the Teensy

View with the lid and electronics board removed. The LCD display is face down in its cutout

Exploded view showing all system components

Showing connections from load cell to HX-711

Top view showing how load cell attaches to the housing

Closeup showing load cell lead routing and power/programming port

End view showing charging port


Preliminary Testing Results:

At this point I have everything running on battery power only inside the box, and I have been able to demonstrate remote data capture on my PC using the HC-05 BT link.  The following image shows the data taken from my rowing machine, and a short video demonstrating the setup.

Complete Code:

Here is the complete Teensy 3.2 program as it stands today.  As you can see if you inspect the code, I have the Teensy low-power stuff turned OFF for the moment (that’s the purpose of the ‘#define NO_SNOOZE’ statement.



Future Work:

  • Do some more work to reduce power consumption to extend the battery life.  I got the ‘Snooze’ feature to work on the Teensy, but that only reduces the Teensy’s power consumption; it does nothing directly to reduce the power consumption of the other components.  I tried using a MOSFET to turn the HC-05 BT module on & off, and found this to be impractical, as then the module loses its connection to the remote data collection device.   I have also tried removing power from the LCD module, but that also turned out to be problematic.

Stay tuned,




Digital Tension Scale, Part IV

Posted 25 December 2018

In my copious free time I have been refining the design for a low power battery operated tensionometer.  In my last post on the subject, I had described the components I had planned to use, and in the ensuing weeks I have been working on implementing this design.  There are several challenges in this project:

Bluetooth Link:

There are a huge number of Bluetooth products out there in the Maker-verse, with varying degrees of Arduino support, and widely varying performance characteristics.  To add to the confusion, there is ‘regular’ Bluetooth and the more recent ‘BLE’ (Bluetooth Low Energy) which are completely incompatible with each other.  As I now understand it, BLE is synonymous with Bluetooth 4.0+ (the iPhone 4S was the first smartphone to implement the new standard).  However, the most common product in use in the Arduino world seems to be the venerable HC-05 ‘regular’ Bluetooth module, available from your local grocery store (well, not quite, but from almost everywhere else!) for not much more than a few pennies

I had no previous experience with BT modules, so this part of the project took some time, and was the last major part to be accomplished.  After receiving my HC-05 modules from China, I used this tutorial to get started.  The real challenge for this part of the project wasn’t getting the HC-05 hooked up to the microcontroller – it was sorting through all the layers of BT-related settings on my Win 10 laptop to pair with the HC-05 device and determine which serial port did what.

  • In Windows 10, I used the ‘Bluetooth and other devices settings’ panel (Settings -> Devices -> Bluetooth and other devices) to find and pair to the HC-05.  The device shows up as ‘HC-05’ and the default pairing password is “1234”.
  • When the HC-05 is paired it automatically sets up at least two serial ports that show up in device manager as ‘Standard Serial over Bluetooth’ ports, as shown below.  However, only one of these ports is actually usable for two-way communication, and it isn’t clear to me why, or how to tell which is which;  I had to experiment with each available ‘SSoB’ port to figure out which to use (so far, it seems like the highest-numbered port is the proper one).
  • After the HC-05 is paired and the com ports are set up, then any serial terminal app (I used RealTerm) can be used to communicate between the PC and the microcontroller via the HC-05.
  • On the microcontroller (I used a Teensy 3.2 with multiple hardware serial ports), I wired the HC-05 to Serial1 leaving Serial (Serial0) available for normal communication between the Teensy and my Visual Studio 2017 Community Edition/Visual Micro add-on for Arduino development platform.

Physical Layout:

The original idea behind this project was to create a self-contained battery-operated digital weight scale that could display weight values on a local display, but could also stream the data live to a remote recording station like a laptop or smartphone. The ‘self-contained’ part requires that all the electronics be mounted on the S-shaped load cell assembly itself, and to that end I designed a housing that connects to the two bolts that hold the arms of the load cell.  The idea is that all the electronics save the LCD display and the battery will be mounted to the underside of the box lid so that servicing would be easier.  Also, by mounting everything to the lid, I can make cutouts for the charger and Teensy USB connectors for easy charging and reprogramming.  After several iterations in TinkerCad, I came up with the following design

Looking up at the underside of the box lid, showing all modules except the battery and the LCD display

Showing the top of the lid with the mounting bracket for the load cell

Isometric view with transparent box walls. The LCD display module is under the battery.  Note the cutouts for the charging and programming USB-C connections

Module Integration:

I had previously tested each module individually, but hadn’t had all of them working at the same time.  I had tested the HC-05 with an Arduino Mega, and I had tested the load cell with both a Sparkfun Pro Micro and with a Teensy 3.2, and I had tested the Nokia LCD display with a Teensy 3.2, but I hadn’t put everything together.  So I wired everything up on my half-size ASP plugboard and got it all working together with a simple program (included below) that exercised the LCD Display, the load cell, the BT module, and the battery charger, as shown in the following photos

RealTerm Serial Terminal Program showing load cell readouts collected wirelessly via the Bluetooth HC-05 modules

HC-05 Bluetooth, HX-711 Load Cell Amp, Sparkfun Charger, and Teensy Microcontroller modules integrated together. Note disconnected USB cable showing that the circuit is running on battery power. The scale is currently measuring 1.8 liters of water in the suspended plastic bag (note the ‘1.8 Kg’ reading on the LCD display)



The software used for the above integration tests is a reasonably complete sketch for day-to-day use of the digital weight scale.  It displays the measured weight on the LCD display, and also sends it to the USB serial port for display on a directly connected PC, and to the HC-05 Bluetooth module for display/capture via a BT-connected laptop or smartphone.  This program is shown below:

However, this program depends on the proper calibration of the load cell, which I have been doing with a separate sketch (also included below):

What I need to do now is to combine these two programs into a single sketch with ‘operating’ and ‘calibration’ modes.  My calibration program already does this to some degree, as it waits 5 seconds on startup for the operator to send the ‘y’ key via the direct-connect serial port. If the ‘y’ character is detected within this window, then the program starts the calibration sequence; otherwise it starts taking measurements as normal.  This behavior needs to be expanded somewhat in that it should accept a calibration command either through the direct-connect serial port (Serial) or via the BT port (Serial1).

Low Power Operation:

I have already done some experimentation on low-power operation of the Teensy 3.2, using Colin Duffy’s fine ‘Snooze’ library, and have determined that I can easily drop the Teensy’s operating current from around 20-30 mA to about 1-2 mA by putting it to sleep during periods of load cell inactivity.  Assuming I get the full 2500 mA hours out of the battery, then I can expect something like 1000 hours or about 40 days between recharges.  However, more work needs to be done to get the low power mode fully operational.


Stay Tuned!



Digital Tension Scale, Part III

Posted 25 November, 2018

Over the Thanksgiving weekend I had a chance to do some more work on my digital tension scale project.  My wife and I drove to St. Louis to visit our kids and grand-kids, and its a 6-hour drive each way.  I make sure we have an audio book going for my wife, and as a consequence I get 6 hours of (mostly) uninterrupted geek time to work on things like this project.

As I mentioned in Part II, my goal is to construct a battery-operated tensionometer that can be mounted directly on the dual-hook S-shaped tension block, as defined by the features delineated in Part II.  After doing some more web research, I came up with the following possible components for the system:


Apparently, the Nokia 5110 84×48 pixel monochrome LCD display used in prehistoric times as the display in Nokia cellphones has found a second career as a simple, low power display for battery-operated devices like the one I envision.


Nokia 5110 Monochrome LCD display

Battery & Battery Charger:

The LCD display will operate quite nicely from 3.3V, so as long as I can come up with a 3.3V micro-controller (like the Teensy 3.2) and a small, capable LiPo charger, I should be in business.  For this component, I plan to use the Adafruit PowerBoost 1000C and something like the 3.7V 2500 mAh battery as shown below

Adafruit PowerBoost 1000C single-cell LiPo charger

3.7V 2500 mAh LiPo battery


I don’t think I’ll need the 5V boosted output from the PB1000C and the entire thing may be a bit of overkill for this project, but I had them hanging around from a previous project, so…


For this I plan to use one of Paul Stoffregen’s magical Teensy 3.2’s.  Again this is probably way overkill for the project, but…

Wireless Connection:

This component is the one for which I have the least understanding and confidence.  I currently use a Pololu Wixel for wireless serial comms and programming with my autonomous robot, but I haven’t figured out how to use it with a Teensy, and I thought maybe there were better solutions out there by now anyway.  So, after some more web searching I found that many ‘makers’ are using the HC-05/6 Bluetooth modules for this purpose.  Hopefully with this module I’ll be able to use a Bluetooth connection from the tensionometer to my laptop or even my cellphone to perform calibrations and collect real-time tension data.

Combining all these with the HX-711 load cell amplifier, I came up with the following system schematic.


Stay tuned!



Digital Tension Scale, Part II

Posted 17 November 2018

In a previous post on this subject, I described a digital tension scale arrangement using a load cell incorporated into a 2-hook tension measurement setup, interfaced to a common HX711 ADC board, and a Sparkfun Pro Micro ATMega32U4 microcontroller.

After (finally) getting the setup to work and getting some initial real-time tension measurements on our rowing machine, I decided to see if I could improve the usability of the overall system, with the goal of constructing a fully automatic battery powered tension scale, with the ability to communicate wirelessly to my PC for data acquisition and programming.

Desired Features:

  • Easy calibration:  The system should offer a calibration option when connected to a PC/Smartphone, but otherwise should use the last calibration data (stored in EEPROM) for measurements.
  • Battery operated: This implies a low-power mode to extend battery life if using primary batteries, and/or a charging arrangement if using secondary (rechargeable) cells.
  • Local display:  A low power display (LCD?) for local tension measurement display
  • Wireless capability:  A wireless connection to a PC or smartphone for real-time data acquisition.
  • Small size:  I would like to mount the entire system on the 2-hook tension measurement assembly itself.

Easy Calibration:

The calibration procedure associated with my previous post was a PITA, to say the least, so I decided to attack this problem first.  I modified the software to allow the user to skip calibration entirely or to calibrate the tensionometer automatically using any known weight.  The new software is shown below:

When run on my PC, this produced the following output

Here are a couple of photos showing the calibration process with my current setup

‘Tare Weight’ configuration, used to zero out the contribution from the bucket

Calibration configuration. Bucket now contains 1.8L water (1.8 Kg)

After calibrating, I tested the the system by measuring tension vs time with an elastic strap I am using as part of my rotator cuff surgery rehab, as shown in the following short video clip

The data from this experiment was captured on my PC and plotted in Excel, as shown below

Tension vs time for the orange elastic strap shown in the video

Then, at the request of my physical therapist, I measured the real-time tension for single & double orange straps, and single/double green straps, as shown below

Single and double green strap tension vs time

Single and double orange strap tension vs time


Stay tuned!




Digital Tension Scale

Posted 27 October 2018

I recently underwent rotator cuff repair surgery on my left (dominant) shoulder, and am now starting the rehab process.  My PT person was adamant that I not re-start my normal rowing routine for at least six weeks post-op, due to the possibility that I could re-tear the tendon.  This made me curious as to what the tension really was on my arms when rowing, so I decided to try and build a digital dynamic tension sensor, capable of plotting rowing strap tension in real time.

To start, I had to educate myself on the world of strain gauges and load cells, and what the differences are.  As I came to understand, what I wanted was a load cell configured for tension measurement, with a strain gauge as the active sensing element in the load cell.  So, I started searching for load cells, and was immediately inundated with ‘too much information’.  This deluge is certainly better than the old days where I had to search through paper (really, no internet!) magazines and catalogs, but at least you didn’t have to worry about overload headaches! ;-).

Anyway, I found this item ‘Degraw 40Kg Tension Load Cell and HX711 Combo Pack Kit‘, as shown in the screenshot below

Amazon catalog item for Degraw load cell

This looked perfect for my intended use, as I could hook one end onto my rowing machine strap, and connect some sort of handle to the other end.  Now all I had to do was figure out how to hook the thing up and get it to work.  Fortunately Degraw also provided a sketch of the hookup using an Arduino Uno, so that part was pretty easy.

Degraw-provided hookup diagram

After a bit more research, I found a nice HX711 library by bogde and some example programs, and got the whole thing to work using an Arduino Mega 2560.  Once I got a program running with some preliminary (but believable) results, I started thinking about how I was going to manage the physical aspects of hooking this assemblage to the rowing machine and recording dynamic tension.  I couldn’t really just let the HX711 board hang by the strain gauge wires while connected with jumpers to the Mega board, as the #28 strain gauge leads would surely break.  So, I came up with the idea of somehow attaching the HX711 board and a small microcontroller to the load cell assembly, and then connecting the whole thing to my laptop with a USB cable.  Hopefully the USB cable would be long enough to allow full extension of the rowing machine strap so I could collect full rowing cycle data.

After some digging around in my parts cabinets, I came up with two candidates for the ‘small microcontroller’ part of the plan; a 3.3V Teensy 3.2, and a 5V/16MHz Sparkfun Pro Micro.  I tried the Pro Micro at first, and almost immediately went down the rabbit hole (my term for getting lost in some technical wonderland without a clue how to get back) trying to figure out how to program the device – a challenge due to the way it handles com ports through the USB connector (it actually implements two different ones, depending on whether the boot loader or the user firmware is running – yowie!).  After climbing my way out of the rabbit hole, I decided to try the Teensy 3.2 instead, as I familiar with it from several other projects.  With the Teensy, I got a test program running and started taking data with known weights attached to the load cell. The way I did this was to suspend a plastic bucket from the load cell, and poured water into the bucket one liter (1Kg) at a time while recording data.  This was successful because I got good data, but unsuccessful because the data didn’t make much sense, as shown in the plot below

Results of pouring 1L (1Kg) water at a time into bucket suspended from load cell, using a 3.3VTeensy 3.2

As can be seen, the data was anything but the stairstep function I was expecting to see.  At this point I wasn’t sure if I had a hardware problem or a software problem, or something else entirely, so I sent an email to Degraw Product support with the above plot attached, asking if they had any insight into the problem.  Amazingly, they replied almost immediately, and offered to send me another load cell unit gratis so I could eliminate their hardware as the cause of the problem.  Although I was quite pleased with their offer of support, I thought maybe the 3.3V supply of the Teensy 3.2 might be causing the non-linearity (the HX711 advertises 2.7-5V operation but the lower voltage might be causing output linearity problems).  So, I tried again with the Sparkfun Pro Micro, and this time I managed to make the programming magic work. Then when I did the same test as above with the 5V Pro Micro instead of the 3.3V Teensy, I got the plot shown below.

Tension vs time plot created by pouring 1L (1Kg) of water at a time into bucket suspended from load cell, using Sparkfun 5V Pro Micro

So, now that I had the software and microcontroller problems solved, I started working on the mounting issue.  After a few minutes in TinkerCad and some quality time with my PowerSpec 3D PRO 3D printer, I had a mounting platform that clipped onto the two vertical rods in the ‘S-shaped’ tension load cell, as shown in the images below.

Reverse side of assembly, showing mounting plate clips attached to load cell vertical members

Sparkfun Pro Micro and HX711 board mounted on load cell

After getting all this set up, it was time to take some real data. Since I was still in the ‘no rowing’ zone after my surgery, I enlisted my lovely wife to do the honors while I recorded the data.  We have an Avari magnetic rowing machine, which thankfully doesn’t make much noise.  I recorded a total of 12 rowing cycles on two different ‘wave’ settings (I’m still not sure what the different ‘wave’ settings mean) at the lowest tension level, with the results shown below

As shown in the above plot, the peak tension reading was around 18Kg (about 40 lbs).   I’ve included a short video of the test below.

State memory for Wall-E2 – writing telemetry packets to FRAM

posted 28 September 2018

In previous posts, I have described my effort to give time, memory and relative heading super-powers to Wall-E2, my autonomous wall-following robot.  This posts describes a helper class I created to allow Wall-E2 to periodically write its current operating state to FRAM memory, for later readout by his human master(s), and a small test program to verify proper operation of the helper class.

My current conception of Wall-E2’s operational state consists of the current time/date, its tracking mode and submode, and the current left, right, and forward distances, and the current battery voltage. These parameters have been encapsulated in a CFramStatePacket class with methods for writing state packets to FRAM and reading them back out again.  The complete code for this class is shown below. Note that all the class code is contained in just one file – FramPacket.h.  There is no associated .cpp file, as I didn’t think that was necessary.

To test my new CFRAMStatePacket class, I created a small test program that periodically writes simulated state packets to FRAM using the helper class methods, and optionally (if the user creates an interrupt by grounding the appropriate pin) reads them back out again.  This program is designed to run on an Arduino Mega 2560.  If a Uno is used, the interrupt pin number would have to be changed.

The test code also looks for a low on the CLEAR_FRAM_PIN (Pin 3) on startup.  If it finds one, it will clear NUM_FRAM_BYTES_TO_CLEAR (currently 2000) FRAM bytes and then read them back out again, byte-by-byte.  Otherwise, the program will continue storing state packets where it left off the last time it was powered up.  Here’s the test code:

And here’s some output from a typical run: