I have just shared content in Guides > Raspberry Pi: “How to use Stepper Motors and DC Motors with a Raspberry Pi - Adafruit DC & Stepper Motor HAT”
Read more
Hey all,
Just learned some more information on this Adafruit HAT. If you want to use GPIO Pins (say for limit switches) the below image shows exactly what Pads are broken out and unused by the HAT. These pads are directly connected to the corresponding pins on the GPIO header and labeled correctly.
Hi, I’m sorry to bother you, I bought a stepper motor hat but can’t seem to get the code to run. I’ve soldered on the contacts correctly, and downloaded the libraries as per the tutorial but I’m getting the following error:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py”, line 175, in __probe_for_device
self.i2c.writeto(self.device_address, b"")
File “/usr/local/lib/python3.9/dist-packages/busio.py”, line 207, in writeto
return self._i2c.writeto(address, buffer, stop=True)
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py”, line 60, in writeto
self._i2c_bus.write_bytes(address, buffer[start:end])
File “/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py”, line 303, in write_bytes
self._device.write(buf)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py”, line 181, in __probe_for_device
self.i2c.readfrom_into(self.device_address, result)
File “/usr/local/lib/python3.9/dist-packages/busio.py”, line 197, in readfrom_into
return self._i2c.readfrom_into(address, buffer, stop=True)
File “/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py”, line 67, in readfrom_into
readin = self._i2c_bus.read_bytes(address, end - start)
File “/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py”, line 170, in read_bytes
return self._device.read(number)
OSError: [Errno 121] Remote I/O error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/home/acdwi/Steppe-Motor-Control.py”, line 8, in
kit = MotorKit(i2c=board.I2C())
File “/usr/local/lib/python3.9/dist-packages/adafruit_motorkit.py”, line 82, in init
self._pca = PCA9685(i2c, address=address)
File “/usr/local/lib/python3.9/dist-packages/adafruit_pca9685.py”, line 150, in init
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
File “/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py”, line 62, in init
self.__probe_for_device()
File “/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py”, line 184, in __probe_for_device
raise ValueError(“No I2C device at address: 0x%x” % self.device_address)
ValueError: No I2C device at address: 0x60
If anyone has any suggestions I’d be incredibly grateful! You seem very knowledgeable
Many thanks,
- Richard Johnson
This means that the I2C code couldn’t find any device on the I2C bus with an address of 0x60. This is the default address for the PCA9685 PWM controller, so it should be found if the hat is properly connected. Have you changed the address by soldering across any of the jumpers A0 through A4?
You can check what I2C devices are visible to your code using the procedure described here:
Raspberry Pi | How to Scan and Detect I2C Addresses | Adafruit Learning System
Have you previously run any other I2C devices?
You should post photos of the hat and the setup so that other eyes have a chance to spot what you might have missed.
Hi
Thank you so much for you insight! I’ll look into it right away and see how it goes
Your brilliance and intellect are highly commendable!
I’m chuffed to bits that I actually heard back from someone
Many thanks!
- Richard Johnson
I’d like to add some sanity checks:
- Is I2C enabled? eg. through
sudo raspi-config
then under theinterfaces
- can you share some pictures of your setup - we often find this really helpful
Hello I’m working on a science fair project where I’m making a robot that able to land terrain. Now I’m using a raspberry pi 5 8gb. I have look over the video and copied all the institution I believe and enabled I2C but when I run the test code for the dc motor I get this error message in the command terminal.
Traceback (most recent call last):
File "/home/angstboater9/Desktop/dc motor contorler.py", line 8, in <module>
kit = MotorKit(i2c = board.I2C())
File "/usr/local/lib/python3.11/dist-packages/adafruit_motorkit.py", line 83, in __init__
self._pca.frequency = pwm_frequency
File "/usr/local/lib/python3.11/dist-packages/adafruit_pca9685.py", line 176, in frequency
old_mode = self.mode1_reg # Mode 1
File "/usr/local/lib/python3.11/dist-packages/adafruit_register/i2c_struct.py", line 81, in __get__
i2c.write_then_readinto(buf, buf, out_end=1, in_start=1)
File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py", line 140, in write_then_readinto
self.i2c.writeto_then_readfrom(
File "/usr/local/lib/python3.11/dist-packages/busio.py", line 232, in writeto_then_readfrom
return self._i2c.writeto_then_readfrom(
File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 98, in writeto_then_readfrom
readin = self._i2c_bus.read_i2c_block_data(
File "/usr/local/lib/python3.11/dist-packages/Adafruit_PureIO/smbus.py", line 264, in read_i2c_block_data
ioctl(self._device.fileno(), I2C_RDWR, request)
BlockingIOError: [Errno 11] Resource temporarily unavailable
These is the error message that I get if there is anyone that could help that would be wonderful. If you need any more information please tell me and I will response as fast as possible.
Welcome to the forum!
The error you’re encountering, BlockingIOError: [Errno 11] Resource temporarily unavailable
, typically occurs when there is a resource that is currently busy or unavailable for immediate access. In the context of I2C communication in Python, this error often indicates an issue with your I2C bus, where the I2C device or the bus itself is not ready to handle a request at the moment the operation was attempted.
Looking at the required libraries for the stepper motor hat it appears that it would use rpi.GPIO, without looking into it too much it may be the case that the hat will not be compatible with a Pi5 due to changes with how the Pi5 operates its GPIO pins.
Hello Dan
Thank you for responding so quickly.This might be a silly question but I have not been in the raspberry pi space and this was my first project. So is there any why to make the GPIO pins work with the adafruit stepper motor board. I also read the adafruit website to buy the board and It said that It would be comparable.
Thank you for your time
Hey @Banana287871,
The GPIO hardware was updated between the Pi 5 and earlier models in such a way that make GPIO code written for earlier Pi board revisions not work correctly. Unfortunately the RPi.GPIO library has yet to be updated to work on the Pi 5.
I will have a look into that guide today and see if I can modify it to work with a pi 5 for you today!