树莓派4b通过I2C总线连接LCD1602

接线方式:

:---PCF85741---:  :---RASP---:

    GND-------------06 GROUND

    VCC-------------02 5V

    SDA-------------03 SDA1

     scl--------scl1(参考作者没有指明,所以走了很多弯路)


打开/etc/modules ,在文件结尾加上 i2c-dev、i2c-bcm2708

pi@raspberrypi ~ $ sudo nano /etc/modules

写入保存

# /etc/modules: kernel modules to load at boot time.

#

# This file contains the names of kernel modules that should be loaded

# at boot time, one per line. Lines beginning with "#" are ignored.

# Parameters can be specified after the module name.

snd-bcm2835

i2c-bcm2708

i2c-dev

————————————————

安装 i2c-tools工具与python-smbus

pi@raspberrypi ~ $ sudo apt-getinstall i2c-toolspython-smbus

记得开启i2c 命令

sudo raspi-config




寻址:

pi@raspberrypi~$ sudo i2cdetect -y1

如果出现不显示下图 27 可查看地四根线是否都接入scl1


测试库


安装测试程序
git clone https://github.com/dhylands/python_lcd.git

cdpython_lcd

sudo pip install -e.

运行测试文件

sudo lcd/i2c_lcd_test.py (此处有坑)直接运行会报错

修改python_lcd/lcd/lcd_api.py最有一个方法

如下图

放上成功图留作纪念


部分内容参考 https://blog.csdn.net/cong408/article/details/60587189

记录我踩过的坑,希望对后来人有所帮助。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容