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

Re: Reading old weight scale

Fri Nov 23, 2018 11:59 am

tlfong01 wrote:
Fri Nov 23, 2018 8:11 am
1kg Load Cell Test Results
Load / Output
500ml water = -1.9V
500ml water + 110 ml milk = -2.2V
Sensitivity Calculation

Linearity Graph
...
Attachments
linearity_2018nov2302.jpg
linearity_2018nov2302.jpg (73.37 KiB) Viewed 4099 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 23, 2018 2:20 pm

tlfong01 wrote:
Fri Nov 23, 2018 8:11 am
1kg Load Cell Test Results

5kg Load Cell Test Results

I have also tested a straight bar 5kg load cell.

/ to continue, ...
Attachments
load_cell_5kg_test_results_2018nov2303.jpg
load_cell_5kg_test_results_2018nov2303.jpg (184.96 KiB) Viewed 4088 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 Nov 24, 2018 4:03 am

tlfong01 wrote:
Fri Nov 23, 2018 11:59 am
1kg Load Cell Test Results
Load / Output
500ml water = -1.9V
500ml water + 110 ml milk = -2.2V
Sensitivity Calculation
Linearity Graph

1kg Load Cell Testing Results Update

Last time I had no confidence that the fake load cell worked, and also my hardware set up ok, so I was a bit casual and did not include the tray weight of about 160g. Now I have added the tray weight to the Excel worksheet, to make my sensitivity calculation more precise.

The sensitivity is about 0.43 mV/V
...
Attachments
load_cell_1kg_results_2018nov2401.jpg
load_cell_1kg_results_2018nov2401.jpg (160.01 KiB) Viewed 3986 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 Nov 24, 2018 4:41 am

tlfong01 wrote:
Sat Nov 24, 2018 4:03 am
1kg Load Cell Test Results
Load / Output
500ml water = -1.9V
500ml water + 110 ml milk = -2.2V
Sensitivity Calculation
Linearity Graph
1kg Load Cell Testing Results Update
Last time I had no confidence that the fake load cell worked, and also my hardware set up ok, so I was a bit casual and did not include the tray weight of about 160g. Now I have added the tray weight to the Excel worksheet, to make my sensitivity calculation more precise.
The sensitivity is about 0.43 mV/V

5kg Load Cell Test Results

Now I am using Excel to calculate the sensitivity of the 5kg load cell.

The results is too good to be true:

1.03 mV/V ! :mrgreen:
...
Attachments
load_cell_5kg_results_2018nov2402.jpg
load_cell_5kg_results_2018nov2402.jpg (177.72 KiB) Viewed 3977 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 Nov 24, 2018 5:30 am

tlfong01 wrote:
Sat Nov 24, 2018 4:41 am
1kg Load Cell Test Results
Load / Output 500ml water = -1.9V 500ml water + 110 ml milk = -2.2V
Sensitivity Calculation Linearity Graph
1kg Load Cell Testing Results Update
Last time I had no confidence that the fake load cell worked, and also my hardware set up ok, so I was a bit casual and did not include the tray weight of about 160g. Now I have added the tray weight to the Excel worksheet, to make my sensitivity calculation more precise.
The sensitivity is about 0.43 mV/V
5kg Load Cell Test Results
Now I am using Excel to calculate the sensitivity of the 5kg load cell.
The results is too good to be true: 1.03 mV/V!

Load Cell Calibration Standard Weights

I am using a 3.5L fish tank, and 1L/1.2L lunch boxs filled with tap water as standard weights to calibrate the 1kg and 5kg load cells. For the 5kg load cell, I have done two sets of tests, one set the fish tank and a lunch box, the second set with 4 lunch boxes. The results of the first set is too good to be true. Now I am checking out the second set to see if I had a fake positive.
...
Attachments
calibration_weights_2018nov2401.jpg
calibration_weights_2018nov2401.jpg (145.58 KiB) Viewed 3964 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 Nov 24, 2018 7:26 am

tlfong01 wrote:
Sat Nov 24, 2018 5:30 am
For the 5kg load cell, I have done two sets of tests, one set the fish tank and a lunch box, the second set with 4 lunch boxes. The results of the first set is too good to be true. Now I am checking out the second set to see if I had a fake positive.

Load Cell Test Results Verified OK

I found 2nd test results looks like the 1st set. I quickly concluded that every thing is OK.

I am taking a break of testing load cells, next step is testing the HX711 thing.
...
Attachments
load_cell_1kg_5kg_results_2018nov2402.jpg
load_cell_1kg_5kg_results_2018nov2402.jpg (167.54 KiB) Viewed 3937 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 Nov 24, 2018 8:16 am

