Skip to Content
Raspberry Pi 3 Cookbook for Python Programmers - Third Edition
book

Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

by Steven Lawrence Fernandes, Tim Cox
April 2018
Beginner content levelBeginner
552 pages
13h 58m
English
Packt Publishing
Content preview from Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

How it works...

We start by importing wiringpi2 so we can communicate with our I2C device later on. We will create a class to contain the required functionality to control the ADC. When we create the class, we can initialize wiringpi2 in such a way that it is ready to use the I2C bus (using wiringpi2.I2C()), and we will set up a generic I2C device with the chip's bus address (using self.i2c.setup(0x48)).

wiringpi2 also has a dedicated class to use with the PCF8591 chip; however, in this case, it is more useful to use the standard I2C functionality to illustrate how any I2C device can be controlled using wiringpi2. By referring to the device datasheet, you can use similar commands to communicate to any connected I2C device (whether it is directly ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Raspberry Pi for Python Programmers Cookbook - Second Edition

Raspberry Pi for Python Programmers Cookbook - Second Edition

Tim Cox

Publisher Resources

ISBN: 9781788629874Supplemental Content