Use Raspberry Pi display temperature/humidity to i2c LCD screen を参考に
Raspberry piで湿温度センサー(OSOYOO製DHT11)で得た値をi2c LCD screen(OSOYOO製I2C 1602 LCD screen)に表示させるというものなんですが、
早速試してみると以降のようなエラーが出ました。
###エラー
Traceback (most recent call last):
File "pi-dht11-i2clcd.py", line 116, in <module>
lcd_byte(0x01, LCD_CMD)
File "pi-dht11-i2clcd.py", line 63, in lcd_byte
bus.write_byte(I2C_ADDR, bits_high)
IOError: [Errno 121] Remote I/O error
###構成と回路
構成
![(9909fdd89a335eb1ee56e511fc376c7b.png)
回路
###pi-dht11-i2clcd.py
python
1# _____ _____ _____ __ __ _____ _____ 2#| | __| | | | | | 3#| | |__ | | |_ _| | | | | 4#|_____|_____|_____| |_| |_____|_____| 5# 6# Use Raspberry Pi to get temperature/humidity from DHT11 sensor 7# Project Tutorial Url:http://osoyoo.com/2016/12/01/use-raspberry-pi-display-temperaturehumidity-to-i2c-lcd-screen/ 8# 9import smbus 10import time 11import dht11 12import RPi.GPIO as GPIO 13 14#define GPIO 14 as DHT11 data pin 15Temp_sensor=14 16 17# Define some device parameters 18I2C_ADDR = 0x3f # I2C device address, if any error, change this address to 0x27 19LCD_WIDTH = 16 # Maximum characters per line 20 21# Define some device constants 22LCD_CHR = 1 # Mode - Sending data 23LCD_CMD = 0 # Mode - Sending command 24 25LCD_LINE_1 = 0x80 # LCD RAM address for the 1st line 26LCD_LINE_2 = 0xC0 # LCD RAM address for the 2nd line 27LCD_LINE_3 = 0x94 # LCD RAM address for the 3rd line 28LCD_LINE_4 = 0xD4 # LCD RAM address for the 4th line 29 30LCD_BACKLIGHT = 0x08 # On 31#LCD_BACKLIGHT = 0x00 # Off 32 33ENABLE = 0b00000100 # Enable bit 34 35# Timing constants 36E_PULSE = 0.0005 37E_DELAY = 0.0005 38 39#Open I2C interface 40#bus = smbus.SMBus(0) # Rev 1 Pi uses 0
###追記
sudo i2cdetect -y 1
にした場合
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
sudo i2cdetect -y 0
にした場合
Error: Could not open file /dev/i2c-0' or
/dev/i2c/0': No such file or directory
回答2件
あなたの回答
tips
プレビュー