tlfong01 wrote:
Sat Nov 24, 2018 7:26 am
I am taking a break of testing load cells, next step is testing the HX711 thing.

HX711 Signal Analysis

Output Format

The output 24 bits of data is in 2’s complement format. When input differential signal goes out of the 24 bit range, the output data will be saturated at 800000h (MIN) or 7FFFFFh (MAX), until the input signal comes back to the input range.

Serial Interface

Pin PD_SCK and DOUT are used for data retrieval, input selection, gain selection and power down controls.

When output data is not ready for retrieval, digital output pin DOUT is high. Serial clock input PD_SCK should be low.

When DOUT goes to low, it indicates data is ready for retrieval.


By applying 25~27 positive clock pulses at the PD_SCK pin, data is shifted out from the DOUT output pin.

Each PD_SCK pulse shifts out one bit, starting with the MSB bit first, until all 24 bits are shifted out.

The 25th pulse at PD_SCK input will pull DOUT pin back to high.


Input and gain selection is controlled by the number of the input PD_SCK pulses. PD_SCK clock pulses should not be less than 25 or more than 27 within one conversion period, to avoid causing serial communication error.

25 pulses = A channel, gain 128

26 pulses = B channel, gain 32

27 pulses = A channel, gain 64


Clock high time = min 0.2 uS, max 50 uS

Clock low time = min 0.2 uS

0.2uS = 1,000,000 / 0.2 = 5 MHz,

50uS = 1,000,000 / 50 = 20 kHz)

...
Attachments
hx711_signal_2018nov2401.jpg
hx711_signal_2018nov2401.jpg (95.77 KiB) Viewed 3925 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 Nov 24, 2018 2:27 pm

tlfong01 wrote:
Sat Nov 24, 2018 8:16 am
HX711 Signal Analysis
Output Format
The output 24 bits of data is in 2’s complement format. When input differential signal goes out of the 24 bit range, the output data will be saturated at 800000h (MIN) or 7FFFFFh (MAX), until the input signal comes back to the input range.
Serial Interface
25 pulses = A channel, gain 128
26 pulses = B channel, gain 32
27 pulses = A channel, gain 64

Clock high time = min 0.2 uS, max 50 uS
Clock low time = min 0.2 uS
0.2uS = 1,000,000 / 0.2 = 5 MHz,
50uS = 1,000,000 / 50 = 20 kHz)

HX711 Testing Plan

1. Test input 1 = bench mark 0~5.5mV from adj regulated PSU
2. Test input 2 = real output from 5kg load cell.


ESP8266 Test Plan

1. Output function to write 10uS, 10kHz, 25, 26, 27 pulses to HX711 Channel B.
2. Input function to read 24 bits output from HX711

...
Attachments
hx711_test_setup_2018nov2401.jpg
hx711_test_setup_2018nov2401.jpg (168.65 KiB) Viewed 3864 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 Nov 24, 2018 3:01 pm

tlfong01 wrote:
Sat Nov 24, 2018 2:27 pm
ESP8266 Test Plan
...
1. Output function to write 10uS, 10kHz, 25, 26, 27 pulses to HX711 Channel B.

Notes on writing a NodeMCU Lua program to output 26 10kHz pulses from ESP8266

Now I am doing the following preparation work.

1. Start ESPlorer.
2. Format flash.
3. Upload two debugging program tools to flash.
4. Save the two debugging programs in Snippet 0 and Snippet 1.
5. Run the print Global variables and save a record.
6. Run the print Flash files and save a record.


The log file is listed below.

...

Code: Select all

Wemos D1 Mini setting up snippets - tlfong01 2018nov24hkt2248

PORT OPEN 115200
Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware...

Can't autodetect firmware, because proper answer not received (may be unknown firmware). 
Please, reset module or continue.
!@#¥%……&*()

Flash sig not correct: 0 vs fafaaf50

NodeMCU custom build by frightanic.com
	branch: master
	commit: c708828bbe853764b9de58fb8113a70f5a24002d
	SSL: false
	modules: dht,ds18b20,file,gpio,hdc1080,http,i2c,mqtt,net,node,ow,pcm,pwm,rtctime,spi,tmr,uart,wifi
build created on 2018-10-25 07:35
powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)
lua: cannot open init.lua

> file.format()
format done.

> Uploading to ESP file pf07.lua...Success
Uploading to ESP file pg07.lua...Success

> -- printFlashFiles V07 tlfong01 2018nov24hkt2238 --
> 
> function printFlashFiles()
>> fileList = file.list()
>> for name, size in pairs(fileList)
>> do
>> print('name =', name, 'size =', size)
>> end
>> end
> 
> printFlashFiles()

