import time from w1thermsensor import W1ThermSensor import board import busio import adafruit_bme280 print ("imports are done") # BME280_Read_A Routine # From BC-Robotics Tutorials (see Source at end) # Just like the last sensor, we will import the library, set up the sensor, # read the sensor, and print the results. Since we are now using the Circuit # Python compatible libraries in this tutorial, there are a few extra chunks # of code to add. # # precede this program by the following Terminal commands: # > $ sudo apt-get update # > $ sudo pip3 install --upgrade setuptools # > $ pip3 install RPI.GPIO # > $ pip3 install adafruit-blinka # > $ sudo pip3 install adafruit-circuitpython-bme280 # > $ sudo pip3 install adafruit-circuitpython-ads1x15 # no DS180B20 # > $ sudo apt-get install python3-w1thermsensor # Preferences set to enable i2c and 1-wire # Imports now succeed..... #imports are done # At 2021AJan08, it printed: # Case Temp: 37.6166015625 at Fri Jan 8 16:23:50 2021 # Humidity: 6.007022899516082 % # Pressure: 101.01191766932729 kPa i2c = busio.I2C(board.SCL, board.SDA) print (i2c) print ("BME280_Read_B.py") bme = adafruit_bme280.Adafruit_BME280_I2C(i2c) # comment out the reference to ds18b20 #ds18b20 = W1ThermSensor() interval = 5 #How long we want to wait between loops (seconds) while True: time.sleep(interval) #Pull Temperature from DS18B20 # comment out the reference to ds18b20 # temperature = ds18b20.get_temperature() #Pull temperature from BME280 case_temp = bme.temperature #Pull pressure from BME280 Sensor & convert to kPa pressure_pa = bme.pressure pressure = pressure_pa / 10 #Pull humidity from BME280 humidity = bme.humidity #Print the results # comment out the reference to ds18b20 # print( 'Temperature: ' , temperature) print( ' Case Temp.: ' , case_temp, 'C at',time.ctime()) print( 'Humidity: ' , humidity, '%') print( 'Pressure: ' , pressure, 'kPa') # print( ' ') # Source 1: https://bc-robotics.com/tutorials/raspberry-pi-weather-station-part-2/ # Source 2: http://ephotocaption.com/a/146/PiR2D_WiringE_NotesB.pdf # Original: Aspire-C:\Users\David\Dev\my programs\python\PiR2\BME280_Read_B.py # Updated: 2021AJan09 #/BME280_Read_B.py #-end-