User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Wed Nov 28, 2018 9:02 am

tlfong01 wrote:
Wed Nov 28, 2018 8:20 am
Giving up ESP8266-12 NodeMCU Lua programming for HX711, will use Rpi3B+ MCP23017 Python instead.
So I will suspend ESP8266-12 for now, and wait for ESP8266-32 to resume my project.
In the mean time, I will fall back on Rpi3B+ MCP2307 Python.
Some 3 months ago, I wrote a python program to read DHT22, but found Rpi3B+ I2C (100kHz) too slow for DHT22 and I gave up. Now I am checking out if I2c 100kHz is good enough for HX711.

(Rpi3B+ MCP23017 DHT22 Tests) RE: RELAY MODULE KY-019 5V - tlfong01 2018-Aug-21[/i][/color]
viewtopic.php?f=37&t=77158&start=350#p1355771

Decoupling Loosely Coupled HX711 from ESP8266

Now that I am no longer using ESP8266 to control HX711, I need to decouple HX711 hardware from ESP8266. Luckily I have been using loosely coupled design for both sofware (mainly using functiona; programming) and hardware modules (functionally separate bread board proto board areas), decoupling modules is an easy job.

Appendix - Loose coupling - Wikipedia
https://en.wikipedia.org/wiki/Loose_coupling

In computing and systems design a loosely coupled system is one in which each of its components has, or makes use of, little or no knowledge of the definitions of other separate components.

Components in a loosely coupled system can be replaced with alternative implementations that provide the same services. Components in a loosely coupled system are less constrained to the same platform, language, operating system, or build environment.

Loose coupling is an architectural principle and design goal in service-oriented architectures;

Computer programming languages having notions of either functions as the core module or functions as objects provide excellent examples of loosely coupled programming. ...

Functional languages have ..., closure, ... See Clojure and Lisp as examples of function programming languages. Object-oriented languages like Smalltalk and Ruby have code blocks, ...

The basic idea is to objectify (encapsulate as an object) a function independent of any other enclosing concept (e.g. decoupling an object function from any direct knowledge of the enclosing object).

See First-class function for further insight into functions as objects, ...

...
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Wed Nov 28, 2018 3:03 pm

tlfong01 wrote:
Wed Nov 28, 2018 8:20 am
In the mean time, I will fall back on Rpi3B+ MCP2307 Python. Some 3 months ago, I wrote a python program to read DHT22, but found Rpi3B+ I2C (100kHz) too slow for DHT22 and I gave up. Now I am checking out if I2c 100kHz is good enough for HX711.
(Rpi3B+ MCP23017 DHT22 Tests) RE: RELAY MODULE KY-019 5V - tlfong01 2018-Aug-21
[url]https://www.raspberrypi.org/forums ... 0#p1355771[/url]

Rpi3B+ Python MCP23017 HX711 Newbie Program V01.02

Now I have found my old DHT11 program which did not work. It was three months ago when I gave up and switched to ESP8266. Now I am coming back. I need to refresh my memory. Again I forgot the terminal command to detect a I2C device address. So I need to read my program comments to find the command.

$ i2cdetect -y 1

I could detect the device adress at 0x22. The program still runs OK. So I now list the config part to refresh my memory.
...

Code: Select all

# hx711.01.01# hx711.01.01 tlfong 2018nov28hkt2206 

# *** Import ***

import datetime
import time
import smbus
import sys

# *** Testing Notes ***
#  Use i2ctools (raspbian stretch terminal mode, no need to install)  
#  $ i2cdetect -y 1 to check addresses of i2c devices on the bus

# *** Config ***

# *** MCP23017 Device Register Address Dictionary (iocon.bank = 0) ***