name =	pf07.lua	size =	224
name =	pg07.lua	size =	210

> title = 'pg07.lua - printGlobalVar v07 tlfong01 2018nov24hkt2235'
> 
> function printGlobalVar()
>> for var, value in pairs(_G)
>> do
>> print ('variable =', var, 'value =', value)
>> end
>> end
> 
> printGlobalVar()
variable =	module	value =	function: 0x3fff0d50
variable =	pairs	value =	function: 0x3fff11e0
variable =	__index	value =	lightfunction: 0x402543c4
variable =	package	value =	table: 0x3fff0b70
variable =	_G	value =	table: 0x3fff05f8
variable =	require	value =	function: 0x3fff0d90
variable =	ipairs	value =	function: 0x3fff1008
variable =	printFlashFiles	value =	function: 0x3fff06b0
variable =	title	value =	pg07.lua - printGlobalVar v07 tlfong01 2018nov24hkt2235
variable =	printGlobalVar	value =	function: 0x3fff09c0
variable =	fileList	value =	table: 0x3fff0a50
variable =	newproxy	value =	function: 0x3fff12a0

> -- printFlashFiles V07 tlfong01 2018nov24hkt2238 --
> 
> function printFlashFiles()
>> fileList = file.list()
>> for name, size in pairs(fileList)
>> do
>> print('name =', name, 'size =', size)
>> end
>> end
> 
> printFlashFiles()
name =	pf07.lua	size =	224
name =	pg07.lua	size =	210
> 
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 Nov 25, 2018 4:23 am

tlfong01 wrote:
Sat Nov 24, 2018 7:26 am
I am taking a break of testing load cells, next step is testing the HX711 thing.

Small size load cells

The straight bar load cell is a bit bulky, and arkward to fix. Next time I resume playing Wheatstone bridge, I think I would consider miniature versions.

Appendices - Miniature load cell references

AliExpress BF350-3AA Precision resistive strain gauge load cell - US$3/10 pieces
https://www.aliexpress.com/item/Free-sh ... 60339.html

BF350-3AA STRAIN GAUGE SENSOR Model HCSENS0037 £ 1.98
https://hobbycomponents.com/sensors/962 ... uge-sensor

A resistive strain gauge sensor with a 350 ohm nominal resistance which varies when a force is applied. By measuring the change in the sensors resistance a measurement of the force applied to it can be obtained. Note that strain gauges exhibit small changes in resistance and so this sensor should be used in a Wheatstone bridge

BE120-3AA ¥3.20
https://detail.tmall.com/item.htm?spm=a ... 6acdd72af8

BF350-3AA-15
http://shop.cpu.com.tw/html/2603/BF350-3AA-15.html
http://shop.cpu.com.tw/product/46508/info/

Coding System of Strain Gauges
https://www.elecrow.com/download/Coding ... ersion.pdf

BX120/BF350
https://detail.tmall.com/item.htm?spm=a ... abbucket=6
https://detail.tmall.com/item.htm?spm=a ... acdd72af8 ...
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 Nov 25, 2018 5:10 am

Neomorph wrote:
Sat Nov 17, 2018 4:03 pm
digital weight scale ...
to simply read out the information from the scale and print it to the terminal? ...
someone using an HX711 weight sensor ...

HX711 based Digital Weight Scale

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 data log and print anything you like, or add ESP8266 to wifi you reading, ... :lol:

AliExpress 1602 Module Display For Arduino Uno Raspberry Pi -US$2.25
https://www.aliexpress.com/item/1PCS-LC ... 02339.html
...
Attachments
digital_scale_2018nov2502.jpg
digital_scale_2018nov2502.jpg (185.11 KiB) Viewed 3814 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 Nov 25, 2018 7:18 am

tlfong01 wrote:
Sat Nov 24, 2018 3:01 pm
Notes on writing a NodeMCU Lua program to output 26 10kHz pulses from ESP8266
Now I am doing the following preparation work.

Saving init.lua in ESPlorer snippets and ESP8266 Flash

So I have done more preparation work, as list below.

1. Write a Hello World, saved it in ESPlorer as snippets and also in ESP8266 flash, which now has the following files.

> printFlashFiles()
name = init.lua size = 140
name = pg07.lua size = 210
name = pf07.lua size = 224
name = hw08.lua size = 140


I also listed the global variables for reference

