3 ms·
blog author here, feel free to direct any questions into this thread since I'm a Hacker News addict^H^H^H^H^H^Hregular. Access to various bits of I2C hardware
by georgemcbay 14y ago
blog author here, feel free to direct any questions into this thread since I'm a Hacker News addict^H^H^H^H^H^Hregular.
Access to various bits of I2C hardware probably limit the usefulness of this specific post to a narrow audience, but I should be writing a lot more about various bits of code I've done to get pure Go talking to linux at a low level -- framebuffer writing via /dev/fb, input handling of mice, touchpads, touchscreens, keyboards, etc via reading /dev/input/*, etc.
(All part of a vague New Years resolution to blog more and get more public code out there, since I've been tinkering on this stuff a lot privately for the past 8 months or so).
- stephengillie 14y agoExcellent 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.
- thibaut_barrere 14y agoThanks for sharing this! I will definitely have a look at your code for inspiration later on, since I'd like to use Go to read 1-wire components (like the DS18B20 temp sensor) through a LinkUSB device, without relying on OWFS. [1] https://www.adafruit.com/products/381 https://www.adafruit.com/products/381 [2] http://www.ibuttonlink.com/products/linkusb http://www.ibuttonlink.com/products/linkusb [3] http://www.owfs.org/ http://www.owfs.org/