Professional Documents
Culture Documents
Raspberry Pi”
Module 4-2:Serial Protocols
“Practical IoT with Raspberry Pi”
Raspberry ports
• UART
• I2C
• SPI
I2C
SPI
I2C
https://www.amazon.es/gp/product/B013G6FZVS
Module 4-2: Serial Protocols Speaker: Jorge Artieda
“Practical IoT with Raspberry Pi”
Enable I2C
Install services
git clone https://github.com/adafruit/Adafruit_Python_BMP.git
cd Adafruit_Python_BMP
sudo python3 setup.py install
Python code
sensor = BMP085.BMP085()
DHT11
Install library
Python code
#!/usr/bin/python
import Adafruit_DHT
sensor = Adafruit_DHT.DHT11
pin = 23
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature,
humidity))
else:
print('Failed to get reading. Try again!')
Conclusion