Comments (7)
If I run i2cdetect -y 1 I get an address of 3f, so I know the hardware is at least being seen.
please post the output of the i2cdetect -y 1
command.
I think I might have some sort of hw problem. I have successfully got it to run once or twice but it eventually fails. I ended up changing line 102 in the lcd/drivers/i2c_dev.py file to the address i2cdetect -y 1 would give
self.lcd = I2CDevice(addr_default=0x3f)
you don't need to edit the driver file. just set the addr
attribute when loading the Lcd()
class in your application. in https://github.com/the-raspberry-pi-guy/lcd/blob/master/demo_clock.py#L14, for example, use the following instead to set the Lcd address to 0x3f
(mentioned in #20):
display = drivers.Lcd(addr=0x3f)
either way, code was supposed to autodetect the address. waiting for your reply to the first question to troubleshoot this further.
from lcd.
I think I might have some sort of hw problem. I have successfully got it to run once or twice but it eventually fails. I ended up changing line 102 in the lcd/drivers/i2c_dev.py file to the address i2cdetect -y 1 would give
self.lcd = I2CDevice(addr_default=0x3f)
This will work for one command, I then try to run it a second time and receive the same error! Here is where it gets weird though. If I run i2cdetect -y 1 again, I get a different address, this time it is 3b. It seems to fluctuate between the two. If I edit i2c_dev.py with the 3b address the lcd will show the no time to waste but it fails immediately with the errno 121 again. I then do another i2cdetect -y 1 and it shows back to the 3f address. If I edit i2c_dev.py to the correct address, yet again it will work again once but then no longer works after the CTRL+C and the address flips again to 3b.
Does that sound like hardware failure?
from lcd.
Thanks so much for the assistance.
I just wiped and reloaded raspberry pi os 32-bit headless so I can start from scratch. I followed the instructions to the letter, the only deviation was an apt update.
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3f
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
If I try to run demo_clock.py from the lcd directory I get this.
python demo_clock.py
Traceback (most recent call last):
File "demo_clock.py", line 14, in
display = drivers.Lcd()
File "/home/pi/lcd/drivers/i2c_dev.py", line 103, in init
self.lcd_write(0x03)
File "/home/pi/lcd/drivers/i2c_dev.py", line 126, in lcd_write
self.lcd_write_four_bits(mode | (cmd & 0xF0))
File "/home/pi/lcd/drivers/i2c_dev.py", line 121, in lcd_write_four_bits
self.lcd.write_cmd(data | LCD_BACKLIGHT)
File "/home/pi/lcd/drivers/i2c_dev.py", line 74, in write_cmd
self.bus.write_byte(self.addr, cmd)
IOError: [Errno 121] Remote I/O error
I found that if I changed line 102 in /home/pi/lcd/drivers/i2c_dev.py from 0x27 to 0x3f it fixed it. I know this isn't the correct way to run it. But it at least confirms the display is functioning correctly.
from lcd.
okay. I'm investigating why it is not auto-detecting your addr
. will update once I find out.
from lcd.
found the culprit at https://github.com/the-raspberry-pi-guy/lcd/blob/master/drivers/i2c_dev.py#L60-L70:
if not addr:
# try autodetect address, else use default if provided
try:
self.addr = int('0x{}'.format(
findall("[0-9a-z]{2}(?!:)", check_output(['/usr/sbin/i2cdetect', '-y', BUS_NUMBER]))[0]), base=16) \
if exists('/usr/sbin/i2cdetect') else addr_default
except:
self.addr = addr_default
else:
self.addr = addr
self.bus = SMBus(bus)
in check_output()
, args must be strings but BUS_NUMBER
is an integer. this causes an error and sets self.addr = addr_default
, which is set to the hex literal 0x27
. in @rnld-rygn 's case, this will cause errors downstream because their i2c device has a different address, namely 0x3f
.
setting str(BUS_NUMBER)
in https://github.com/the-raspberry-pi-guy/lcd/blob/master/drivers/i2c_dev.py#L64 should fix this. will double check it later this week and submit a PR.
in the meantime, as I mentioned before, you can avoid this issue altogether by setting Lcd(addr=0x3f)
in your application.
from lcd.
Thanks so much for your help. I will try the recommended fix you gave and keep an eye out for the release fix.
from lcd.
Top notch stuff @cgomesu, thanks for supporting this repo :)
from lcd.
Related Issues (20)
- smbus is not recognized HOT 20
- No module named smbus HOT 1
- No module named smbus HOT 4
- No module named smbus (sorry if not correct label..)
- Maintaining Python 2.7 compatibility moving forward HOT 1
- Favourite HOT 1
- Removal of the default 'pi' user
- turn off the lcd screen HOT 6
- > ```python
- module not imported running python script at startup raspberry pi /etc/profiles HOT 2
- Cannot run install.sh HOT 5
- would like the cpu/gpu temp display code HOT 3
- Display IP adress HOT 2
- Displaying the IP address shows a b' in front of IP address HOT 2
- demo_tiny_dashboard is broken as Theysaidso api is no longer public
- demo_forex.py is broken because requests is blocked by cloudflare HOT 1
- Omision on README about quotable.io quote length restrictions HOT 2
- LCD Spotify Now Playing + Telegram Bot HOT 7
- BACKLIGHT can't stay in OFF mode
- cc.load_custom_characters_data() not working HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lcd.