regAddrByte = \
    {	
        'IODIRA'  	: 0x00, 
		'IODIRB'	: 0x01, 
		'IPOLA'		: 0x02,
		'IPOLB'		: 0x03, 
		'GPINTENA'      : 0x04, 
		'GPINTENB'	: 0x05, 
		'DEFVALA'	: 0x06, 
		'DEFVALB'	: 0x07, 
		'INTCONA'	: 0x08, 
		'INTCONB'	: 0x09, 
		'IOCON' 	: 0x0b, 
		'IOCON' 	: 0x0a, 
		'GPPUA' 	: 0x0c, 
		'GPPUB' 	: 0x0d, 
		'INTFA' 	: 0x0e, 
		'INTFB' 	: 0x0f, 
		'INTCAPA'	: 0x10, 
		'INTCAPB'	: 0x11,
		'GPIOA' 	: 0x12,
        'GPIOB'		: 0x13,
        'OLATA'     : 0x14,
        'OLATB'     : 0x15,
        'PortA'     : \
            {
                'Direction'         : 0x00,
                'OutLatch'          : 0x14,
                'GpioPort'          : 0x12,
                'IntPinsEnable'     : 0x04,
                'IntPinsDefault'    : 0x06,
                'IntPinsCompare'    : 0x08,
                'InterruptFlagByte' : 0x0e,
                'IntCap'            : 0x10,
                'PullUp'            : 0x0c
            },
        'PortB'         : \
            {
                'Direction'         : 0x01,
                'OutLatch'          : 0x15,
                'GpioPort'          : 0x13,
                'IntPinsEnable'     : 0x05,
                'IntPinsDefault'    : 0x07,
                'IntPinsCompare'    : 0x09,
                'InterruptFlagByte' : 0x0f,
                'IntCap'            : 0x11,
                'PullUp'            : 0x0d
            },
        }

# *** MCP23017 Control Byte Dictionary ***

controlByte = \
    {
        'WriteRegBaseByte'                          : 0x40,
        'ReadRegBaseByte'                           : 0x41,
        'EnableAddressPins'                         : 0x08,
        'AllPinsOutput'                             : 0x00,
        'AllPinsInput'                              : 0xff,
        'LowNibblePinsOutputHighNibblePinsInput'    : 0xf0,
        'IntAllPinsEnable'                          : 0xff,
        'IntPinsEnable'                             : 0xff,
        'IntAllPinsCompareDefault'                  : 0xff,
        'AllPinsPullUp'                             : 0xff,
        'AllHigh'                                   : 0xff,
        'AllLow'                                    : 0x00,
        'AllPinsHigh'                               : 0xff,
        'AllPinsLow'                                : 0x00,
        'IntAllPinsHigh'                            : 0xff,
        'IntAllPinsLow'                             : 0x00,
        'IntLowNibblePinsEnable'                    : 0x0f,
        'IntLowNibblePinsComparePrevious'           : 0x00,
        '0x01'                                      : 0x01,
        '0x55'                                      : 0x55,
        '0x66'                                      : 0x66,
        '0xaa'                                      : 0xaa,
        '0x0f'                                      : 0x0f,
        '0xf0'                                      : 0xf0,     
    }

repeatCount = \
    {
        'RepeatOneTime'                             : 1,
        'RepeatOneHundredTimes'                     : 100,
        'RepeatFiveHundredTimes'                    : 500,
        'RepeatOneThousandTimes'                    : 1000,
        'RepeatTwoThousandTimes'                    : 2000,
        'RepeatThreeThousandTimes'                  : 3000,
        'RepeatFiveThousandTimes'                   : 5000,
        'RepeatTenThousandTimes'                    : 100000,
        'RepeatOneHundredThousandTimes'             : 100000,
    }

pauseTime = \
    {
        'ZeroMilliSeconds'                          : 0,
        'TwoMilliSeconds'                           : 2,
        'FourMilliSeconds'                          : 4,
        'FiveMilliSeconds'                          : 5,
        'SixMilliSeconds'                           : 6,
        'SevenMilliSeconds'                         : 7,
        'TenMilliSeconds'                           : 10,
        'FiftyMilliSeconds'                         : 50,
        'OneHundredMilliSeconds'                    : 100,
        'TwoHundredMilliSeconds'                    : 200,
        'OneThousandMilliSeconds'                   : 1000,
        'TwoThousandMilliSeconds'                   : 2000,
    }