> printGlobalVar()
variable = module value = function: 0x3fff0d50
variable = pairs value = function: 0x3fff11e0
variable = __index value = lightfunction: 0x402543c4
variable = package value = table: 0x3fff0b70
variable = _G value = table: 0x3fff05f8
variable = require value = function: 0x3fff0d90
variable = ipairs value = function: 0x3fff1008
variable = printFlashFiles value = function: 0x3fff09f0
variable = title value = pg07.lua - printGlobalVar v07 tlfong012018nov24hkt2235
variable = printHelloWorld value = function: 0x3fff09a0
variable = fileList value = table: 0x3fff13d8
variable = newproxy value = function: 0x3fff12a0
variable = printGlobalVar value = function: 0x3fff06b0
...

Code: Select all

NodeMCU custom build by frightanic.com
	branch: master
	commit: c708828bbe853764b9de58fb8113a70f5a24002d
	SSL: false
	modules: dht,ds18b20,file,gpio,hdc1080,http,i2c,mqtt,net,node,ow,pcm,pwm,rtctime,spi,tmr,uart,wifi
 build created on 2018-10-25 07:35
 powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)

Hello World

> title = 'hw08.lua - printHelloWorld v08 tlfong01 2018nov25hkt1457'
> 
> function printHelloWorld()
>> print('Hello World')
>> end
> 
> printHelloWorld()
Hello World

> -- printFlashFiles V07 tlfong01 2018nov24hkt2238 --
> 
> function printFlashFiles()
>> fileList = file.list()
>> for name, size in pairs(fileList)
>> do
>> print('name =', name, 'size =', size)
>> end
>> end
> 
> printFlashFiles()
name =	init.lua	size =	140
name =	pg07.lua	size =	210
name =	pf07.lua	size =	224
name =	hw08.lua	size =	140

> title = 'pg07.lua - printGlobalVar v07 tlfong01 2018nov24hkt2235'
> 
> function printGlobalVar()
>> for var, value in pairs(_G)
>> do
>> print ('variable =', var, 'value =', value)
>> end
>> end
> 
> printGlobalVar()

variable =	module	value =	function: 0x3fff0d50
variable =	pairs	value =	function: 0x3fff11e0
variable =	__index	value =	lightfunction: 0x402543c4
variable =	package	value =	table: 0x3fff0b70
variable =	_G	value =	table: 0x3fff05f8
variable =	require	value =	function: 0x3fff0d90
variable =	ipairs	value =	function: 0x3fff1008
variable =	printFlashFiles	value =	function: 0x3fff09f0
variable =	title	value =	pg07.lua - printGlobalVar v07 tlfong01 2018nov24hkt2235
variable =	printHelloWorld	value =	function: 0x3fff09a0
variable =	fileList	value =	table: 0x3fff13d8
variable =	newproxy	value =	function: 0x3fff12a0
variable =	printGlobalVar	value =	function: 0x3fff06b0
> 
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 Nov 25, 2018 8:24 am

tlfong01 wrote:
Sun Nov 25, 2018 7:18 am
Notes on writing a NodeMCU Lua program to output 26 10kHz pulses from ESP8266

ESP8266 writing 26 pulses to HX711 Program Testing Notes

Now I have debugged a program to blink D4 LED 26 times. The blink time is 100mS or 10Hz. I am not sure if ESP8266 can blink 10 times faster, at 10kHz. The program is listed below.


ESP8266 Blinky YouTube
https://youtu.be/fjFXk1qtBI4
...

Code: Select all

-- bl2608 - blink D4 LED 26 times tlfong01 2018nov25hkt1606

title = 'bl26'
printTitle(title)

High, Low = true, false
Output, Input = true, false
D0, D1, D2, D3, D4, D5, D6, D7, D8 = 0, 1, 2, 3, 4, 5, 6, 7, 8
TenthSecond, EighthSecond, FifthSecond, QuarterSecond   = 100,   125,    200,   250
HalfSecond,  OneSecond,    TwoSeconds,  FourSeconds     = 500,   1000,  2000,  4000
EightSeconds, TenSeconds, TwelveSeconds, SixteenSeconds = 8000, 10000, 12000, 16000
OneTime,   TwoTimes,    ThreeTimes,    FourTimes    =  1,  2,  3,  4 
FiveTimes, SixTimes,    SevenTime,     EightTimes   =  5,  6,  7,  8
TenTimes,  TwelveTimes, FourTeenTimes, SixteenTimes = 10, 12, 14, 16
TwentySixTimes = 26

function printTitle(title)
  local threeStars = '***'; local twoNewLines = '\n\n'
  print(twoNewLines, threeStars, title, threeStars)
end

function printTitleNum(title, num)
  local twoNewLines = '\n\n'; local fiveSpaces = '     '
  print(fiveSpaces, title, num)
end

