if pwr: # Fontys PCB V2 board from machine import Pin if not Pin(pwr, mode=Pin.OUT, pull=None, alt=-1).value(): Pin(pwr, mode=Pin.OUT, pull=None, alt=-1).value(1) def BME_ID(i2c, address=0x77): BME_ID_ADDR = const(0xd0) # Create I2C device. if not type(i2c) is I2C: raise ValueError('An I2C object is required.') return int.from_bytes(i2c.readfrom_mem(address, BME_ID_ADDR, 1), 'little') & 0xFF i2c = I2C(0, I2C.MASTER, pins=pins) print("Find and install I2C devices via I2C bus scan") addrs = i2c.scan() print("Registers of devices on I2C bus: ", addrs) for addr in addrs: print("Try I2C addr: 0x%X" % addr) try: if (addr == 0x77) or (addr == 0x76): BME280_ID = const(0x60) BME680_ID = const(0x61) print("Try as BME280/680 device") try: bmeID = BME_ID(i2c, address=addr) except:
''' 实验名称:人体感应传感器 版本:v1.0 日期:2019.8 作者:01Studio(www.01studio.org) 说明:人体红外感应传感器应用 ''' import time from machine import I2C,Pin #从machine模块导入I2C、Pin子模块 from ssd1306 import SSD1306_I2C #从ssd1306模块中导入SSD1306_I2C子模块 #pyBoard I2C初始化 i2c = I2C(sda=Pin(13), scl=Pin(14)) #OLED显示屏初始化:128*64分辨率,OLED的I2C地址是0x3c oled = SSD1306_I2C(128, 64, i2c, addr=0x3c) Human=Pin(22,Pin.IN,Pin.PULL_UP) #构建人体红外对象 #OLED初始信息显示 oled.fill(0) # 清屏背景黑色 oled.text("01Studio", 0, 0) # 写入第1行内容 oled.text("Human body test:", 0, 15) # 写入第2行内容 oled.show() # OLED执行显示 def fun(Human): #Get People闪烁5次效果! for i in range(5): oled.fill(0) # 清屏背景黑色 oled.text("01Studio", 0, 0) # 写入第1行内容 oled.text("Human body test:", 0, 15) # 写入第2行内容
mot1 = PWM(Pin(0, 5000)) mot1.duty(400) mot2 = PWM(Pin(2, 5000)) mot2.duty(350) tim = Timer(-1) ligado = 0 desligado = 1 in1 = Pin(14, Pin.OUT) in2 = Pin(12, Pin.OUT) in3 = Pin(13, Pin.OUT) in4 = Pin(15, Pin.OUT) i2c = I2C(-1, Pin(5), Pin(4)) display = ssd1306.SSD1306_I2C(128, 64, i2c) def read(t): value = requests.get( "http://blynk-cloud.com/iTArttJxBXtIN76gIDHXx-pHJP3-Xapx/get/v0") value = int(value.text[2]) botao = requests.get( "http://blynk-cloud.com/iTArttJxBXtIN76gIDHXx-pHJP3-Xapx/get/v1") botao = int(botao.text[2]) image(value) motor(botao)
socketObject = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM) socketObject.connect(("remote.ertviper.org", 8038)) print(" Sending \n") socketObject.send(post) print(socketObject.readline()) print("Printing the remainder of the server's response: \n") # Use a "standard" receive call, "recv", # to receive a specified number of # bytes from the server, or as many bytes as are available. # Receive and output the remainder of the page data. socketObject.close() print("Socket closed.") i2c = I2C(1, freq=400000) # I2c Module c = network.Cellular() def command_read(comm): switcher = {1: "C1", 2: "C2", 3: "C3", 4: "C4", 5: "C5"} return switcher.get(comm, "Invalid command") def i2c_read(): global i2c data_i2c = i2c.readfrom(40, 4) data_i2c = int.from_bytes(data_i2c, byteorder='big') return data_i2c
from machine import Pin, I2C INT_MODE = True # Run in interrupt mode. INT_FLAG = False # Set True on interrupt. def imu_int_handler(pin): global INT_FLAG INT_FLAG = True if INT_MODE == True: int_pin = Pin(24) int_pin.irq(handler=imu_int_handler, trigger=Pin.IRQ_RISING) i2c = I2C(0, scl=Pin(13), sda=Pin(12)) # Vibration detection example UCF_FILE = "lsm6dsox_vibration_monitoring.ucf" UCF_LABELS = {0: "no vibration", 1: "low vibration", 2: "high vibration"} # NOTE: Selected data rate and scale must match the MLC data rate and scale. lsm = LSM6DSOX(i2c, gyro_odr=26, accel_odr=26, gyro_scale=2000, accel_scale=4, ucf=UCF_FILE) # Head gestures example # UCF_FILE = "lsm6dsox_head_gestures.ucf" # UCF_LABELS = {0:"Nod", 1:"Shake", 2:"Stationary", 3:"Swing", 4:"Walk"}
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import time import xbee from machine import I2C from hdc1080 import HDC1080 MODEM_STATUS_NETWORK_WOKE = 0x0B # Initialize the HDC1080 sensor. sensor = HDC1080(I2C(1)) def handle_modem_status(status): if status == MODEM_STATUS_NETWORK_WOKE: temp_celsius = sensor.read_temperature(True) aggregator_addr = xbee.atcmd("DH") + xbee.atcmd("DL") xbee.transmit(aggregator_addr, "{}".format(temp_celsius)) # Register the above function as the modem status callback so that it # will be called whenever a modem status is generated. xbee.modem_status.callback(handle_modem_status) # Enable sync sleep modem status messages xbee.atcmd("SO", 4)
import sensor import image import lcd import time import utime import KPU as kpu from fpioa_manager import fm from machine import I2C from Maix import I2S, GPIO fm.register(board_info.LED_B, fm.fpioa.GPIO6) led_b = GPIO(GPIO.GPIO6, GPIO.OUT) led_b.value(1) #RGBW LEDs are Active Low i2c = I2C(I2C.I2C0, freq=400000, scl=28, sda=29) fm.register(board_info.SPK_SD, fm.fpioa.GPIO0) spk_sd = GPIO(GPIO.GPIO0, GPIO.OUT) spk_sd.value(1) #Enable the SPK output fm.register(board_info.SPK_DIN, fm.fpioa.I2S0_OUT_D1) fm.register(board_info.SPK_BCLK, fm.fpioa.I2S0_SCLK) fm.register(board_info.SPK_LRCLK, fm.fpioa.I2S0_WS) wav_dev = I2S(I2S.DEVICE_0) def play_sound(filename): try: player = audio.Audio(path=filename)
# Read the data from Pressure sensor (Pressure, temperature ) and # display it on REPL # # See GitHub: https://github.com/mchobby/esp8266-upy/tree/master/hat-sense # # Author: Meurisse D. for Shop.mchobby.be # from machine import I2C from sensehat import * import time # PYBStick, Hat-Face: Sda=S3, Scl=S5 i2c = I2C(1) hat = SenseHat(i2c) while True: # Read Pressure and Temperature print("%8.2f hPa, %3.1f Celcius" % hat.pressure) time.sleep(1)
# tested on M5Stack Gray # based on http://blog.akanumahiroaki.com/entry/2018/10/27/235000 from m5stack import lcd from machine import I2C from mpu9250 import MPU9250 import time i2c = I2C(sda=21, scl=22) sensor = MPU9250(i2c) lcd.clear() x, y = 0, 0 while True: ax, ay, az = sensor.acceleration ax = ax * -1 # original is left negative # clear previous ball lcd.circle(x, y, 5, lcd.BLACK, lcd.BLACK) # g-bowl lcd.circle(160, 120, 110, lcd.WHITE) lcd.circle(160, 120, 55, lcd.WHITE) lcd.line(50, 120, 270, 120, lcd.WHITE) lcd.line(160, 10, 160, 230, lcd.WHITE) # plot ball x = int(ax * (55 / 10)) + 160 y = int(ay * (55 / 10)) + 120 lcd.circle(x, y, 5, lcd.RED, lcd.RED)
temp_mag = (temp_raw & 0x7fff) temp_sig = (temp_raw & 0x8000) >> 7 prev_temp = (1 - 2 * temp_sig) * temp_mag * .0078 def button_press(pin) : global button if pin == Pin(14) and button != 1 : button = 1 elif pin == Pin(15) and button == 1 : button = 2 buttom_timer.init(mode=Timer.ONE_SHOT, period=200, callback=on_pressed) # main code i2c = I2C(1, scl=Pin(22), sda=Pin(23), freq=400000) button_g = Pin(14, Pin.IN, Pin.PULL_UP) button_g.irq(trigger=Pin.IRQ_FALLING, handler=button_press) button_r = Pin(15, Pin.IN, Pin.PULL_UP) button_r.irq(trigger=Pin.IRQ_FALLING, handler=button_press) buttom_timer = Timer(1) led_r = Pin(17, Pin.OUT, value=1) led_y = Pin(16, Pin.OUT, value=1) led_g = Pin(19, Pin.OUT, value=1) onboard = PWM(Pin(13)) onboard.freq(0) onboard.duty(0)
def __init__(self, scl_pinno=SCL_PIN, sda_pinno=SDA_PIN): self.i2c = I2C(scl=Pin(scl_pinno, Pin.IN), sda=Pin(sda_pinno, Pin.IN))
# Created by Chenye Yang, Haokai Zhao, Zhuoyue Xing on 2019/9/28. # Copyright © 2019 Chenye Yang, Haokai Zhao, Zhuoyue Xing . All rights reserved. from machine import I2C, Pin import ssd1306 import time i2c = I2C(-1, scl=Pin(5), sda=Pin(4)) # initialize access to the I2C bus i2c.scan() oled = ssd1306.SSD1306_I2C(128, 32, i2c) # the width=128 and height=32 redLED = Pin(15, Pin.OUT, value=0) weekday = { 0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday', 6: 'Sunday' } monthdays = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30,
# LSM6DSOX Basic Example. import time from lsm6dsox import LSM6DSOX from machine import Pin, I2C lsm = LSM6DSOX(I2C(0, scl=Pin(13), sda=Pin(12))) while True: print("Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}".format( *lsm.read_accel())) print("Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}".format( *lsm.read_gyro())) print("") time.sleep_ms(100)
from machine import Pin, I2C, ADC from ssd1306 import SSD1306_I2C import utime import time #joystick xAx = ADC(Pin(27)) yAx = ADC(Pin(26)) button = Pin(16,Pin.IN, Pin.PULL_UP) WIDTH = 128 HEIGHT = 64 i2c = I2C(0) print("I2C adres : "+hex(i2c.scan()[0]).upper()) print("I2C konfiguracja : "+str(i2c)) oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) oled.fill(0) oled.show() while True: oled.fill(0) oled.rect(0,0,127,63,1) oled.rect(0,0,127,16,1) xValue = xAx.read_u16() yValue = yAx.read_u16() wspol = 546.125 xFloat = (32767.5-xValue)/wspol yFloat = (32767.5-yValue)/wspol buttonValue = button.value() xStatus = "centrum x " yStatus = "centrum y " buttonStatus = "wycisniety" if xValue <= 600: xStatus = "lewo "
f.close() except Exception: ide = False if ide: os.remove(ide_mode_conf) from machine import UART import lcd lcd.init(color=lcd.PINK) repl = UART.repl_uart() repl.init(1500000, 8, None, 1, read_buf_len=2048, ide=True, from_ide=False) sys.exit() # MaixCube PMU AXP173 from machine import I2C i2c_bus = I2C(I2C.I2C0, freq=400000, scl=30, sda=31) axp173_addr = 0x34 dev_list = i2c_bus.scan() if axp173_addr in dev_list: # print("I2C:" + str(i2c_bus.scan())) i2c_bus.writeto_mem(axp173_addr, 0x46, 0xFF) # Clear the interrupts i2c_bus.writeto_mem( axp173_addr, 0x33, 0xC1 ) # set target voltage and current of battery(axp173 datasheet PG.) # REG 10H: EXTEN & DC-DC2 control reg = (i2c_bus.readfrom_mem(axp173_addr, 0x10, 1))[0] # read reg value i2c_bus.writeto_mem(axp173_addr, 0x10, reg & 0xFC) del reg
# coroutine pauzeren await asyncio.sleep_ms(50) # coroutine LED intensiteit aanpassen async def LEDIntensity(): # oneindige lus while True: # LED intenteit aanpassen myGlobals.led.duty(myGlobals.intensity) # coroutine pauzeren await asyncio.sleep_ms(50) # i2c, lcd en oled instances i2c = I2C(scl=Pin(21), sda=Pin(22)) lcd = I2cLcd(i2c, lcd_i2c_address, 2, 16) oled = ssd1306.SSD1306_I2C(128, 64, i2c, addr = oled_i2c_address) # knop instances for i in range(len(KNOPPin)): myGlobals.knop.append(Pin(KNOPPin[i], Pin.IN, Pin.PULL_UP)) if i == 0: myGlobals.mult.append(-1) else: myGlobals.mult.append(1) # led instance (PWM) myGlobals.led = PWM(Pin(LEDPin), freq=100) myGlobals.led.duty(myGlobals.intensity)
from time import sleep_ms from machine import Pin, UART, I2C import math from mpu9250 import MPU9250 #地磁気センサ用ライブラリ #初期設定 uart = UART(1, 115200) #ここではUART1使用 sleep_ms(1000) led = machine.Pin(25, machine.Pin.OUT) sda = Pin(16) scl = Pin(17) i2c = I2C(0, sda=sda, scl=scl, freq=115200) sensor = MPU9250(i2c) while True: ######################################################## # 地磁気センサのデータを0〜360度に変換 ######################################################## #磁気の生値 単位:マイクロテスラ #マニュアルでのキャリブレーション #x = sensor.magnetic[0] - 3 #y = sensor.magnetic[1] - 43 x = sensor.magnetic[0] + 20 y = sensor.magnetic[1] - 35 #if not y == 0: if x >= 0 and y >= 0: #第一象限 heading = math.degrees(math.atan(y / x)) elif x < 0 and y >= 0: #第二象限
from umqtt import simple import ssd1306 import wifi try: wifi.wifi_connect() except: wifi.hotspot_connect() pe = Pin(23) servo = PWM(pe, freq=50) # ESP32 Pin assignment i2c = I2C(-1, scl=Pin(22), sda=Pin(21)) p = Pin(2, Pin.OUT) p.value(1) # ESP8266 Pin assignment #i2c = I2C(-1, scl=Pin(5), sda=Pin(4)) oled_width = 128 oled_height = 32 try: oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c) oled.init_display() oled.text('Initialized', 0, 0) oled.text('Waiting a mssg.', 0, 10)
import time from machine import I2C, Pin from bme280_float import BME280, BME280_OSAMPLE_8 # BME280 - SPIs # D1 - 05 - SCL # D2 - 04 - SDA # init sensor i2c = I2C(scl=Pin(5), sda=Pin(4)) bme280 = BME280(i2c=i2c, mode=BME280_OSAMPLE_8) def read_data(bme280): data = bme280.read_compensated_data() dew = bme280.dew_point print("{:6.2}°C {:10}hPa {:5.2}% {:6.2}°C(dew)".format(data[0], data[1], data[2], dew)) return [data[0], data[1], data[2], dew] while (True): read_data(bme280) time.sleep(2)
from time import sleep, sleep_ms, ticks_ms, ticks_diff from machine import Pin, I2C import os import sys import ssd1306 from struct import unpack as unp led = Pin(14, Pin.OUT) pump = Pin(13, Pin.OUT) btnLeft = Pin(12, Pin.IN, Pin.PULL_UP) btnDown = Pin(2, Pin.IN, Pin.PULL_UP) btnA = Pin(0, Pin.IN, Pin.PULL_UP) buzzer = Pin(15, Pin.OUT) i2c = I2C(-1, Pin(5), Pin(4)) # SCL, SDA display = ssd1306.SSD1306_I2C(128, 64, i2c) # turn off everything led.on() pump.on() def pressed(btn, wait_release=False): if not btn.value(): sleep_ms(30) if btn.value(): return False #wait for key release while wait_release and not btn.value(): sleep_ms(5)
from machine import Pin, I2C, ADC, Timer from ssd1306 import SSD1306_I2C from utime import sleep_ms import gfx from arduinoMap import mymap oled_width = 128 oled_height = 64 # Init Display i2c = I2C(0,sda=Pin(0),scl=Pin(1),freq=40000) oled = SSD1306_I2C(oled_width, oled_height, i2c) graphics = gfx.GFX(oled_width, oled_height, oled.pixel) pot = ADC(26) Y = 65 reading = 0 timer = Timer() def readAna(timer): global Y global reading reading = pot.read_u16() Y = int(mymap(reading, 0, 65535, 62, 12)) timer.init(freq=100, mode=Timer.PERIODIC, callback=readAna) #oled.invert(True) graphics.line(0, 10, 126, 10, 1) graphics.line(0, 63, 126, 63, 1)
def __init__(self, scl_pin=5, sda_pin=4, clk_freq=100000): self._address = SHT20_I2CADDR pin_c = Pin(scl_pin) pin_d = Pin(sda_pin) self._bus = I2C(scl=pin_c, sda=pin_d, freq=clk_freq)
import time from machine import I2C import machine t24C512 = 512 * 1024 / 8 #512 Kbits t24C256 = 256 * 1024 / 8 #256 Kbits t24C128 = 128 * 1024 / 8 #128 Kbits t24C64 = 64 * 1024 / 8 #64 Kbits i2c = I2C(0, I2C.MASTER, baudrate=100000) class SingleEEPROM(): capacity = 0 address = 0x50 def __init__(self, chipType=t24C512, addr=0x50): self.capacity = int(chipType) self.address = int(addr) def writeEEPROM(self, eeaddress, value): data = bytearray(3) data[0] = eeaddress >> 8 #MSB data[1] = eeaddress & 0xFF #LSB data[2] = value i2c.writeto(self.address, data) time.sleep(.05) def readEEPROM(self, eeaddress): data = bytearray(2) data[0] = eeaddress >> 8 #MSB
import machine from machine import I2C, RTC, Pin, ADC import ssd1306 import time i2c = I2C(-1, machine.Pin(5), machine.Pin(4)) display = ssd1306.SSD1306_I2C(128, 32, i2c) adc = machine.ADC(0) rtc = machine.RTC() rtc.datetime((2019, 9, 25, 0, 3, 0, 0, 0)) rtc_datetime = {"year":0, "month":1, "day":2, "hour":4, "minute":5, "second":6} dict_index = 0 # change which pos do you want to change def select_change_option(p): global dict_index, rtc_datetime dict_index += 1 active = 0 while active < 20: if p.value() == 0: active += 1 else: return time.sleep_ms(1) display.fill(0) #clear the screen first dict_index = dict_index % 6 date_time_keys = list(rtc_datetime.keys()) display.text(str(date_time_keys[dict_index]), 10, 10)
CCS811_BOOTLOADER_APP_DATA = 0xF2 CCS811_BOOTLOADER_APP_VERIFY = 0xF3 CCS811_BOOTLOADER_APP_START = 0xF4 CCS811_DRIVE_MODE_IDLE = 0x00 CCS811_DRIVE_MODE_1SEC = 0x01 CCS811_DRIVE_MODE_10SEC = 0x02 CCS811_DRIVE_MODE_60SEC = 0x03 CCS811_DRIVE_MODE_250MS = 0x04 CCS811_HW_ID_CODE = 0x81 CCS811_REF_RESISTOR = 100000 #i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000) i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000) def rint8u(reg): ba = i2c.readfrom_mem(CCS811_ADDRESS, reg, 1) return int.from_bytes(ba, 'big') statfwmode = lambda stat: stat & 0x80 statappvalid = lambda stat: stat & 0x10 statdr = lambda stat: stat & 0x08 staterr = lambda stat: stat & 0x01 def mexit(str): print("Can't start CO2 app: %s" % (str))
def main(): print("I2C - LCD test start") # open I2C port i2c = I2C(0, scl=Pin(17), sda=Pin(16), freq=100000) print('Scan i2c bus...') devices = i2c.scan() if len(devices) == 0: print("No i2c device !") else: print('i2c devices found:', len(devices)) for device in devices: print("Decimal address: ", device, " | Hexa address: ", hex(device)) # now create LCD object with, hopefully, the only address found LCD = I2cLcd(i2c, device, 4, 20) # Test LCD.backlight_on() # build special character special_char = bytearray([0x4, 0xe, 0x1f, 0x4, 0x4, 0x4, 0x4, 0x4]) time.sleep(1) LCD.clear() LCD.custom_char(0x0, special_char) LCD.putstr("Hello World \n") # for repeat in range(2): # for x in range(20): # LCD.move_to(x, 1) # LCD.putchar(chr(0)) # time.sleep(0.2) # LCD.move_to(x, 1) # LCD.putchar(" ") time.sleep(1) LCD.blink_cursor_off() LCD.hide_cursor() LCD.move_to(10, 2) for x in range(ord('A'), ord('Z')): LCD.putchar_no_move(chr(x)) # LCD.move_cursor_left() time.sleep(0.3) LCD.move_to(10, 3) LCD.putchar_no_move('*') LCD.show_cursor() for x in range(10): LCD.move_cursor_left() time.sleep(0.3) for x in range(10): LCD.move_cursor_right() time.sleep(0.3) # LCD.backlight_off() print("I2C - LCD test end") # LCD.display_off() # LCD.backlight_off() gc.collect() print(gc.mem_free()) print(gc.mem_alloc())
## test i2c devices from machine import Pin, I2C i2c = I2C(sda=Pin(4), scl=Pin(5)) i2c.scan()
from machine import Pin, I2C import utime i2c = I2C( sda=Pin(4), scl=Pin(5)) # instanciamos y configuramos bus I2C en los pines sda y scl dispositivos_conectado = i2c.scan( ) # manda mensajes por el bus i2c a todas las direcciones para ver que dispositivos contestan # devuelve un listado de dispositivos conectados print( dispositivos_conectado ) # NOTA las direcciones las muestra en decimal, normalmente usaremos hexadecimal para trabajar con el i2c from apds9930 import APDS9930 sensor = APDS9930( i2c) # creamos una instancia del sensor y le pasamos el manejador del i2c # el manejador del i2c lo creamos aqui porque si tenemos varios sensores en el bus, le pasamos el mismo manejador a todos sensor.activar_proximidad( ) # este metodo modifica un registro interno del APDS9930 para activar el sensor de proximidad print("Acerca la mano al sensor para activarlo") while True: proximidad = sensor.get_proximidad() if proximidad is not 0: print("Activado! lectura {}".format(proximidad)) utime.sleep_ms(100) # para que no sature la consola con prints
KEYMAP = ['123A', '456B', '789C', '*0#D'] CHARMAP = { '1': '.1', '2': 'abc2', '3': 'def3', '4': 'ghi4', '5': 'jkl5', '6': 'mno6', '7': 'pqrs7', '8': 'tuv8', '9': 'wxyz9', '0': '_0', } i2c = I2C(scl=Pin(5), sda=Pin(4), freq=40000000) pcf = PCF8574(i2c, KEY_ADDR) keypad = Keypad(pcf, KEYMAP, CHARMAP) lcd = I2cLcd(i2c, LCD_ADDR, 2, 16) pcf1 = PCF8574(i2c, 57) pcf2 = PCF8574(i2c, 58) opto_mask = 0b11111111 storrage = Storrage() class SettingsErr(Exception): pass class CancelSignal(Exception):
from machine import I2C from machine import Pin DISPLAY = True i2c = I2C(-1, Pin(14), Pin(2)) if DISPLAY == True: import ssd1306 oled = ssd1306.SSD1306_I2C(128, 64, i2c) oled.fill(0) oled.show() import bme280 bme = bme280.BME280(i2c=i2c) #a=bme.read_compensated_data() b = bme.values if DISPLAY == True: oled.fill(0) oled.text(str(b[0]), 0, 30) oled.text(str(b[1]), 0, 40) oled.text(str(b[2]), 0, 50) oled.show() print(b)