dataByte = \
    {
        'AllBitsHigh'                                : 0xff,
        'AllBitsLow'                                 : 0x00,
        'TwoBitHighSixBitLow'                       : 0xf6,
        'SixBitLowTwoBitHigh'                       : 0x03,        
        'FourBitLowFourBitHigh'                     : 0x0f,
        'FourBitHighFourBitLow'                     : 0xf0,
        'FiveBitLowThreeBitHigh'                    : 0x07,
        'ThreeBitHighFiveBitLow'                    : 0xef,
        'Five'                                      : 5,
        'Twelve'                                    : 12,
        'Eighteen'                                  : 18,
        'Nineteen'                                  : 19,
        'TwentyTwo'                                 : 22,
        'TwentyThree'                               : 23,
    }
       
# *** MCP23017 Config Bit Dictionary ***

basicCnfgBits = \
    {
        'BaseByte'                      : 0x00,
        'RegAddrBank0'                  : 0b0 << 7,
        'TwoIntPinsNoMirror'            : 0b0 << 6,
        'TwoIntPinsMirror'              : 0b1 << 6,
        'AutoIncRegAddrDisable'         : 0b1 << 5,
        'SlewRateDiable'                : 0b0 << 4,
        'HardwareAddrEnable'            : 0b1 << 3,
        'ActiveDriver'                  : 0b0 << 2,
        'OpenDrain'                     : 0b1 << 2,               
        'IntActiveLevelHigh'            : 0b1 << 1,
        'IntActiveLevelLow'             : 0b0 << 1,
        'Unimplemented'                 : 0b0 << 0,
    }
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 4:27 am

tlfong01 wrote:
Wed Nov 28, 2018 7:57 am
Load Cell 500g Calibration Record
I have used the 7 in 1 500g calibration weight set to calibrate the load cell. My cheap multimeter is only accurate to 0.1mV. So the output mV readings, especially at the low end, are not that reliable.
Average Sensitivity = 1.26mV/V

Rpi3B+ ESP8266-12 Based Smart 5kg/1g Weight Scale Making Notes Part 1

/ to continue, ...
...
Attachments
smart_scale_2018nov2901.jpg
smart_scale_2018nov2901.jpg (175.42 KiB) Viewed 6873 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 4:30 am

tlfong01 wrote:
Thu Nov 29, 2018 4:27 am
Rpi3B+ ESP8266-12 Based Smart 5kg/1g Weight Scale Making Notes Part 1

Rpi3B+ ESP8266-12 Based Smart 5kg/1g Weight Scale Making Notes Part 2

/ to continue, ...
...
Attachments
smart_scale_2018nov2902.jpg
smart_scale_2018nov2902.jpg (196.32 KiB) Viewed 6872 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 4:33 am

tlfong01 wrote:
Thu Nov 29, 2018 4:30 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 1
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 2

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 3

/ to continue, ...
...
Attachments
smart_scale_2018nov2903.jpg
smart_scale_2018nov2903.jpg (178.98 KiB) Viewed 6872 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 4:46 am

tlfong01 wrote:
Thu Nov 29, 2018 4:33 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 1
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 2
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 3

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 4

/ to continue, ...
...
Attachments
smart_scale_2018nov2904b.jpg
smart_scale_2018nov2904b.jpg (158.24 KiB) Viewed 6856 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 4:58 am

tlfong01 wrote:
Thu Nov 29, 2018 4:46 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 1
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 2
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 3
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 4

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 5

/ to continue, ...
...
Attachments
smart_scale_2018nov2905.jpg
smart_scale_2018nov2905.jpg (149.44 KiB) Viewed 6856 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 8:44 am

tlfong01 wrote:
Thu Nov 29, 2018 4:58 am
tlfong01 wrote:
Thu Nov 29, 2018 4:46 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 1
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 2
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 3
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 4
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 5

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 6

Cut the Blue Wire
https://www.youtube.com/watch?v=nXoPEmh39ls

/ to continue, ...
...
Attachments
smart_scale_2018nov2906b.jpg
smart_scale_2018nov2906b.jpg (175.7 KiB) Viewed 6815 times
Last edited by tlfong01 on Thu Nov 29, 2018 2:49 pm, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Thu Nov 29, 2018 2:42 pm