function setPinMode(pinNum, pinMode)
  if pinMode == Output
    then
      gpio.mode(pinNum, gpio.OUTPUT)  
    else
      gpio.mode(pinNum, gpio.INPUT) 
  end
end

function setPinHigh(pinNum)
  gpio.write(pinNum, gpio.HIGH)  
end

function setPinLow(pinNum)
  gpio.write(pinNum, gpio.LOW)  
end

function setAllPinsOutput()
  for i = 0, 8, 1
    do
      setPinMode(i, Output)
  end
end

function setAllPinsLow()
  for i = 0, 8, 1
    do
      setPinLow(i)
  end
end

function setupPins()
  setAllPinsOutput()
  setAllPinsLow()
end

function togglePin(pinTable)
  pinNum		= pinTable.pinNum
  highTime		= pinTable.highTime
  lowTime		= pinTable.lowTime
  toggleCount		= pinTable.toggleCount
  toggleDelayTime	= pinTable.toggleDelayTime
  taskCount		= pinTable.taskCount

  printTitleNum('pinNum          =', pinNum)
  printTitleNum('highTime        =', highTime)
  printTitleNum('lowTime         =', lowTime)
  printTitleNum('toggleCount     =', toggleCount)
  printTitleNum('toggleDelayTime =', toggleDelayTime)
  printTitleNum('taskCount       =', taskCount)

  highTimer = tmr.create()
  lowTimer  = tmr.create()
  taskTimer = tmr.create()

  function highTimerCallback()
    setPinLow(pinNum) 
    currentToggleCount = currentToggleCount - 1
    if currentToggleCount > 0
      then
        lowTimer:start()
      else
	taskTimer:start()
    end
  end

  function lowTimerCallback()
    setPinHigh(pinNum)  
    highTimer:start()
  end

  function taskTimerCallback()
    taskCount = taskCount - 1
    printTitleNum('taskCount =', taskCount)
      if taskCount >= 0
        then
          currentToggleCount = toggleCount
          setPinHigh(pinNum)
          highTimer:start()
        else
	  printTitle('End of all toggle tasks.')
	  highTimer:stop()
	  lowTimer:stop()
	  taskTimer:stop()
      end 
  end

  highTimer:register(highTime,        tmr.ALARM_SEMI, highTimerCallback)
  lowTimer:register (lowTime,         tmr.ALARM_SEMI, lowTimerCallback)
  taskTimer:register(toggleDelayTime, tmr.ALARM_SEMI, taskTimerCallback)

  taskTimer:start()

end

pinTable01 = 
  {
    pinNum          = D4,
    highTime        = TenthSecond, 
    lowTime         = TenthSecond, 
    toggleCount     = TwoTimes, 
    toggleDelayTime = OneSecond,
    taskCount       = TwentySixTimes
  }

function main()
  printTitle(title)
  setupPins()
  togglePin(pinTable01)
end

main() 

*** Sample Output ***
...
> pinTable01 =
>> {
>> pinNum          = D4,
>> highTime        = TenthSecond,
>> lowTime         = TenthSecond,
>> toggleCount     = TwoTimes,
>> toggleDelayTime = OneSecond,
>> taskCount       = TwentySixTimes
>> }
> 
> function main()
>> printTitle(title)
>> setupPins()
>> togglePin(pinTable01)
>> end
> 
> main()
	***	bl26	***
     	pinNum          =	4
     	highTime        =	100
     	lowTime         =	100
     	toggleCount     =	2
     	toggleDelayTime =	1000
     	taskCount       =	26
>      	taskCount =	25
     	taskCount =	24
     	taskCount =	23
     	taskCount =	22
     	taskCount =	21
     	taskCount =	20
     	taskCount =	19
     	taskCount =	18
     	taskCount =	17
     	taskCount =	16
     	taskCount =	15
     	taskCount =	14
     	taskCount =	13
     	taskCount =	12
     	taskCount =	11
     	taskCount =	10
     	taskCount =	9
     	taskCount =	8
     	taskCount =	7
     	taskCount =	6
     	taskCount =	5
     	taskCount =	4
     	taskCount =	3
     	taskCount =	2
     	taskCount =	1
     	taskCount =	0
     	taskCount =	-1
	***	End of all toggle tasks.	***
 
Attachments
hx711_youtube_2018nov2501.jpg
hx711_youtube_2018nov2501.jpg (153.33 KiB) Viewed 3791 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 Nov 25, 2018 1:29 pm

tlfong01 wrote:
Sun Nov 25, 2018 8:24 am
Notes on writing a NodeMCU Lua program to output 26 10kHz pulses from ESP8266
ESP8266 writing 26 pulses to HX711 Program Testing Notes
Now I have debugged a program to blink D4 LED 26 times. The blink time is 100mS or 10Hz.

