I2C 800kHz Testing Results V4.0
by tl fong01
I2C 800kHz Testing Results V4.0 tlfong 01 2019nov24hkt1642
penzu entry link: https://penzu.com/p/724a2f82
4:53PM SUN. 11/24/2019

https://imgur.com/gallery/lea3E5A
# fpwm137.py tlfong01 2019nov24hkt1454
import os
import smbus
from time import sleep
from datetime import datetime
import fprint70 as fprint
import ftime71 as ftime
import fi2c128 as fi2c
# *** PCA9685 16 Channel PWM Controller Module Config ***
pca9685DevAddrDict = {
‘Dev0’: 0x40,
‘Dev1’: 0x41,
‘Dev2’: 0x42,
‘Dev3’: 0x43,
‘Dev4’: 0x44,
‘Dev5’: 0x45,
‘Dev6’: 0x46,
‘Dev7’: 0x47,
}
#pca9685RegAddrDict = { ‘Mode1’: 0x00,
# ‘Mode2’: 0x01,
# }
pca9685RegAddrDict = {
‘GeneralCall’ : 0x00,
‘Mode1’ : 0x00,
‘Mode2’ : 0x01,
‘SubAdr1’ : 0x02,
‘SubAdr2’ : 0x03,
‘SubAdr3’ : 0x04,
‘AllCallAdr’ : 0x05,
‘SoftwareReset’ : 0x06,
‘AllLedFullOnLow’ : 0xfa,
‘AllLedFullOnHigh’ : 0xfb,
‘AllLedFullOffLow’ : 0xfc,
‘AllLedFullOffHigh’ : 0xfd,
‘PreScale’ : 0xfe,
‘TestMode’ : 0xff,
‘LedOnLow0’ : 0x06, ‘LedOnHigh0’ : 0x07, ‘LedOffLow0’ : 0x08, ‘LedOffHigh0’ : 0x09,
‘LedOnLow1’ : 0x0a, ‘LedOnHigh1’ : 0x0b, ‘LedOffLow1’ : 0x0c, ‘LedOffHigh1’ : 0x0d,
‘LedOnLow2’ : 0x0e, ‘LedOnHigh2’ : 0x0f, ‘LedOffLow2’ : 0x10, ‘LedOffHigh2’ : 0x11,
‘LedOnLow3’ : 0x12, ‘LedOnHigh3’ : 0x13, ‘LedOffLow3’ : 0x14, ‘LedOffHigh3’ : 0x15,
‘LedOnLow4’ : 0x16, ‘LedOnHigh4’ : 0x17, ‘LedOffLow4’ : 0x18, ‘LedOffHigh4’ : 0x19,
‘LedOnLow5’ : 0x1a, ‘LedOnHigh5’ : 0x1b, ‘LedOffLow5’ : 0x1c, ‘LedOffHigh5’ : 0x1d,
‘LedOnLow6’ : 0x1e, ‘LedOnHigh6’ : 0x1f, ‘LedOffLow6’ : 0x20, ‘LedOffHigh6’ : 0x21,
‘LedOnLow7’ : 0x22, ‘LedOnHigh7’ : 0x23, ‘LedOffLow7’ : 0x24, ‘LedOffHigh7’ : 0x25,
‘LedOnLow8’ : 0x26, ‘LedOnHigh8’ : 0x27, ‘LedOffLow8’ : 0x28, ‘LedOffHigh8’ : 0x29,
‘LedOnLow9’ : 0x2a, ‘LedOnHigh9’ : 0x2b, ‘LedOffLow9’ : 0x2c, ‘LedOffHigh9’ : 0x2d,
‘LedOnLow10’ : 0x2e, ‘LedOnHigh10’ : 0x2f, ‘LedOffLow10’ : 0x30, ‘LedOffHigh10’ : 0x31,
‘LedOnLow11’ : 0x32, ‘LedOnHigh11’ : 0x33, ‘LedOffLow11’ : 0x34, ‘LedOffHigh11’ : 0x35,
‘LedOnLow12’ : 0x36, ‘LedOnHigh12’ : 0x37, ‘LedOffLow12’ : 0x38, ‘LedOffHigh12’ : 0x39,
‘LedOnLow13’ : 0x3a, ‘LedOnHigh13’ : 0x3b, ‘LedOffLow13’ : 0x3c, ‘LedOffHigh13’ : 0x3d,
‘LedOnLow14’ : 0x3e, ‘LedOnHigh14’ : 0x3f, ‘LedOffLow14’ : 0x40, ‘LedOffHigh14’ : 0x41,
‘LedOnLow15’ : 0x42, ‘LedOnHigh15’ : 0x43, ‘LedOffLow15’ : 0x44, ‘LedOffHigh15’ : 0x45,
}
ledOffHighRegNameList = [
‘LedOffHigh0’, ‘LedOffHigh1’, ‘LedOffHigh2’, ‘LedOffHigh3’,
‘LedOffHigh4’, ‘LedOffHigh5’, ‘LedOffHigh6’, ‘LedOffHigh7’,
‘LedOffHigh8’, ‘LedOffHigh9’, ‘LedOffHigh10’, ‘LedOffHigh11’,
‘LedOffHigh12’, ‘LedOffHigh13’, ‘LedOffHigh14’, ‘LedOffHigh15’,
]
pwmChannelDict = {
‘0’: {‘Name’: ‘Channel 0’, ‘Reg3Name’: ‘LedOffHigh0’},
‘1’: {‘Name’: ‘Channel 1’, ‘Reg3Name’: ‘LedOffHigh1’},
‘2’: {‘Name’: ‘Channel 2’, ‘Reg3Name’: ‘LedOffHigh2’},
‘3’: {‘Name’: ‘Channel 3’, ‘Reg3Name’: ‘LedOffHigh3’},
‘4’: {‘Name’: ‘Channel 4’, ‘Reg3Name’: ‘LedOffHigh4’},
‘5’: {‘Name’: ‘Channel 5’, ‘Reg3Name’: ‘LedOffHigh5’},
‘6’: {‘Name’: ‘Channel 6’, ‘Reg3Name’: ‘LedOffHigh6’},
‘7’: {‘Name’: ‘Channel 7’, ‘Reg3Name’: ‘LedOffHigh7’},
‘8’: {‘Name’: ‘Channel 8’, ‘Reg3Name’: ‘LedOffHigh8’},
‘9’: {‘Name’: ‘Channel 9’, ‘Reg3Name’: ‘LedOffHigh9′},
’10’: {‘Name’: ‘Channel 10’, ‘Reg3Name’: ‘LedOffHigh10′},
’11’: {‘Name’: ‘Channel 11’, ‘Reg3Name’: ‘LedOffHigh11′},
’12’: {‘Name’: ‘Channel 12’, ‘Reg3Name’: ‘LedOffHigh12′},
’13’: {‘Name’: ‘Channel 13’, ‘Reg3Name’: ‘LedOffHigh13′},
’14’: {‘Name’: ‘Channel 14’, ‘Reg3Name’: ‘LedOffHigh14′},
’15’: {‘Name’: ‘Channel 15’, ‘Reg3Name’: ‘LedOffHigh15’},
}
pca9685ControlByteDict = {
‘Mode1Config01’ : 0x00, # no restart, int clk, dsbl auto inc, normal sleep, no subs/all addr
‘Mode2Config01’ : 0x04, # no invert, o/p change on stop, totem pole, ~OE = enbl LEDs
‘Sleep’ : 0x10, # Sleep
‘WakeUp’ : 0x01, # WakeUp
‘AutoIncrement’ : 0x20, # AutoIncrement
‘ExtClock’ : 0x40, # External clock
‘Restart’ : 0x80, # Restart Pwm
‘Invert’ : 0x10, # Invert output polarity
‘TotemPole’ : 0x04, # Totem pole (not open drain
‘SoftwareResetDataByte1’ : 0x06,
‘DummyDataByte’ : 0x00,
‘EnableRestart’ : 0x01 << 7, # Mode 1 Options
‘ExternalClock’ : 0x01 << 6,
‘EnableAutoIncrement’ : 0x01 << 5,
‘Sleep’ : 0x01 << 4, # Low power, oscillator off
‘RespondToSubAddr1’ : 0x01 << 3,
‘RespondToSubAddr2’ : 0x01 << 2,
‘RespondToSubAddr3’ : 0x01 << 1,
‘RespondToAllCallAddr’ : 0x01 << 0,
‘InvertOutputLogicState’ : 0x01 << 4, # Mode 2 options
‘OutputChangeOn Ack’ : 0x01 << 3,
‘OutputTotemPole’ : 0x01 << 2,
‘LEDnHighImpedance’ : 0x01 << 1,
‘LEDn=1WhenOutDrv=1’ : 0x01 << 0,
‘Mode1Config01’ : 0x00, # No to all Mode 1 options
‘Mode2Config01’ : 0x04, # TotemPole, No to all the restMode 2 options
‘Mode1Reset’ : 0x11,
‘Sleep’ : 0x10, # Sleep, oscillator off to change frequency
‘WakeUp’ : 0x00, # Normal operation
‘AllLedFullOn’ : 0x00001000,
‘AllLedFullOff’ : 0x10000000,
‘OneLedFullOn’ : 0x00010fff,
‘OneLedFullOff’ : 0x00010010,
’24Hz’ : 0xff,
’50Hz’ : 0x7f, # 50Hz = 20 mS period
‘200Hz’ : 0x1e,
‘400Hz’ : 0x0f,
‘800Hz’ : 0x07,
‘1526Hz’ : 0x03,
‘0%’ : 0x00010fff,
‘5%’ : 0x00010f33,
‘10%’ : 0x00010e66,
‘20%’ : 0x00010ccc,
‘50%’ : 0x000107ff,
‘75%’ : 0x000103ff,
‘80%’ : 0x00010333,
‘90%’ : 0x00010199,
‘55%’ : 0x000100cc,
‘DutyCycle20%Delay10%’ : 0x019904cc,
‘500uS’ : 0x00010f99, # 0.5 mS (50Hz)
‘1000uS’ : 0x00010f33, # 1.0 mS
‘1500uS’ : 0x00010ecd, # 1.5 mS
‘2000uS’ : 0x00010e66, # 2.0 mS
‘10000uS’ : 0x000107ff, # 10.0 mS
‘Mode1Reset’: 0x11,
‘TwoMilliSeconds’ : 0.002,
‘FourMilliSeconds’ : 0.004,
‘TenMilliSeconds’ : 0.01,
‘OneTime’ : 1,
‘FourTimes’ : 4,
‘OneMillionTimes’ : 1000000,
}
dataByteDict = {
‘0x55’ : 0x55,
‘0x66’ : 0x66,
‘0x77’ : 0x77,
‘0x59’ : 0x59,
‘0x5566’ : 0x5566,
‘0x55667788’ : 0x55667788,
}
# *** Device Dict ***
devDict0 = {
‘DevNum’ : 0,
‘DevName’ : ‘Dev0’,
‘I2cBusName’ : ‘I2cBus1’,
‘Frequency’ : ’50Hz’,
}
devDict1 = {
‘DevNum’ : 1,
‘DevName’ : ‘Dev1’,
‘I2cBusName’ : ‘I2cBus3’,
‘Frequency’ : ’50Hz’,
}
devDictList = (devDict0, devDict1)
def systemInfo():
print(‘\n# *** UART BaudRate *****************************************************’)
os.system(‘grep dtparam=i2c /boot/config.txt’)
return
def repeatPingPca9685(devId, busName, devName, regName, testByteHexString, pauseBetweenPingSecondsName, repeatCountName):
#systemInfo()
fprint.printBeginExecFunction()
#devAddrDict = fi2c.pca9685DevAddrDict
devAddrDict = pca9685DevAddrDict
regAddrDict = pca9685RegAddrDict
i2cBus = fi2c.i2cBusDict[busName]
testByte = int(testByteHexString, 16)
repeatCount = pca9685ControlByteDict[repeatCountName]
pauseBetweenPingSeconds = pca9685ControlByteDict[pauseBetweenPingSecondsName]
fprint.printTitleString(‘Repeat Ping Times’, fprint.indentFormat640, repeatCount)
fprint.printTitleString(‘Now repeat pinging, Ctrl-C to exit,’, fprint.indentFormat640, ‘…..’)
for count in range(repeatCount): # *** Repeat Ping Section ***
fi2c.writeRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName, testByte)
readByte = fi2c.readRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName)
sleep(pauseBetweenPingSeconds)
if readByte == testByte:
resultsString = ‘Good’
else:
resultsString = ‘Bad’
fprint.printTitleString(‘Repeat Ping Times’, fprint.indentFormat640, repeatCount)
devAddr = devAddrDict[devName]
regAddr = regAddrDict[regName]
fprint.printTitleString(‘Date Time’, fprint.indentFormat640, str(datetime.now())[0:16])
fprint.printTitleString(‘Device Id’, fprint.indentFormat640, devId)
fprint.printTitleString(‘I2C Bus Name’, fprint.indentFormat640, busName)
fprint.printTitleString(‘Device Name’, fprint.indentFormat640, devName)
fprint.printTitleOneByteNum(‘Device Address’, fprint.indentFormat640, devAddr)
fprint.printTitleString(‘Register Name’, fprint.indentFormat640, regName)
fprint.printTitleOneByteNum(‘Register Addr’, fprint.indentFormat640, regAddr)
fprint.printTitleOneByteNum(‘Register Written’, fprint.indentFormat640, testByte)
fprint.printTitleOneByteNum(‘Register Read Back’, fprint.indentFormat640, readByte)
fprint.printTitleString(‘Results’, fprint.indentFormat640, resultsString)
fprint.printEndExecFunction()
return
def pingPca9685OneTime():
fprint.printBeginExecFunction()
repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘OneTime’)
fprint.printEndExecFunction()
return
def pingPca9685ManyTimes():
fprint.printBeginExecFunction()
repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TwoMilliSeconds’, ‘FourTimes’)
#repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘OneMillionTimes’)
#repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘FourMilliSeconds’, ‘OneMillionTimes’)
repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TwoMilliSeconds’, ‘OneMillionTimes’)
fprint.printEndExecFunction()
return
# ********************************************************************************
# *** Main Tests ***
# ********************************************************************************
pca9685PwmController = {
‘PingOneTime’ : pingPca9685OneTime,
‘PingManyTimes’: pingPca9685ManyTimes,
}
# ********************************************************************************
# *** Init/Main Functions ***
# ********************************************************************************
# *** Init Function ***
def init():
pass
return
# ********************************************************************************
#*** Main Function ***
# ********************************************************************************
def main():
init()
pca9685PwmController[‘PingOneTime’]()
pca9685PwmController[‘PingManyTimes’]()
return
# ********************************************************************************
# *** Main ***
# ********************************************************************************
if __name__ == ‘__main__’:
main()
# *** End of Program ***
Sample output
>>> %Run fpwm137.py
********************************************************************************
Begin Execute Function pingPca9685OneTime 2019-11-24 15:30
Function Name = pingPca9685OneTime
********************************************************************************
Begin Execute Function repeatPingPca9685 2019-11-24 15:30
Function Name = repeatPingPca9685
Repeat Ping Times = 1
Now repeat pinging, Ctrl-C to exit, = …..
Repeat Ping Times = 1
Date Time = 2019-11-24 15:30
Device Id = PCA9685
I2C Bus Name = I2cBus1
Device Name = Dev0
Device Address = 0x40
Register Name = Mode1
Register Addr = 0x00
Register Written = 0x75
Register Read Back = 0x75
Results = Good
End Execute Function repeatPingPca9685 2019-11-24 15:30
********************************************************************************
End Execute Function pingPca9685OneTime 2019-11-24 15:30
********************************************************************************
********************************************************************************
Begin Execute Function pingPca9685ManyTimes 2019-11-24 15:30
Function Name = pingPca9685ManyTimes
********************************************************************************
Begin Execute Function repeatPingPca9685 2019-11-24 15:30
Function Name = repeatPingPca9685
Repeat Ping Times = 4
Now repeat pinging, Ctrl-C to exit, = …..
Repeat Ping Times = 4
Date Time = 2019-11-24 15:30
Device Id = PCA9685
I2C Bus Name = I2cBus1
Device Name = Dev0
Device Address = 0x40
Register Name = Mode1
Register Addr = 0x00
Register Written = 0x75
Register Read Back = 0x75
Results = Good
End Execute Function repeatPingPca9685 2019-11-24 15:30
********************************************************************************
********************************************************************************
Begin Execute Function repeatPingPca9685 2019-11-24 15:30
Function Name = repeatPingPca9685
Repeat Ping Times = 1000000
Now repeat pinging, Ctrl-C to exit, = …..
Traceback (most recent call last):
File “/home/pi/Python_Programs/work1414/fpwm137.py”, line 290, in <module>
main()
File “/home/pi/Python_Programs/work1414/fpwm137.py”, line 282, in main
pca9685PwmController[‘PingManyTimes’]()
File “/home/pi/Python_Programs/work1414/fpwm137.py”, line 252, in pingPca9685ManyTimes
repeatPingPca9685(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TwoMilliSeconds’, ‘OneMillionTimes’)
File “/home/pi/Python_Programs/work1414/fpwm137.py”, line 215, in repeatPingPca9685
sleep(pauseBetweenPingSeconds)
File “/usr/lib/python3/dist-packages/thonny/backend.py”, line 346, in signal_handler
raise KeyboardInterrupt(“Execution interrupted”)
KeyboardInterrupt: Execution interrupted (30 seconds no error)
>>> keyboard interrupt 1559 tlfong01 2019nov24hkt1600
.END
5:00PM SUN. 11/24/2019
4:51PM SUN. 11/24/2019
1:29PM THU. 11/21/2019
I2C 500kHz Testing Results V3.0 tlfong 01 2019nov21hkt1330
penzu entry link: https://penzu.com/p/1d0bb304