tlfong01 wrote:
Thu Nov 29, 2018 8:44 am
tlfong01 wrote:
Thu Nov 29, 2018 4:58 am
tlfong01 wrote:
Thu Nov 29, 2018 4:46 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 1
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 2
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 3
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 4
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 5
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 6

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 7

Comparing Quarter, Half, and Full Wheatstone Bridge - AllAboutCircuits
https://www.allaboutcircuits.com/textbo ... in-gauges/

/ to continue, ...
...
Attachments
bridge_schematic_2018nov2902.jpg
bridge_schematic_2018nov2902.jpg (140.36 KiB) Viewed 6818 times
Last edited by tlfong01 on Fri Nov 30, 2018 5:23 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 3:56 am

tlfong01 wrote:
Sun Nov 25, 2018 5:10 am
HX711 based Digital Weight Scale[/b][/color]
It is very likely that your scale uses HX711, sealed inside the black dot. A work around is forget the black dot, and connect your own HX7111 to the load cell. You can also replace the LCD and button by the AliExpress cheap thing below.
The good thing of this work around is that you can datalog and print[/color] anything you like, or add ESP8266 towifi you reading, ... :lol:
AliExpress 1602 Module Display For Arduino Uno Raspberry Pi -US$2.25
https://www.aliexpress.com/item/1PCS-LC ... 02339.html

Rpi Graphics 128 x 64 LCD Display with Touch Buttons

Just now I read MagPi76 and found the Pimorni LCD Button hat interesting, and newbie friendly. Everything is I2C! I am thinking of DIYing something similar.

GFX HAT - 128x64 LCD Display with RGB Backlight and Touch Buttons
https://shop.pimoroni.com/products/gfx-hat#description

A 128x64 pixel, 2.15" LCD display with snazzy six-zone RGB backlight and six capacitive touch buttons. GFX HAT makes an ideal display and interface for your headless Pi projects.

... gives you the flexibility of individual pixels, letting you display more complex graphics and real typefaces, ... handy capacitive touch buttons for input / navigation.

