Using I²C Sensors With Any Linux Via USB And IIO

Hooking up I2C sensors is something which is generally associated with microcontrollers and SBCs, yet it’s very easy to use such I2C sensors from basically any system that runs Linux. After all, I2C (that is, SMBus) is one of the interfaces that is highly likely to be used on your PC’s mainboard as well as peripherals. This means that running our own devices like the well-known BME280 temperature, pressure and humidity sensor, or Si1145 light sensor should be a piece of cake.

In a blog post from a few years ago, [Peter Molnar] explains in detail how to wire up a physical adapter to add a USB-connected I2C interface to a system. At its core is the ATtiny85 AVR-based MCU, which provides a built-in USB interface, running the I2C-Tiny-USB firmware.

The essential part here is that the MCU shows up to the Linux kernel as an i2c device, requiring the i2c-dev driver to be loaded. After this the I2C device that is connected to the adapter MCU’s I2C bus can be used via the Linux module’s API calls, either directly or via existing drivers. [Peter] found that the BMP280 driver came with Debian Sid, for example.

A Pi Pico plugged into a breadboard, with an I2C OLED display connected to it

Need An USB-I2C Adapter? Use Your Pico!

Given its abundance and simplicity, the RP2040 has no doubt become a favourite for USB peripheral building – in particular, USB-connected tools for electronics experiments. Today, we see one more addition to our Pico-based tool arsenal – a USB-I2C adapter firmware for RP2040 by [Renze Nicolai]. This is a reimplementation of the ATTiny-based I2C-Tiny-USB project and complies to the same protocol – thus, it’s compatible with the i2c-tiny-usb driver that’s been in the Linux kernel for ages. Just drag&drop the .uf2, run a script on your Linux system, and you will get a /dev/i2c-X device you can work with from userspace code, or attach other kernel drivers to.

The software will work with any RP2040 devboard – just connect your I2C devices to the defined pins and you’ll have them show up in i2cdetect output on your Linux workstation. As a demo, [Renze] has written a userspace Python driver for one of these SSD1306 128×64 OLEDs, and gives us a commandline that has the driver accept output of an ffmpeg command capturing your main display’s contents, duplicating your screen on the OLED – in a similar fashion that we’ve seen with the “HDMI” I2C-driven display a few months back. Everything you might need is available on the GitHub page, including usage instructions and examples, and the few scripts you can use if you want to add an udev rule or change the I2C clock frequency.

Just to name a few purposes, you can use a Pi Pico as a tool for SWD, JTAG, CAN, a logic analyser with both digital and analog channels, or even as a small EMP-driven chip glitching tool. The now-omnipresent $3 Pi Pico boards, it seems, are a serious contender to fondly remembered hacker tools of the past, such as the legendary BusPirate.

Continue reading “Need An USB-I2C Adapter? Use Your Pico!”

Modular Z80 Really Racks Up The Retrocomputer Cred

Very few retrocomputing projects are anything other than a labor of love. There’s really no practical reason to build a computer that is woefully inadequate for just about any task compared to even an entry-level PC today. But the lack of a practical reason to do something rarely stops a hacker, as with this nifty modular Z80-based rack computer.

Actually, there’s at least one area where retrocomputers excel compared to their modern multi-core gigahertz counterparts — and that’s nostalgia. That’s what [Ricardo Kaltchuk] was going for with his build, which started by finding a Z80 and an Intel 8251 USART in his parts bin. Those formed the core of what would become the “Proton” computer, a modular beauty built around 7 cm by 10 cm PCBs that plug into a backplane inside a rack made from aluminum angle. Aside from the power supply and the Z80 CPU, other modules include a RAM card with a zero insertion force socket for an EPROM, a mass-storage module sporting a 128 MB Compact Flash card, plus modules for standard serial and I2C comms.

The fit and finish are excellent, and the performance is impressive. The Proton runs CP/M and boasts a ton of old applications that will bring back some memories, like SuperCalc and dBase. We’d venture a bet that WordStar is in there someplace, or easily could be. The video below is a little rough, but shows everything off really well.

In some ways, the Proton reminds us of the RC2014, but its fit and finish are what bring this build home. That’s not to take away from the work [Ricardo] obviously put into documentation, though. The 62-page manual has every detail of every module, plus instructions for building one of your own.

Continue reading “Modular Z80 Really Racks Up The Retrocomputer Cred”

Universal TFT Display Backpack Helps Small Displays Shine

TFT technology might be ancient news for monitors and TVs, but it’s alive and well when it comes to hobbyist electronics and embedded devices. They’ve now become even easier to integrate, thanks to the Universal TFT Display Backpack design by [David Johnson-Davies].

Breakout board, compatible with pinouts of most small TFT displays.

Such displays are affordable and easy to obtain, and [David] noticed that many seemed to have a lot in common when it came to pinouts and hookup info. The result is his breakout board design, a small and easy-to-assemble PCB breakout board that can accommodate the pinouts of a wide variety of TFT displays available from your favorite retailers or overseas sellers.

The board has a few quality-of-life features such as an optional connection for a backlight, and a staggered pin pattern so that different TFT boards can be pushed in to make a solid connection without soldering. That’s very handy for testing and evaluating different displays.

Interested? Head on over to the GitHub repository for the project, and while you’re at it, check out [David]’s Tiny TFT Graphics Library 2 which is a natural complement to the display backpack. [David] sure knows his stuff when it comes to cleverly optimized display work; we loved his solution for writing to OLED displays without needing a RAM buffer.

Barely HDMI Display Gets A Steampunk-Inspired Enclosure

It’s an interesting question: What does one do for a follow-up to building the world’s worst HDMI display? Simple — stick it in a cool steampunk-inspired case and call it a day.

That seems to have been [mitxela]’s solution, and please don’t take our assessment as a knock on either the original build or this follow-up. [mitxela] himself expresses a bit of wonder at the attention garnered by his “rather stupid project,” which used the I2C interface in an HDMI interface to drive a tiny monochrome OLED screen. Low refresh rate, poor resolution — it has everything you don’t want in a display, but was still a cool hack that deserved the attention it got.

The present work, which creates an enclosure for the dodgy display, is far heavier on metalworking than anything else, as the video below reveals. The display itself goes in a small box that’s machined from brass, while the HDMI plug gets a sturdy-looking brass housing that makes the more common molded plastic plug look unforgivably flimsy — hot glue notwithstanding. Connecting the two is a flexible stalk, allowing it to plug into a computer’s HDMI port and giving the user the flexibility to position the nearly useless display where it can be seen best.

But again, we may be too harsh in our judgment; while DOOM is basically unplayable on the tiny display, “Bad Apple!!” is quite watchable, especially when accompanied by [mitxela]’s servo-controlled MIDI music box. And since when has usability been a criterion for judging a hack’s coolness, anyway?

Continue reading “Barely HDMI Display Gets A Steampunk-Inspired Enclosure”

Bare-Metal STM32: Using The I2C Bus In Master-Transceiver Mode

As one of the most popular buses today for on- and inter-board communication within systems, there’s a good chance you’ll end up using it with an embedded system. I2C offers a variety of speeds while requiring only two wires (clock and data), which makes it significantly easier to handle than alternatives, such as SPI. Within the STM32 family of MCUs, you will find at least one I2C peripheral on each device.

As a shared, half-duplex medium, I2C uses a rather straightforward call-and-response design, where one device controls the clock, and other devices simply wait and listen until their fixed address is sent on the I2C bus. While configuring an STM32 I2C peripheral entails a few steps, it is quite painless to use afterwards, as we will see in this article. Continue reading “Bare-Metal STM32: Using The I2C Bus In Master-Transceiver Mode”

Four jumper wires with white heatshrink on them, labelled VCC, SCL, SDA and GND

The Connector Zoo: I2C Ecosystems

I2C is a wonderful interface. With four wires and only two GPIOs, you can connect a whole lot of sensors and devices – in parallel, at that! You will see I2C used basically everywhere, in every phone, laptop, desktop, and any device with more than a few ICs inside of it – and most microcontrollers have I2C support baked into their hardware. As a result, there’s a myriad of interesting and useful devices you can use I2C with. Occasionally, maker-facing companies create plug-and-play interfaces for the I2C device breakouts they produce, with standardized pinouts and connectors.

Following a standard pinout is way better than inventing your own, and your experience with inconsistent pin header pinouts on generic I2C modules from China will surely reflect that. Wouldn’t it be wonderful if you could just plug a single I2C-carrying connector into an MPU9050, MLX90614 or HMC5883L breakout you bought for a few dollars, as opposed to the usual hurdle of looking at the module’s silkscreen, soldering pin headers onto it and carefully arranging female headers onto the correct pins?

As with any standard, when it comes to I2C-on-a-connector conventions, you would correctly guess that there’s more than one, and they all have their pros and cons. There aren’t quite fifteen, but there’s definitely six-and-a-half! They’re mostly inter-compatible, and making use of them means that you can access some pretty powerful peripherals easily. Let’s start with the two ecosystems that only have minor differences, and that you’ll encounter the most! Continue reading “The Connector Zoo: I2C Ecosystems”