Raspberry Pi - Common Errors

Posted on

by

in

Common Raspberry Pi Errors

This post will list some of the common Raspberry Pi errors that I have encountered while building my Internet of Things (IoT) projects. This will include issues that arose while interfacing with sensors and the solutions I have figured out.

OSError: [Errno 121] Remote I/O error

I kept encountering the following error while working with an I2C LCD display together with other sensors like a Keypad and Servo Motor. Whenever I run my Python code this error keeps on popping up for some unknown reason.

  File "/home/pi/rpi_keypad_db_security_system/drivers/i2c_dev.py", line 104, in __init__
    self.lcd_write(0x03)
  File "/home/pi/rpi_keypad_db_security_system/drivers/i2c_dev.py", line 127, in lcd_write
    self.lcd_write_four_bits(mode | (cmd & 0xF0))
  File "/home/pi/rpi_keypad_db_security_system/drivers/i2c_dev.py", line 122, in lcd_write_four_bits
    self.lcd.write_cmd(data | LCD_BACKLIGHT)
  File "/home/pi/rpi_keypad_db_security_system/drivers/i2c_dev.py", line 74, in write_cmd
    self.bus.write_byte(self.addr, cmd)
OSError: [Errno 121] Remote I/O error

Solution

I powered the LCD to the 5V pin of my Raspberry Pi GPIO. It turns out that not enough current is supplied by my Raspberry Pi charger. Powering this sensor or display with a separate power source will solve the issue. Just make sure that you connect the ground between your Raspberry Pi and your external source.

This could also be a case of bad connections or wiring between the GPIO pins and the I2C LCD getting cut. Replace the wires and validate.

The Servo motor is not moving a full 180-degree

My servo is not moving the full zero to 180 degrees even if I have set the duty cycle according to the datasheet specification.

Solution

Please see the following link.

The Servo motor is jittery

The servo motor appears to be jittery and is moving a lot or not staying in position.

Solution

I found the following solutions to work in my case. I am not sure if this will work out in your case.

In my code, if your servo motor does not need to move then setting the duty cycle to zero will keep the servo motor from jittering.

pwm = GPIO.PWM(servo_pin,50) 
pwm.ChangeDutyCycle(0)

Another solution is to power your servo motor from a different power source and not the Raspberry Pi. Just make sure to connect the ground of your external source with that of the Raspberry Pi.

These two solutions appear to have fixed my issues. Try it out yourselves and let me know if this works.

Wrap Up

I will keep updating this post to list down some of the common errors that I have encountered while working with my Raspberry Pi.

Stay Tuned! Happy Exploring!

Support Me!

I love sharing what I know and hopefully, I was able to help you. Writing helpful content takes so much time and research. If you think you like my work and I have managed to help you then please consider supporting my channel. I would be very grateful and would boost my confidence that what I am doing is making a big change in the world. (No Pun Intended!) 😉

Become a Patron!
If you like my post then please consider sharing this. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *