System.IO.IOException Error 121 on Raspberry Pi I²C with PCF8574 LCD using .NET

3 weeks ago 16
ARTICLE AD BOX

I am trying to connect a Raspberry Pi to a Midas MCOB21605G1V-EYP display with a soldered HW-61 board using I²C.

The VCC pin of the HW-61 board is connected to a Wago splice connector. This connector has one wire coming from a 5V PSU and another wire going to a Whadda WPI410 level converter.

The GND pin of the HW-61 board is also connected to a Wago splice connector (a different one). This connector has three additional GND wires: one from the Raspberry Pi, one from the PSU, and one from the Whadda WPI410 level converter.

The SDA and SCL pins from the HW-61 board are connected to the corresponding pins on the level shifter. On the low-voltage side, the level shifter is correctly connected to the Raspberry Pi.

As mentioned in the title, I am getting the error:
“System.IO.IOException: Error 121 (Remote I/O error) performing I2C data transfer.”
However, the I²C address is correct, and I²C is enabled on the Raspberry Pi.

Code:

using Iot.Device.CharacterLcd; using Iot.Device.Pcx857x; using se24_lite_display_manager.Models; using System.Device.Gpio; using System.Device.I2c; namespace se24_lite_display_manager.Services { public class DisplayDriver { private Lcd1602? _lcd; private readonly LiteDisplayManagerSettings _settings; private readonly ILogger<DisplayDriver> _logger; public DisplayDriver(LiteDisplayManagerSettings settings, ILogger<DisplayDriver> logger) { _settings = settings; _logger = logger; Start(); } private void Start() { _logger.LogInformation("Starting the display..."); try { var i2cConnection = new I2cConnectionSettings(busId: 1, deviceAddress: 0x27); var i2cDevice = I2cDevice.Create(i2cConnection); var driverPcf = new Pcf8574(i2cDevice); var gpioController = new GpioController(driverPcf); _lcd = new Lcd1602( registerSelectPin: 0, enablePin: 2, dataPins: new int[] { 4, 5, 6, 7 }, backlightPin: 3, readWritePin: 1, controller: gpioController ); _lcd.Clear(); _lcd.Write("Hello World"); } catch (Exception ex) { _logger.LogError($"{ex}"); _lcd = null; } } } }
Read Entire Article