TTP223 Capacitive Touch Button to Control HX711 Weight Sensor

Now I am thinking of using 0.5 yuan / piece touch button as input to control HX711

Button 1 - Channel B 32x
Button 2 - Channel A 64x
Button 3 - Channle A 128X
Button 4 - Reset


AliExpress TTP223 Capacitive Self Locking Touch switch sensor US$0.1 / piece
https://www.aliexpress.com/item/10PCS-L ... aa092bcf68

...
Attachments
ttp223_touch_button_2018nov2502jpg.jpg
ttp223_touch_button_2018nov2502jpg.jpg (162.57 KiB) Viewed 3772 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

Mon Nov 26, 2018 1:18 pm

tlfong01 wrote:
Sun Nov 25, 2018 8:24 am
Notes on writing a NodeMCU Lua program to output 26 10kHz pulses from ESP8266
ESP8266 writing 26 pulses to HX711 Program Testing Notes
Now I have debugged a program to blink D4 LED 26 times. The blink time is 100mS or 10Hz. I am not sure if ESP8266 can blink 10 times faster, at 10kHz.

Bad News - Program cannot blink faster than 500Hz! :(

So I changed the pintTable01 to below, with highTime and lowTime = 1 mS, and used my scope to check if D4 pin output is 1 / (1mS + 1mS) = 500Hz. Everything went well.

pinTable01 =
{
pinNum = 4,
highTime = 1,
lowTime = 1,

toggleCount = 1,
toggleDelayTime = 1,
taskCount = 1000000
}


Then I set highTime lowTime = 0.1ms, and 0.01mS etc, to get higher frequencies. However I already got the following error message at 0.1mS:

stdin:46: bad argument #1 to 'register' (Range: 1-6870947)

Now I know the smallest time for NodeMCU tmr is 1mS, or the highest frequency is 500Hz!

HX711's max high time is 50uS, or 1/50uS = 1000k/50 = 20 kHz!

So I am going back to the drawing board!
...
Attachments
esp8266_1khz_output_2018nov2602.jpg
esp8266_1khz_output_2018nov2602.jpg (139.66 KiB) Viewed 3743 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 Nov 27, 2018 4:33 am

tlfong01 wrote:
Sun Nov 25, 2018 5:10 am
HX711 based Digital Weight Scale
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 data and print anything you like, or add ESP8266 to wifi you reading, ...

Digital Weight Scale Hacking Notes

So this morning I started messing around with my toy. I found it very hacker friendly. Just loosen two screws inside the battery apartment, the weight tray with the load cell can easily be removed.

It took me only 30 seconds. I think the designer is himself a hacker, therefore has made the toy so hacker friendly, ... :lol:
...
Attachments
digi_scale_hacking_2018nov2701.jpg
digi_scale_hacking_2018nov2701.jpg (191.2 KiB) Viewed 3723 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 Nov 27, 2018 4:40 am

tlfong01 wrote:
Tue Nov 27, 2018 4:33 am
Digital Weight Scale Hacking Notes 1, 2
So this morning I started messing around with my toy. I found it very hacker friendly. Just loosen two screws inside the battery apartment, the weight tray with the load cell can easily be removed.
It took me only 30 seconds. I think the designer is himself a hacker, therefore has made the toy so hacker friendly, ...

Digital Weight Scale Hacking Notes 3, 4

It took me another 30 seconds to loosen two little screws at the top of the case inside, and removed the PCB and LCD. Then I cut the load cell's red, black, green, and white connecting wires and separated the load cell with tray from the PCB.
...
Attachments
digi_scale_hacking_2018nov2703.jpg
digi_scale_hacking_2018nov2703.jpg (191.3 KiB) Viewed 3716 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 Nov 27, 2018 5:27 am

tlfong01 wrote:
Tue Nov 27, 2018 4:40 am
Digital Weight Scale Hacking Notes 1, 2
So this morning I started messing around with my toy. I found it very hacker friendly. Just loosen two screws inside the battery apartment, the weight tray with the load cell can easily be removed.
It took me only 30 seconds. I think the designer is himself a hacker, therefore has made the toy so hacker friendly, ...
Digital Weight Scale Hacking Notes 3, 4
It took me another 30 seconds to loosen two little screws at the top of the case inside, and removed the PCB and LCD. Then I cut the load cell's red, black, green, and white connecting wires and separated the load cell with tray from the PCB.

Digital Weight Scale Hacking Notes 5, 6

Now that the load cell is detached from the digital scale, HX711 (I guess what the black blob is) now has no input, and can report nothing but zero. I think I can any time attach a load cell of any weight, say 500g to 20kg to it, as long as the power supply is 3V to 5V (just guessing), and output voltage (to find out later) is the same as the original 500g load cell.

The detached load cell has a red blk resistance of 660R. The two M3 screws is 10mm centre to centre.

Everything looks OK. Next step is to secure the load cell with plate to somewhere.
...
Attachments
digi_scale_hacking_2018nov2706.jpg
digi_scale_hacking_2018nov2706.jpg (190.44 KiB) Viewed 3705 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 Nov 27, 2018 7:46 am

tlfong01 wrote:
Tue Nov 27, 2018 5:27 am
Digital Weight Scale Hacking Notes 1, 2
Digital Weight Scale Hacking Notes 3, 4
Digital Weight Scale Hacking Notes 5, 6
The detached load cell has a red blk resistance of 660R. The two M3 screws is 10mm centre to centre.
Everything looks OK. Next step is to secure the load cell with plate to somewhere.

Digital Weight Scale Hacking Notes 7, 8

Now that the load cell with tray is sitting tight, next step is to add a high class I2C LCD to the whole assembly.
...
Attachments
digi_scale_hacking_2018nov2707.jpg
digi_scale_hacking_2018nov2707.jpg (191.16 KiB) Viewed 3705 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 Nov 27, 2018 8:03 am

tlfong01 wrote:
Tue Nov 27, 2018 7:46 am
Digital Weight Scale Hacking Notes 1, 2
Digital Weight Scale Hacking Notes 3, 4
Digital Weight Scale Hacking Notes 5, 6
Digital Weight Scale Hacking Notes 7, 8
Now that the load cell with tray is sitting tight, next step is to add a high class I2C LCD to the whole assembly.

Digital Weight Scale Hacking Notes 9

And I have added a 20 char x 4 lines LCD.

AliExpress LCD2004 + I2C HD44780 I2C Module US$4.20
https://www.aliexpress.com/item/TZT-1PC ... c46475c7b8

...
Attachments
lcd2004_2018nov2702.jpg
lcd2004_2018nov2702.jpg (171.6 KiB) Viewed 3688 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 Nov 27, 2018 9:15 am

tlfong01 wrote:
Tue Nov 27, 2018 8:03 am
Digital Weight Scale Hacking Notes 9[/b]
And I have added a 20 char x 4 lines LCD.

NodeMCU Lua HX711 Module

I spent 2 hobbyist months to learn the difficult, internet driven, NodeMCU Lua, just hoping to write a blink program to blink the built in LED connection to D4 pin.

I did finally complete an almost bug free program. And now I hope to modify the blink program to blink 26 times at 20kHz, as input signal to KX711, to request for reading the weight.

Disappointedly, I found my blink program can only blink slowly, not faster than 1 kHz. In others words, my time has wasted.

So I gave up and hope to use the NodeMCU module, if any. I found one, but it only uses Channel A, not B. In other words, I cannot use Channel B for calibration and testing.

Anyway, I might just see if I can do more later. For now I will just use the NodeMCU one.

NodeMCU HX711 Module 2015-10-09 Chris Takahashi
https://nodemcu.readthedocs.io/en/maste ... les/hx711/

This module provides access to an HX711 load cell amplifier/ADC. The HX711 is an inexpensive 24bit ADC with programmable 128x, 64x, and 32x gain. Currently only channel A at 128x gain is supported.

hx711.init() Initialize io pins for hx711 clock and data.
hx711.read() Read digital loadcell ADC value.


hx711.init()
Initialize io pins for hx711 clock and data.

Syntax
hx711.init(clk, data)

Parameters
clk pin the hx711 clock signal is connected to
data pin the hx711 data signal is connected to

Returns
nil

Example
-- Initialize the hx711 with clk on pin 5 and data on pin 6
hx711.init(5,6)
hx711.read()

Read digital loadcell ADC value.

Syntax
hx711.read(mode)

Parameters
mode ADC mode. This parameter is currently ignored and reserved to ensure backward compatability if support for additional modes is added. Currently only channel A @ 128 gain is supported.

mode channel gain
0 A 128

Returns
a number (24 bit signed ADC value extended to the machine int size)

Example
-- Read ch A with 128 gain.
raw_data = hx711.read(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

Wed Nov 28, 2018 5:20 am

tlfong01 wrote:
Sat Nov 24, 2018 5:30 am
1kg Load Cell Test Results
Load / Output 500ml water = -1.9V 500ml water + 110 ml milk = -2.2V
The sensitivity is about 0.43 mV/V
5kg Load Cell Test Results
Now I am using Excel to calculate the sensitivity of the 5kg load cell.
The results is too good to be true: 1.03 mV/V!
Load Cell Calibration Standard Weights
I am using a 3.5L fish tank, and 1L/1.2L lunch boxs filled with tap water as standard weights to calibrate the 1kg and 5kg load cells. For the 5kg load cell, I have done two sets of tests, one set the fish tank and a lunch box, the second set with 4 lunch boxes.

500g Load Cell Calibration Data

Sensitivity Calculation

Bridge input = 3.27V

Full load 500g output = 4.2mV

Sensitivity = 4.2mV / 3.27V = 1.28mV/V


...
Attachments
load_cell_500g_calibrate_2018nov2802.jpg
load_cell_500g_calibrate_2018nov2802.jpg (162.87 KiB) Viewed 3664 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

Wed Nov 28, 2018 6:25 am

tlfong01 wrote:
Wed Nov 28, 2018 5:20 am
1kg Load Cell Test Results
Load / Output 500ml water = -1.9V 500ml water + 110 ml milk = -2.2V
The sensitivity is about 0.43 mV/V
5kg Load Cell Test Results
Now I am using Excel to calculate the sensitivity of the 5kg load cell.
The results is too good to be true: 1.03 mV/V!
Load Cell Calibration Standard Weights
I am using a 3.5L fish tank, and 1L/1.2L lunch boxs filled with tap water as standard weights to calibrate the 1kg and 5kg load cells. For the 5kg load cell, I have done two sets of tests, one set the fish tank and a lunch box, the second set with 4 lunch boxes.
500g Load Cell Calibration Data
Sensitivity Calculation
Bridge input = 3.27V
Full load 500g output = 4.2mV
Sensitivity = 4.2mV / 3.27V = 1.28mV/V


Calibration Weights

So I have bought some TaoBao calibration weights for my HX711 projects.

AliExpress Calibration Weight 500g 7PCS/Set 200g 100g 50g 20g 10g 5g - US$15
https://www.aliexpress.com/item/New-Arr ... 69101.html

AliExpress 500g/100g/50g/20g/10g/5g/1g Precision Chrome Calibration Scale Weight Set US$0.6 - 11
https://www.aliexpress.com/item/High-Qu ... 49748.html

TaoBao Calibration Weight Single M1, Set M2 ¥3 -19
https://detail.tmall.com/item.htm?_u=s3 ... 0932784707

...
Attachments
calibration_weights_2018nov2801.jpg
calibration_weights_2018nov2801.jpg (158.54 KiB) Viewed 3657 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

Wed Nov 28, 2018 7:57 am

tlfong01 wrote:
Wed Nov 28, 2018 6:25 am
1kg Load Cell Test Results
Load / Output 500ml water = -1.9V 500ml water + 110 ml milk = -2.2V
The sensitivity is about 0.43 mV/V
5kg Load Cell Test Results
Now I am using Excel to calculate the sensitivity of the 5kg load cell.
The results is too good to be true: 1.03 mV/V!
Load Cell Calibration Standard Weights
I am using a 3.5L fish tank, and 1L/1.2L lunch boxs filled with tap water as standard weights to calibrate the 1kg and 5kg load cells. For the 5kg load cell, I have done two sets of tests, one set the fish tank and a lunch box, the second set with 4 lunch boxes.
500g Load Cell Calibration Data
Sensitivity Calculation
Bridge input = 3.27V
Full load 500g output = 4.2mV
Sensitivity = 4.2mV / 3.27V = 1.28mV/V


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

...
Attachments
calibration_record_2018nov2801.jpg
calibration_record_2018nov2801.jpg (197.08 KiB) Viewed 3649 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

Wed Nov 28, 2018 8:20 am

tlfong01 wrote:
Tue Nov 27, 2018 9:15 am
NodeMCU Lua HX711 Module
I spent 2 hobbyist months to learn the difficult, internet driven, NodeMCU Lua, just hoping to write a blink program to blink the built in LED connection to D4 pin.
I did finally complete an almost bug free program. And now I hope to modify the blink program to blink 26 times at 20kHz, as input signal to KX711, to request for reading the weight.
Disappointedly, I found my blink program can only blink slowly, not faster than 1 kHz. In others words, my time has wasted.
So I gave up and hope to use the NodeMCU HX711 module, if any. I found one, but disappointedly it only uses Channel A, not B. In other words, I cannot use Channel B for calibration and testing.

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
viewtopic.php?f=37&t=77158&start=350#p1355771
...
I am an electronics and smart home hobbyist.

Return to “Automation, sensing and robotics”