About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

Tutorial 1 error

2423 Views - Created 05/10/2015

18/07/2015

Posted by:
giagara

Users Avatar

Hello,

I'm approaching to IoPi by using tutorial1.py.

When i run command python tutorial1.py, this error is raised:

 self._bus.write_byte_data(self.address, self.IOCON, self.config)
AttributeError: 'NoneType' object has no attribute 'write_byte_data'

I didn't edit the library file, i've only run this command.

I use python 2.

Can you help me?

Many thanks

BR

18/07/2015

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hello

The error that you are getting could mean that the raspberry pi is having trouble communicating with the IO Pi using the I2C bus.

Have you followed our tutorial on setting up I2C on the Raspberry Pi? It may be worth going through the steps in the tutorial to check that everything is installed correctly.  

Try running the command "i2cdetect -y 1".  This will bring up a list of all I2C devices on the Raspberry Pi.  The IO Pi should show up on channels 20 and 21.

AB Electronics UK Tech Support

21/10/2015

Posted by:
stevesilva

Users Avatar

I'm sort of having the same issue. Actually tutorial1.py works perfect running python from the console.

However, when we use the same code from an apache webserver page (which is a python file) we also get the same error

self._bus.write_byte_data(self.address, self.IOCON, self.config)
AttributeError: 'NoneType' object has no attribute 'write_byte_data'

'i2cdetect revealed that we can infact see the bus and that we can infact see the one card we have installed?

Any thoughts?

21/10/2015

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

It could be a permissions problem that is stopping apache from seeing the i2c bus.  Have you tried adding apache to the i2c user group?  If not you can do it using the following command.

sudo adduser www-data i2c

Once you have added apache to the group you will need to restart apache before running any python scripts.

sudo /etc/init.d/apache2 restart

Hopefully this will fix your problem.

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.