![python 2.7 serial library python 2.7 serial library](http://net-informations.com/python/intro/img/version.png)
The whole scheme can be seen in the picture below:įor this post I am using the compass module w hich uses the I2C serial communication to talk to the master device which in our case is Raspberry Pi. Then click on the Python 3.0 IDLE and the window will appear in front of you. For this go into the Raspberry Pi menu at the top left corner of the screen.
#Python 2.7 serial library code
Now it is the time to write the code in the Python IDLE. Type the following command in the terminal window and press enter.Ī chart will appear in the terminal window with the addresses of your slave devices connected to the I2C serial communication bus of the Raspberry Pi.Īfter this we are all set up and ready for writing the python module for communicating with the I2C device. It is not difficult as it also needs the execution of the single command in the terminal window. Hence as described in the previous post it is important that you know the address of each slave device.
![python 2.7 serial library python 2.7 serial library](https://www.techmonkeybusiness.com/images/Tech/pySerial_in_Blender272.jpg)
In our case the master device is definitely Raspberry Pi and a number of slave devices can be connected to the single I2C serial communication bus.
![python 2.7 serial library python 2.7 serial library](https://b3van8qm1o7ou9d3b48qdhsg-wpengine.netdna-ssl.com/wp-content/uploads/2020/07/19R-01.png)
Getting the Address of the I2C Slave:Īs we know the in the I2C communication there can be many master devices and number of slave devices. After the execution of this command you will be able to write the I2C code in the Python shell.