Advertisement
fabiobiondi

bmp180-demo.py

Oct 22nd, 2021
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. from bmp180 import BMP180
  2. from machine import I2C, Pin, SoftI2C # create an I2C bus object accordingly to the port you are using
  3. # bus = I2C(1, baudrate=100000) # on pyboard
  4. # bus = I2C(scl=Pin(12), sda=Pin(35), freq=100000) # on esp8266
  5. bus = i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
  6. bmp180 = BMP180(bus)
  7. bmp180.oversample_sett = 2
  8. bmp180.baseline = 101325
  9. from time import sleep
  10.  
  11. from utils import myoled
  12.  
  13.  
  14. while True:
  15. temp = bmp180.temperature
  16. p = bmp180.pressure
  17. altitude = bmp180.altitude
  18. print(temp, p, altitude)
  19. myoled.show('Temp: ' + str(temp), 4, True)
  20. sleep(0.1)
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement