Adafruit Motor HAT for pi test examples

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
gurmar
 
Posts: 3
Joined: Mon Feb 23, 2015 5:09 pm

Adafruit Motor HAT for pi test examples

Post by gurmar »

try to run the test examples for the HAT I recently bought, but they do not run.
I am getting IOError: Errno 2 no such file or directory

I did everything in the setup procedure correctly.

Please help me.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Motor HAT for pi test examples

Post by adafruit_support_rick »

Please post the entire error message. It may be several lines long. Which python example are you running ?

User avatar
gurmar
 
Posts: 3
Joined: Mon Feb 23, 2015 5:09 pm

Re: Adafruit Motor HAT for pi test examples

Post by gurmar »

the screen is:

pi@raspberrypi ~/Adafruit-Motor-HAT-Python-Library/examples $ sudo python StepperTest.py
Traceback (most recent call last):
File "StepperTest.py", line 3, in <module>
from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor, Adafruit_StepperMotor
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/__init__.py", line 1, in <module>
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_MotorHAT.py", line 3, in <module>
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 11, in <module>
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 35, in PWM
File "build/bdist.linux-armv6l/egg/Adafruit_MotorHAT/Adafruit_I2C.py", line 43, in __init__
IOError: [Errno 2] No such file or directory

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Motor HAT for pi test examples

Post by adafruit_support_rick »

It looks like you haven't configured I2C on your Pi.
https://learn.adafruit.com/adafruits-ra ... guring-i2c

User avatar
gurmar
 
Posts: 3
Joined: Mon Feb 23, 2015 5:09 pm

Re: Adafruit Motor HAT for pi test examples

Post by gurmar »

thanks a lot. finally I managed it work with your help.

User avatar
jhroelofs
 
Posts: 5
Joined: Wed May 06, 2015 12:00 pm

Re: Adafruit Motor HAT for pi test examples

Post by jhroelofs »

I'm having a similar problem- set up everything, I felt like I instalelled I2C and python properly, but I keep getting this error message:

pi@raspberrypi ~/Adafruit-Motor-HAT-Python-Library/examples $ sudo python DCTest.py
Traceback (most recent call last):
File "DCTest.py", line 2, in <module>
from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor
File "/usr/local/lib/python2.7/dist-packages/Adafruit_MotorHAT-1.2.0-py2.7.egg/Adafruit_MotorHAT/__init__.py", line 1, in <module>
from .Adafruit_MotorHAT import Adafruit_StepperMotor, Adafruit_DCMotor, Adafruit_MotorHAT
File "/usr/local/lib/python2.7/dist-packages/Adafruit_MotorHAT-1.2.0-py2.7.egg/Adafruit_MotorHAT/Adafruit_MotorHAT.py", line 3, in <module>
from Adafruit_PWM_Servo_Driver import PWM
File "/usr/local/lib/python2.7/dist-packages/Adafruit_MotorHAT-1.2.0-py2.7.egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 11, in <module>
class PWM :
File "/usr/local/lib/python2.7/dist-packages/Adafruit_MotorHAT-1.2.0-py2.7.egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 35, in PWM
general_call_i2c = Adafruit_I2C(0x00)
File "/usr/local/lib/python2.7/dist-packages/Adafruit_MotorHAT-1.2.0-py2.7.egg/Adafruit_MotorHAT/Adafruit_I2C.py", line 43, in __init__
self.bus = smbus.SMBus(busnum if busnum >= 0 else Adafruit_I2C.getPiI2CBusNumber())
IOError: [Errno 2] No such file or directory

Any ideas?
Thanks!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Motor HAT for pi test examples

Post by adafruit_support_rick »

What do you get from the command i2cdetect -y 1

User avatar
jhroelofs
 
Posts: 5
Joined: Wed May 06, 2015 12:00 pm

Re: Adafruit Motor HAT for pi test examples

Post by jhroelofs »

I had to run it as root, and got the following:

pi@raspberrypi ~ $ i2cdetect -y 1
Error: Could not open file `/dev/i2c-1': Permission denied
Run as root?
pi@raspberrypi ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --

User avatar
jhroelofs
 
Posts: 5
Joined: Wed May 06, 2015 12:00 pm

Re: Adafruit Motor HAT for pi test examples

Post by jhroelofs »

Also, when I try to run the example DCTest.py, I get

Error accessing 0x61: Check your I2C address

Repeating over and over until I shut the pi down

User avatar
jhroelofs
 
Posts: 5
Joined: Wed May 06, 2015 12:00 pm

Re: Adafruit Motor HAT for pi test examples

Post by jhroelofs »

I changed the "addr=0x61" in the DCTest.py script to a 60 and it worked! Not sure exactly what happened but we're good to go!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Motor HAT for pi test examples

Post by adafruit_support_rick »

Great!

User avatar
bdog253
 
Posts: 2
Joined: Tue Jun 30, 2015 10:29 pm

Re: Adafruit Motor HAT for pi test examples

Post by bdog253 »

Hey guys,

I was having the same issues with the addressing and fixed it by changing it to use 0x60. The issue I'm running into now is that when I run the script the first time it starts the motor but then reboots the pi. Once rebooted if I run the script again it seems to work okay. When I hit ctrl-C to get out of the loop and then try and run again it then reboots.

Did I screw up my hat while soldering? Is there a quick way to test if the hat is still okay?

Thanks in advance.


*** EDIT ***
Upon further investigation it would seem when running the code the first time it just starts the motor at half speed and then reboots. When I commented out the line of code that says myMotors.setSpeed(150) everything seemed to work okay and it no longer reboots.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Motor HAT for pi test examples

Post by adafruit_support_rick »

So you're good to go?

User avatar
bdog253
 
Posts: 2
Joined: Tue Jun 30, 2015 10:29 pm

Re: Adafruit Motor HAT for pi test examples

Post by bdog253 »

Yes thanks. Everything seems to be working as long as I don't have that line of code. Not sure why. I've written a bunch of other scripts to test out 3 motors and everything seems okay. Thanks again!

User avatar
JTibbetts
 
Posts: 3
Joined: Wed Nov 18, 2015 8:10 am

Re: Adafruit Motor HAT for pi test examples

Post by JTibbetts »

Hi, we are also getting similar issues (by this i mean it won't power the motor and get error messages out the yingyang) but, changing it to 60 did nothing.
Please help.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”