4 ms·
Excellent post! I'll be adding a RasPi to my collection soon, and I've been wrestling with an I2C 20x4 LCD. I'll definitely be rereading your blog when it arriv
by stephengillie 14y ago
Excellent post! I'll be adding a RasPi to my collection soon, and I've been wrestling with an I2C 20x4 LCD. I'll definitely be rereading your blog when it arrives.
Speaking of the LCD, do you have any suggestions for finding the address of an I2C device? Is there a way to query or scan it to see at which address it responds? I just got the Sainsmart LCD2004 as a gift. Google searches about the device result in forum posts, where people have got it to work with addresses from 0x20 to 0x27 to 0x40 -- one guy had to work it out with a multimeter. Do you know of a more elegant solution than brute-forcing it?
- georgemcbay 14y agoi2cdetect? http://www.lm-sensors.org/wiki/man/i2cdetect http://www.lm-sensors.org/wiki/man/i2cdetect Both the web page and the program itself will inform you that running it could cause Armageddon, but assuming all you have plugged into your i2c bus is an LCD it really shouldn't cause any harm. On Raspbian, you'll have to apt-get install i2c-tools to install this (and you'll have to modprobe in the i2c drivers as described in my blog post). On the Adafruit distro it comes pre-installed. Running i2cdetect on my Pi which currently has one of those LED matrix devices I talked about in the blog results in this: pi@raspberrypi ~ $ sudo i2cdetect 1 WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c-1. I will probe address range 0x03-0x77. Continue? [Y/n] y 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: 70 -- -- -- -- -- -- -- (Telling me it detected a device at 0x70, which is correct for this device). I don't have the LCD you have so I'm not sure if it is properly detected by i2cdetect, but that's what I'd try first.
- stephengillie 14y agoWow, thank you so much! This obviously hadn't come up in relation to Arduino searches.
- georgemcbay 14y agoAh, yeah, not relevant to Arduino but if you have any Linux boxes with I2C support available (which you will when your RaspPi arrives), i2cdetect is great for this sort of thing.