Features
128x64 pixel, 2.15" LCD display
Integrated diffuser/reflector assembly
Six-zone RGB LED backlight
SN3218 LED driver chip (I2C address 0x54)
Six capacitive touch buttons with white LEDs
Microchip CAP1166 capacitive touch/LED driver chip ((I2C address 0x2c)
Compatible with Raspberry Pi 3B+, 3, 2, B+, A+, Zero, and Zero W
Python library

Software
Python library handles displaying on the LCD, controlling the backlight, and linking functions to the touch buttons. ... also included a couple of examples to get [newbie] started.


...
Attachments
lcd_button_hat_2018nov3001.jpg
lcd_button_hat_2018nov3001.jpg (158.7 KiB) Viewed 6787 times
Last edited by tlfong01 on Fri Nov 30, 2018 5:10 am, edited 1 time in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 4:25 am

tlfong01 wrote:
Fri Nov 30, 2018 3:56 am
Just now I read MagPi76 and found the Pimorni LCD Button hat interesting, and newbie friendly. Everything is I2C! I am thinking of DIYing something similar.

Rpi Tutorial - Build a digital Raspberry Pi Scale with Weight Sensor HX711

The following Rpi tutorial is also newbie friendly:

Build a digital Raspberry Pi Scale with Weight Sensor HX711
(hx711) https://tutorials-raspberrypi.com/digit ... sor-hx711/
(hx711) https://www.youtube.com/watch?time_cont ... hqGCvYOh_8
(lcd) https://tutorials-raspberrypi.com/contr ... y-via-i2c/
(python) https://github.com/gandalf15/HX711
(arduino) https://github.com/bogde/HX711/blob/master/README.md

... only a sensor and a load cell are required, available for different weight ranges.
... a simple Raspberry Pi kitchen scale, whose precision is amazingly accurate.
... a load cell a metal bar, with four cables. To read out the values, the HX711
... can also take an existing person or kitchen scale and unscrew it, could start directly.
... a python library, contains an example.py file
... correct calibration crucial, two packs of rice, 1kg each
... measurement is astonishingly accurate
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 7:23 am

tlfong01 wrote:
Thu Nov 29, 2018 2:42 pm
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 7

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 8
...
Attachments
load_cell_wiring_2018nov3001.jpg
load_cell_wiring_2018nov3001.jpg (163.32 KiB) Viewed 6764 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 8:16 am

tlfong01 wrote:
Fri Nov 30, 2018 7:23 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 7
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 8

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 9
...
Attachments
quad_load_cell_full_bridge_adapter_2018nov3001.jpg
quad_load_cell_full_bridge_adapter_2018nov3001.jpg (177.26 KiB) Viewed 6757 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 1:14 pm

tlfong01 wrote:
Fri Nov 30, 2018 8:16 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 9[/i][/color]

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 10

So I calibrated the 5kg load cell and found results OK, though the output voltage and sensitivity magnitudes 2mV and 0.75mV/V surprisingly small. Since sensitivity in the 2kg to 4.5kg range looks quite stable. So I think after HX711' s amplification, results should be good enough for my Mickey Mouse applications.

...
Attachments
load_cell_5kg_calibate_2018nov3001.jpg
load_cell_5kg_calibate_2018nov3001.jpg (185.04 KiB) Viewed 6744 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 1:24 pm

tlfong01 wrote:
Fri Nov 30, 2018 1:14 pm
tlfong01 wrote:
Fri Nov 30, 2018 8:16 am
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 10[/i][/color]

Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 11

So the 5kg load cell full bridge is tested OK. Next step is to test the HX711 amplifier. To test HX711, I will not use the load cell bridge. Instead I will use the adjustable voltage reference 0mV ~ 7.5mV to input to HX711.
...
Attachments
load_cell_5kg_setup_2018nov3002.jpg
load_cell_5kg_setup_2018nov3002.jpg (191.17 KiB) Viewed 6741 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Fri Nov 30, 2018 1:52 pm

tlfong01 wrote:
Fri Nov 30, 2018 1:24 pm
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 11[/i][/color]

Controlling HX711 using Rpi3B+, MCP23017, and python3

Now I am leaving the weight scale thing and start python programming. I plan to use python 3 and the following hardware:

1. Rpi3B+
2. MCP23017
3. HX711


I googled and found two very good references, as listed below. I will study them carefully and hope to learn from these HX711 experts.

HX711 Class in Python 3 for Rasperry Pi by gandalf15, 2017
Newbie friendly, well documented structured programming.
https://github.com/gandalf15/HX711

HX711 Class in python and pigpio
Lua and event driven programmers friendly, using daemons and callbacks.
http://abyz.me.uk/rpi/pigpio/code/HX711_py.zip

HX711 Python Class - tatobari/hx711py 2016
https://github.com/tatobari/hx711py/blo ... r/hx711.py
Simple and short program - only 303 lines, 205 sloc (Source Lines Of Code), 7.58 kB)

HX711 Arduino Library by bogde, 2013
https://github.com/bogde/HX711
Last edited by tlfong01 on Sun Dec 02, 2018 1:58 am, edited 6 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sat Dec 01, 2018 3:21 am

tlfong01 wrote:
Fri Nov 30, 2018 1:52 pm
Controlling HX711 using Rpi3B+, MCP23017, and python3

Using MCP23017 to read 12 HX711