imgur image link: https://imgur.com/gallery/xY7xp3J
# *** Test Function ***
def mainTest05():
osInfo()
testRepeatWriteReadRegisterNoPrintResults(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘FourTimes’)
testRepeatWriteReadRegisterNoPrintResults(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘OneMillionTimes’)
return
”’ *** Sample Output 2019nov21hkt1310 *******************************************
Python 3.7.3 (/usr/bin/python3)
>>> %Run fi2c127.py
# *** System Info *****************************************************
>>>>> Date <<<<<
Thu 21 Nov 2019 01:09:42 PM HKT
>>>>> buster version, Rpi4B model, Rpi4B memory <<<<<
Linux tlfong01 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Model : Raspberry Pi 4 Model B Rev 1.1
MemTotal: 1986020 kB
>>>>> i2c baudrate <<<<<
dtparam=i2c_arm=on,i2c_arm_baudrate=500000
>>>>> i2c dtoverlay <<<<<
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c3,pins_4_5
dtoverlay=i2c4,pins_6_7
dtoverlay=i2c5,pins_12_13
dtoverlay=i2c6,pins_22_23
>>>>> ls /dev/i2c* <<<<<
/dev/i2c-1
/dev/i2c-3
/dev/i2c-4
/dev/i2c-6
>>>>> i2cdetect -y 1 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 41 — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — 72 — — — — —
>>>>> i2cdetect -y 3 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 — 42 — — — — — 48 49 — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 4 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
********************************************************************************
Begin Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
Function Name = testRepeatWriteReadRegisterNoPrintResults
Repeat Ping Times = 4
Now repeat pinging, Ctrl-X to exit, = …..
Repeat Ping Times = 4
Date Time = 2019-11-21 13:09
Device Id = PCA9685
I2C Bus Name = I2cBus1
Device Name = Dev0
Device Address = 0x40
Register Name = Mode1
Register Written = 0x75
Register Read Back = 0x75
Results = Good
End Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
********************************************************************************
********************************************************************************
Begin Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
Function Name = testRepeatWriteReadRegisterNoPrintResults
Repeat Ping Times = 1000000
Now repeat pinging, Ctrl-X to exit, = …..
”’
# fi2c127.py tlfong01 2019nov21hkt1204
from time import sleep
from datetime import datetime
import smbus
import fprint70 as fprint
import ftime71 as ftime
import os
# I2c Bus Setup Notes
# *** Date and Configuration ***
# pi@raspberrypi:~ $ date Wed 28 Aug 2019 03:26:24 PM HKT
# pi@raspberrypi:~ $ uname -a
# Linux raspberrypi 4.19.58-v7l+ #1245 SMP Fri Jul 12 17:31:45 BST 2019 armv7l GNU/Linux
# *** Setup multiple I2C buses ***
# pi@raspberrypi:~ $ sudo nano /boot/config.txt
# dtoverlay=i2c1,pins_2_3 (board pins 3, 5)
# dtoverlay=i2c3,pins_4_5 (board pins 7, 29)
# dtoverlay=i2c4,pins_6_7 (board pins 31, 26)
# dtoverlay=i2c5,pins_12_13 (board pins 32, 33)
# dtoverlay=i2c6,pins_22_23 (board pins 15, 16)
# pi@raspberrypi:~ $ ls /dev/i2c*
# /dev/i2c-1 /dev/i2c-3 /dev/i2c-4 /dev/i2c-5 /dev/i2c-6
# *** Speed setting (Only for Rpi4B, Not for Rpi3B+, whose I2C is NOT changeable ***
# pi@raspberrypi:~ $ sudo nano /boot/config.txt
# dtparam=i2c_arm=on, i2c_arm_baudrate=10000
# ********************************************************************************
# ********************************************************************************
# *** I2c Bus Config ***
i2cBus1 = smbus.SMBus(1)
i2cBus3 = smbus.SMBus(3)
i2cBus4 = smbus.SMBus(4)
# i2cBus5 = smbus.SMBus(5) # <<< not working !!!
i2cBus6 = smbus.SMBus(6)
i2cBusDict = {‘I2cBus1’: i2cBus1,
‘I2cBus3’: i2cBus3,
‘I2cBus4′: i2cBus4,
#’I2cBus5’: i2cBus5, # <<<<< Not working !!!
‘I2cBus6’: i2cBus6,
}
# *** Control Byte Dictionary ***
testControlByteDict = {
‘TenMilliSeconds’ : 0.01,
‘FourTimes’ : 4,
‘OneMillionTimes’ : 1000000,
}
# ********************************************************************************
# ********************************************************************************
# *** Read Write Print Device/Register Functions ***
# *** Write/Read Device One Byte ***
def quickWriteDevOneByte(i2cBus, devAddr, writeByte):
i2cBus.write_byte(devAddr, writeByte)
return
def quickReadDevOneByte(i2cBus, devAddr):
readByte = i2cBus.read_byte(devAddr)
return readByte
# *** Write/Read/Print Device Two Bytes / Device Register One Byte ***
def writeDevTwoBytes(i2cBus, devAddr, writeByte1, writeByte2):
i2cBus.write_byte_data(devAddr, writeByte1, writeByte2)
return
def writeRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName, writeByte):
devAddr = devAddrDict[devName]
regAddr = regAddrDict[regName]
writeDevTwoBytes(i2cBus, devAddr, regAddr, writeByte)
return
def readDevOneByte(i2cBus, devAddr, readByteAddr):
readByte = i2cBus.read_byte_data(devAddr, readByteAddr)
return readByte
def readRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName):
devAddr = devAddrDict[devName]
regAddr = regAddrDict[regName]
readByte = i2cBus.read_byte_data(devAddr, regAddr)
return readByte
def printRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName):
readByte = readRegOneByte(i2cBusName, devAddrDict, devName, regAddrDict, regName)
print(printTitle, hex(readByte))
return
# *** Write Device Three Bytes ***
def writeDevThreeBytes(i2cBus, devAddr, WriteByte1, writeByte2, writByte3): # <<<<<<<<<< Not yet tested <<<<<<<<<<
i2cBus.write_block_data(devAddr, writeByte1, [writeByte2, writeByte3])
return
# *** OS Info ***
def osInfo():
print(‘\n# *** System Info *****************************************************’)
print(‘\n>>>>> ‘, ‘Date’, ‘<<<<<‘)
os.system(‘date’)
print(‘\n>>>>> ‘, ‘buster version, Rpi4B model, Rpi4B memory’, ‘<<<<<‘)
os.system(‘uname -a’)
os.system(‘grep Model /proc/cpuinfo’)
os.system(‘grep MemTotal /proc/meminfo’)
print(‘\n>>>>> ‘, ‘i2c baudrate’, ‘<<<<<‘)
os.system(‘grep dtparam=i2c /boot/config.txt’)
print(‘\n>>>>> ‘, ‘i2c dtoverlay’, ‘<<<<<‘)
os.system(‘grep dtoverlay=i2c /boot/config.txt’)
print(‘\n>>>>> ‘, ‘ls /dev/i2c*’, ‘<<<<<‘)
os.system(‘ls /dev/i2c*’)
i2cdetectCommand = ‘i2cdetect -y 1’
print(‘\n>>>>> ‘, i2cdetectCommand, ‘<<<<<‘)
os.system(i2cdetectCommand)
i2cdetectCommand = ‘i2cdetect -y 3’
print(‘\n>>>>> ‘, i2cdetectCommand, ‘<<<<<‘)
os.system(i2cdetectCommand)
i2cdetectCommand = ‘i2cdetect -y 4’
print(‘\n>>>>> ‘, i2cdetectCommand, ‘<<<<<‘)
os.system(i2cdetectCommand)
return
# *** Main Test Function ***
# *** PCA9685 16 Ch PWM Controller Config ***
pca9685DevAddrDict = {
‘Dev0’: 0x40,
‘Dev1’: 0x41,
‘Dev2’: 0x40,
‘Dev3’: 0x43,
‘Dev4’: 0x44,
‘Dev5’: 0x45,
‘Dev6’: 0x46,
‘Dev7’: 0x47,
}
pca9685RegAddrDict = { ‘Mode1’: 0x00,
‘Mode2’: 0x01,
}
pca9685DataByteDict = {
‘Mode1Reset’: 0x11,
}
# *** PCF8591 ADC/DAC Config ***
pcf8591DevAddrDict = {
‘DevAddr0’: 0x48,
‘DevAddr1’: 0x49,
‘DevAddr2’: 0x4a,
‘DevAddr3’: 0x4b,
‘DevAddr4’: 0x4c,
‘DevAddr5’: 0x4d,
‘DevAddr6’: 0x4e,
‘DevAddr7’: 0x4f,
}
pcf8591ControlByteDict = {
‘ChannelNum0’: 0x00,
‘ChannelNum1’: 0x01,
}
moduleDict = {
‘PhMeter’: {‘ḾoduleName’: ‘PhMeter’,
‘ModuleHelp’: ‘PhMeterHelp’,
‘GreenTea’: {‘SignalName’ : ‘GreenTea’,
‘I2cBusName’ : ‘I2cBus1’,
‘DevAddrName’ : ‘DevAddr0’,
‘ChannelNumName’ : ‘ChannelNum0’,
},
‘Milk’ : {‘SignalName’ : ‘Yvalue’,
‘I2cBusName’ : ‘I2cBus3’,
‘DevAddrName’ : ‘DevAddr1’,
‘ChannelNumName’: ‘ChannelNum0’,
},
‘Water’ : {‘SignalName’ : ‘Yvalue’,
‘I2cBusName’ : ‘I2cBus3’,
‘DevAddrName’ : ‘DevAddr0’,
‘ChannelNumName’: ‘ChannelNum0’,
},
‘Oil’ : {‘SignalName’ : ‘Yvalue’,
‘I2cBusName’ : ‘I2cBus4’,
‘DevAddrName’ : ‘DevAddr0’,
‘ChannelNumName’: ‘ChannelNum0’,
}
},
}
# *** Test PCA9685 ***
def testWriteReadRegister(devId, busName, devName, regName, testByteHexString):
fprint.printBeginExecFunction()
devAddrDict = pca9685DevAddrDict
regAddrDict = pca9685RegAddrDict
i2cBus = i2cBusDict[busName]
testByte = int(testByteHexString, 16)
writeRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName, testByte)
readByte = readRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName)
if readByte == testByte:
resultsString = ‘Good’
else:
resultsString = ‘Bad’
devAddr = devAddrDict[devName]
fprint.printTitleString(‘Date Time’, fprint.indentFormat640, str(datetime.now())[0:16])
fprint.printTitleString(‘Device Id’, fprint.indentFormat640, devId)
fprint.printTitleString(‘I2C Bus Name’, fprint.indentFormat640, busName)
fprint.printTitleString(‘Device Name’, fprint.indentFormat640, devName)
fprint.printTitleOneByteNum(‘Device Address’, fprint.indentFormat640, devAddr)
fprint.printTitleString(‘Register Name’, fprint.indentFormat640, regName)
fprint.printTitleOneByteNum(‘Register Written’, fprint.indentFormat640, testByte)
fprint.printTitleOneByteNum(‘Register Read Back’, fprint.indentFormat640, readByte)
fprint.printTitleString(‘Results’, fprint.indentFormat640, resultsString)
fprint.printEndExecFunction()
return
# Notes
# For Mode1 register, Test byte 0x88, 0x77 returns 0x58, 0x77. In other words, some bits are hardwired.
def testRepeatWriteReadRegisterNoPrintResults(devId, busName, devName, regName, testByteHexString, pauseBetweenPingSecondsName, repeatCountName):
fprint.printBeginExecFunction()
devAddrDict = pca9685DevAddrDict
regAddrDict = pca9685RegAddrDict
i2cBus = i2cBusDict[busName]
testByte = int(testByteHexString, 16)
repeatCount = testControlByteDict[repeatCountName]
pauseBetweenPingSeconds = testControlByteDict[pauseBetweenPingSecondsName]
fprint.printTitleString(‘Repeat Ping Times’, fprint.indentFormat640, repeatCount)
fprint.printTitleString(‘Now repeat pinging, Ctrl-X to exit,’, fprint.indentFormat640, ‘…..’)
for count in range(repeatCount): # *** Repeat Ping Section ***
writeRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName, testByte)
readByte = readRegOneByte(i2cBus, devAddrDict, devName, regAddrDict, regName)
sleep(pauseBetweenPingSeconds)
if readByte == testByte:
resultsString = ‘Good’
else:
resultsString = ‘Bad’
fprint.printTitleString(‘Repeat Ping Times’, fprint.indentFormat640, repeatCount)
devAddr = devAddrDict[devName]
fprint.printTitleString(‘Date Time’, fprint.indentFormat640, str(datetime.now())[0:16])
fprint.printTitleString(‘Device Id’, fprint.indentFormat640, devId)
fprint.printTitleString(‘I2C Bus Name’, fprint.indentFormat640, busName)
fprint.printTitleString(‘Device Name’, fprint.indentFormat640, devName)
fprint.printTitleOneByteNum(‘Device Address’, fprint.indentFormat640, devAddr)
fprint.printTitleString(‘Register Name’, fprint.indentFormat640, regName)
fprint.printTitleOneByteNum(‘Register Written’, fprint.indentFormat640, testByte)
fprint.printTitleOneByteNum(‘Register Read Back’, fprint.indentFormat640, readByte)
fprint.printTitleString(‘Results’, fprint.indentFormat640, resultsString)
fprint.printEndExecFunction()
return
# *** Test PCF8591 ***
# *** Read PCF8591 Single Ended Input Channel 0 ***
def readAdcResults(i2cBus, devAddr, controlByte):
adcResults = i2cBus.read_byte_data(devAddr, controlByte)
adcResults = i2cBus.read_byte_data(devAddr, controlByte)
return adcResults
def pcf8591Convert(moduleName, signalName):
# fprint.printBeginExecFunction()
i2cBusName = moduleDict[moduleName][signalName][‘I2cBusName’]
devAddrName = moduleDict[moduleName][signalName][‘DevAddrName’]
channelNumName = moduleDict[moduleName][signalName][‘ChannelNumName’]
i2cBus = i2cBusDict[i2cBusName]
devAddr = pcf8591DevAddrDict[devAddrName]
controlByte = pcf8591ControlByteDict[channelNumName]
adcResults = readAdcResults(i2cBus, devAddr, controlByte)
print(‘\n# *** PCF8591 ADC Testing *****************************************************\n’)
fprint.printTitleString(‘Module Name’, fprint.indentFormat640, moduleName)
fprint.printTitleString(‘Signal Name’, fprint.indentFormat640, signalName)
fprint.printTitleString(‘I2C Bus Name’, fprint.indentFormat640, i2cBusName)
fprint.printTitleOneByteNum(‘PCF8591 I2C Device Addr’, fprint.indentFormat640, devAddr)
fprint.printTitleOneByteNum(‘Channel Number’, fprint.indentFormat640, pcf8591ControlByteDict[channelNumName])
print(‘ ADC Results =’, fprint.convertOneByteNumToFourCharStr(adcResults), ‘ (hex)’)
print(‘ =’, (str(adcResults)).ljust(4, ‘ ‘), ‘ (dec)’)
print(‘ =’, (str(int((float((adcResults)/255) * 100)))).ljust(4, ‘ ‘), ‘ (%)’)
# fprint.printEndExecFunction()
return
# ********************************************************************************
# ********************************************************************************
# ********************************************************************************
# *** I2C PCF8591 ADC PhMeter GreenTea/Milk/Water Tests ***
# ********************************************************************************
def convertPhMeterGreenTea():
#fprint.printBeginExecFunction()
pcf8591Convert(‘PhMeter’, ‘GreenTea’)
#fprint.printEndExecFunction()
return
def convertPhMeterMilk():
#fprint.printBeginExecFunction()
pcf8591Convert(‘PhMeter’, ‘Milk’)
#fprint.printEndExecFunction()
return
def convertPhMeterWater():
#fprint.printBeginExecFunction()
pcf8591Convert(‘PhMeter’, ‘Water’)
#fprint.printEndExecFunction()
return
def convertPhMeterOil():
#fprint.printBeginExecFunction()
pcf8591Convert(‘PhMeter’, ‘Oil’)
#fprint.printEndExecFunction()
return
# ********************************************************************************
# *** Main Tests ***
# ********************************************************************************
def mainTest01(): # *** Testing dateTime and timeElapse Functions ***
ftime.testPrintDateTimeNow()
ftime.testPrintOneSecondElapsedTime()
return
def mainTest02(): # *** Testing I2C PCA9685 16 Channel PWM Controller Ping (ReadAfterWrite Function ) ***
testWriteReadRegister(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, “0x75”) # 0x40
testWriteReadRegister(‘PCA9685’, ‘I2cBus1’, ‘Dev1’, ‘Mode1’, “0x77”) # 0x41
testWriteReadRegister(‘PCA9685’, ‘I2cBus3’, ‘Dev2’, ‘Mode1’, “0x77”) # 0x40
testWriteReadRegister(‘PCA9685’, ‘I2cBus3’, ‘Dev2’, ‘Mode1’, “0x77”) # 0x42
return
def mainTest03():
osInfo()
convertPhMeterGreenTea()
convertPhMeterMilk()
convertPhMeterWater()
convertPhMeterOil()
return
def mainTest04(): # *** Ping PCA9685 I2cBus1, Device Address 0x40, Register Mode1, Test Byte 0x75 ***
osInfo()
testWriteReadRegister(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’) # 0x40
return
def mainTest05():
osInfo()
testRepeatWriteReadRegisterNoPrintResults(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘FourTimes’)
testRepeatWriteReadRegisterNoPrintResults(‘PCA9685’, ‘I2cBus1’, ‘Dev0’, ‘Mode1’, ‘0x75’, ‘TenMilliSeconds’, ‘OneMillionTimes’)
return
# ********************************************************************************
# ********************************************************************************
# ********************************************************************************
# *** Init/Main Functions ***
# ********************************************************************************
# *** Init Function ***
def init():
pass
return
# ********************************************************************************
#*** Main Function ***
# ********************************************************************************
def main():
init()
#mainTest01()
#mainTest02()
#mainTest03()
#mainTest04()
mainTest05()
return
# ********************************************************************************
# ********************************************************************************
# ********************************************************************************
# *** Main ***
# ********************************************************************************
if __name__ == ‘__main__’:
main()
# *** End of Program ***
# ********************************************************************************
# ********************************************************************************
”’ *** Sample Output 2019nov21hkt1310 *******************************************
Python 3.7.3 (/usr/bin/python3)
>>> %Run fi2c127.py
# *** System Info *****************************************************
>>>>> Date <<<<<
Thu 21 Nov 2019 01:09:42 PM HKT
>>>>> buster version, Rpi4B model, Rpi4B memory <<<<<
Linux tlfong01 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Model : Raspberry Pi 4 Model B Rev 1.1
MemTotal: 1986020 kB
>>>>> i2c baudrate <<<<<
dtparam=i2c_arm=on,i2c_arm_baudrate=500000
>>>>> i2c dtoverlay <<<<<
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c3,pins_4_5
dtoverlay=i2c4,pins_6_7
dtoverlay=i2c5,pins_12_13
dtoverlay=i2c6,pins_22_23
>>>>> ls /dev/i2c* <<<<<
/dev/i2c-1
/dev/i2c-3
/dev/i2c-4
/dev/i2c-6
>>>>> i2cdetect -y 1 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 41 — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — 72 — — — — —
>>>>> i2cdetect -y 3 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 — 42 — — — — — 48 49 — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 4 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
********************************************************************************
Begin Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
Function Name = testRepeatWriteReadRegisterNoPrintResults
Repeat Ping Times = 4
Now repeat pinging, Ctrl-X to exit, = …..
Repeat Ping Times = 4
Date Time = 2019-11-21 13:09
Device Id = PCA9685
I2C Bus Name = I2cBus1
Device Name = Dev0
Device Address = 0x40
Register Name = Mode1
Register Written = 0x75
Register Read Back = 0x75
Results = Good
End Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
********************************************************************************
********************************************************************************
Begin Execute Function testRepeatWriteReadRegisterNoPrintResults 2019-11-21 13:09
Function Name = testRepeatWriteReadRegisterNoPrintResults
Repeat Ping Times = 1000000
Now repeat pinging, Ctrl-X to exit, = …..
”’
”’ *** Sample Output 2019nov19hkt2059 *******************************************
>>> %Run fi2c123.py
# *** System Info *****************************************************
>>>>> Date <<<<<
Tue 19 Nov 2019 09:49:15 PM HKT
>>>>> buster version, Rpi4B model, Rpi4B memory <<<<<
Linux tlfong01 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Model : Raspberry Pi 4 Model B Rev 1.1
MemTotal: 1986020 kB
>>>>> i2c baudrate <<<<<
dtparam=i2c_arm=on,i2c_arm_baudrate=500000
>>>>> i2c dtoverlay <<<<<
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c3,pins_4_5
dtoverlay=i2c4,pins_6_7
dtoverlay=i2c5,pins_12_13
dtoverlay=i2c6,pins_22_23
>>>>> ls /dev/i2c* <<<<<
/dev/i2c-1
/dev/i2c-3
/dev/i2c-4
/dev/i2c-6
>>>>> i2cdetect -y 1 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 41 — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — 72 — 74 — — —
>>>>> i2cdetect -y 3 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 — 42 — — — — — 48 49 — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — 72 — 74 — — —
>>>>> i2cdetect -y 4 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = GreenTea
I2C Bus Name = I2cBus1
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0xf8 (hex)
= 248 (dec)
= 97 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Milk
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x49
Channel Number = 0x00
ADC Results = 0x00 (hex)
= 0 (dec)
= 0 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Water
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x7a (hex)
= 122 (dec)
= 47 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Oil
I2C Bus Name = I2cBus4
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x7b (hex)
= 123 (dec)
= 48 (%)
>>>
”’
”’
# *** Sample Output 2019nov21hkt1131 ***
Python 3.7.3 (/usr/bin/python3)
>>> %cd /home/pi/Python_Programs/work1409
>>> %Run fi2c125.py
# *** System Info *****************************************************
>>>>> Date <<<<<
Thu 21 Nov 2019 11:29:06 AM HKT
>>>>> buster version, Rpi4B model, Rpi4B memory <<<<<
Linux tlfong01 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Model : Raspberry Pi 4 Model B Rev 1.1
MemTotal: 1986020 kB
>>>>> i2c baudrate <<<<<
dtparam=i2c_arm=on,i2c_arm_baudrate=500000
>>>>> i2c dtoverlay <<<<<
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c3,pins_4_5
dtoverlay=i2c4,pins_6_7
dtoverlay=i2c5,pins_12_13
dtoverlay=i2c6,pins_22_23
>>>>> ls /dev/i2c* <<<<<
/dev/i2c-1
/dev/i2c-3
/dev/i2c-4
/dev/i2c-6
>>>>> i2cdetect -y 1 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 41 — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 3 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 — 42 — — — — — 48 49 — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 4 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = GreenTea
I2C Bus Name = I2cBus1
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0xf8 (hex)
= 248 (dec)
= 97 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Milk
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x49
Channel Number = 0x00
ADC Results = 0x00 (hex)
= 0 (dec)
= 0 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Water
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x7a (hex)
= 122 (dec)
= 47 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Oil
I2C Bus Name = I2cBus4
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x79 (hex)
= 121 (dec)
= 47 (%)
>>> %Run fi2c125.py
# *** System Info *****************************************************
>>>>> Date <<<<<
Thu 21 Nov 2019 11:29:36 AM HKT
>>>>> buster version, Rpi4B model, Rpi4B memory <<<<<
Linux tlfong01 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
Model : Raspberry Pi 4 Model B Rev 1.1
MemTotal: 1986020 kB
>>>>> i2c baudrate <<<<<
dtparam=i2c_arm=on,i2c_arm_baudrate=500000
>>>>> i2c dtoverlay <<<<<
dtoverlay=i2c1,pins_2_3
dtoverlay=i2c3,pins_4_5
dtoverlay=i2c4,pins_6_7
dtoverlay=i2c5,pins_12_13
dtoverlay=i2c6,pins_22_23
>>>>> ls /dev/i2c* <<<<<
/dev/i2c-1
/dev/i2c-3
/dev/i2c-4
/dev/i2c-6
>>>>> i2cdetect -y 1 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 41 — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 3 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: 40 — 42 — — — — — 48 49 — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: 70 — — — — — — —
>>>>> i2cdetect -y 4 <<<<<
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — 48 — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = GreenTea
I2C Bus Name = I2cBus1
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0xe0 (hex)
= 224 (dec)
= 87 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Milk
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x49
Channel Number = 0x00
ADC Results = 0x00 (hex)
= 0 (dec)
= 0 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Water
I2C Bus Name = I2cBus3
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x7a (hex)
= 122 (dec)
= 47 (%)
# *** PCF8591 ADC Testing *****************************************************
Module Name = PhMeter
Signal Name = Oil
I2C Bus Name = I2cBus4
PCF8591 I2C Device Addr = 0x48
Channel Number = 0x00
ADC Results = 0x79 (hex)
= 121 (dec)
= 47 (%)
>>>
”’
1:29PM THU. 11/21/2019
5:04PM SUN. 11/24/2019
Copyright Penzu Inc. 2019
Related
Categories: Uncategorized