So I googled to check out how other Rpi guys are using MCP23017 to read HX711, ... and I found an inconvenient truth, ... :(

Appendices - HX711 and MCP23017 etc

Reading HX711 with MCP23017
https://raspberrypi.stackexchange.com/q ... 0864#70864

Using MCP23017 to read 12 HX711
https://raspberrypi.stackexchange.com/q ... 2656#62656

StackExchange Raspberry Pi Questions on HX711 - 23 results
https://raspberrypi.stackexchange.com/s ... st&q=hx711

IoT Raspberry Pi Smart Container with Email Alert and Web Monitoring - 2017
https://circuitdigest.com/microcontroll ... -container
https://circuitdigest.com/microcontroll ... matic-gate
https://circuitdigest.com/microcontroll ... -load-cell
https://www.youtube.com/watch?v=Sud5KSNCKUs
http://abyz.me.uk/rpi/pigpio/code/HX711_py.zip

Avia Semi Data Converter (ADC) HX71x/HX61x Product List
http://www.aviaic.com/ENProducts.aspx
http://www.aviaic.com/ENDefault.aspx

TaoBao shop selling load cells
https://shop33817767.world.taobao.com/s ... 8%D0%C6%F7
https://item.taobao.com/item.htm?spm=a2 ... t=9#detail

HX711 DIY 5kg Scale with LCD1602 Uno R3
https://www.alibaba.com/product-detail/ ... 6.html?s=p

SparkFun OpenScale $32
https://www.sparkfun.com/products/13261
Last edited by tlfong01 on Sat Dec 01, 2018 7:12 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sat Dec 01, 2018 4:27 am

tlfong01 wrote:
Fri Nov 30, 2018 1:24 pm
Rpi3B+ ESP8266-12 HX711 Based Smart 5kg/1g Weight Scale Making Notes Part 11
So the 5kg load cell full bridge is tested OK. Next step is to test the HX711 amplifier.

Which load cell to test, 500g, 1kg, or 5kg?

So I am going to write the python program to test HX711 and load cell. I found my bench over crowded, and awkward to squeeze in the kitchen scale and the calibrating weights. So I decide to only test the smallest load cell, the 500g pocket scale.

My ridiculously tiny electronics workshop is also over crowded and messy, so I need to again tidying up by throwing away more unwanted things
.

We girls in the Ridiculously tiny flat in Hong Kong - 2017feb 482,868 views
https://www.youtube.com/watch?v=979a8b0lP2M

The Life Changing Magic of Tidying Up - Marie Kondo
viewtopic.php?f=37&t=77158&start=400#p1367846

...
Attachments
hx711_test_setup_2018dec0101.jpg
hx711_test_setup_2018dec0101.jpg (177.6 KiB) Viewed 6689 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sat Dec 01, 2018 5:47 am

tlfong01 wrote:
Sat Dec 01, 2018 4:27 am
Which load cell to test, 500g, 1kg, or 5kg?

HX711 ESP8266 decoupling/rewiring notes

And I am disconnecting ESP8266 wires from HX711.
Attachments
hx711_esp8266_decoupling_2018dec0103.jpg
hx711_esp8266_decoupling_2018dec0103.jpg (155.49 KiB) Viewed 6668 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sat Dec 01, 2018 8:29 am

tlfong01 wrote:
Sat Dec 01, 2018 5:47 am
And I am disconnecting ESP8266 wires from HX711.

HX711 Test Cheater Cable

HX711 during operation, input channels A and B read the output from the Wheatstone bridge.

However, for testing, an adjustable voltage reference 0mV ~ 7.5mV, pretending to be a Wheatstone bridge output, will be used to cheat the HX711.

...
Attachments
hx711_cheater_cable_2018dec0101.jpg
hx711_cheater_cable_2018dec0101.jpg (185.26 KiB) Viewed 6656 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sat Dec 01, 2018 9:52 am

tlfong01 wrote:
Sat Dec 01, 2018 8:29 am
HX711 Test Cheater Cable
HX711 during operation, input channels A and B read the output from the Wheatstone bridge.
However, for testing, an adjustable voltage reference 0mV ~ 7.5mV, pretending to be a Wheatstone bridge output, will be used to cheat the HX711.

HX711 Timing Notes

Summary

1. Pulse width must be less than 50 uS + 50 uS = 100 uS = 1 / 100 uS = 10 kHz.

2. Write convert command = after each conversion period, 25, 26, or 27 pulses.

3. Conversion time for 10 CPS = 1000mS / 10 = 100mS, for 80 CPS = 12.5 mS.

/ to continue, ...


...
Attachments
hx711_timing_2018dec0103.jpg
hx711_timing_2018dec0103.jpg (195.5 KiB) Viewed 6638 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Sun Dec 02, 2018 6:28 am

tlfong01 wrote:
Sat Dec 01, 2018 9:52 am

HX711 Rate Select Notes

OpenScale Applications and Hookup Guide
https://learn.sparkfun.com/tutorials/op ... e-features

Power Cycling

When the report rate is above 500ms OpenScale will automatically turn off the power to the load cell between readings. This saves power and limits the amount of localized heating of the strain gauges.

The HX711 requires around 500ms after power-up to stabilize. If the report rate is set below 500ms OpenScale will keep the HX711 on all the time. This will not damage the load cell but it may affect the accuracy of the readings over multiple hours of consecutive readings.


Rate Jumper

The Rate jumper selects between two rates: 10 samples per second (SPS) or 80 samples per second. By default there is a short between the two pads on the board connecting the HX711 RATE pin to ground and setting the rate at 10SPS. This decreases the sample input noise to 50nV (makes the readings less noisy) but increases the startup time (from power save mode) to 400ms.

Opening the jumper will set the sample rate to 80SPS, increasing the noise to 90nV, and decreasing the startup time to 100ms. Open the jumper by cutting this jumper with a hobby knife. The jumper can be closed again with solder if necessary.

...
Attachments
hx711_rate_select_2018dec0201.jpg
hx711_rate_select_2018dec0201.jpg (171.22 KiB) Viewed 6609 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Tue Dec 04, 2018 6:32 am

tlfong01 wrote:
Sun Dec 02, 2018 6:28 am

MCP23017 Troubleshooting notes - setting up another RPi

I found the HX711 program has intermittent failures, with the remote error message "Remote IO errors". I think there are many causes, including the following:

1. Rpi power supply not stable.
2. Rpi I2C port damaged.
3. I2C connecting cables too long,
4. Poor electrical contacts of connecting wires and IC sockets etc.
5. many more other reasons.


To make hardware troubleshooting easy, I decided to setup another Rpi, with the same configuration, so I can quickly swap hardware to narrow down problem areas.

Another reason is that the current Rpi with an A4 size foot print is too big to squeeze into my ridiculously tiny test bench. The new Rpi's foot print will be half of the old one.

...
Attachments
rpi3b_sys_b_2018dec0401.jpg
rpi3b_sys_b_2018dec0401.jpg (172.76 KiB) Viewed 6555 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Tue Dec 04, 2018 8:22 am

tlfong01 wrote:
Tue Dec 04, 2018 6:32 am
MCP23017 Troubleshooting notes - setting up another RPi

XL4015E 5V 5A Heavy Duty PSU dedicated to Rpi
...
Attachments
rpi_psu_12v_2a_5v_5a_2018dec0401.jpg
rpi_psu_12v_2a_5v_5a_2018dec0401.jpg (171.62 KiB) Viewed 6544 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: Reading old weight scale

Tue Dec 04, 2018 2:02 pm

tlfong01 wrote:
Tue Dec 04, 2018 8:22 am
MCP23017 Troubleshooting notes - setting up another RPi
XL4015E 5V 5A Heavy Duty PSU dedicated to Rpi

Setting up another Rpi for swap testing

Part A - Download stretch 2018nov zipped image file
Raspbian Stretch with desktop and recommended software - 2018dec04hkt2104
https://www.raspberrypi.org/downloads/raspbian/
Image with desktop and recommended software based on Debian Stretch
Version:November 2018
Release date:2018-11-13
Kernel version:4.14
Release notes:Link
Download TorrentDownload ZIP
SHA-256: 0ca644539fdaf4e19ec7cebf9e61c049b82ba45b1a21cdec91fa54bd59d660d2
Start 2018dec04hkt21:05 Finish 21:59 Total download time = 54 min

Part B - Create Boot SD Card
1.0 Extract image from downloaded zip file.
1.1 D:/rpi_stretch_2018dec04/work2/2018-11-13-raspbian-stretch-full.img
1.2 Win10 quick format SD card
1.3 SDFormatter V4.0 quick format SD card (must!)
1.4 Win32DiskImager - 1.0 to copy image to SD card
1.5 Generate SHA256 hash = 29b88e98b94aca1dde6bbf5bce3f3a382f7f89f2b166b570587369ddd6109832
1.6 Copy image to SD card Master copy, Copy 0 (speed 6MB/s to 15 MB/s, Total time about 7.5 min)
1.7 Copy more SD cards Copy 1, 2, 3, ...


/ to continue, ...

...
Attachments
rpi3b_sys_b_2018dec0402.jpg
rpi3b_sys_b_2018dec0402.jpg (187.76 KiB) Viewed 6530 times
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”