while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed( Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)): ugfx.Label( 5, 5, 240, 15, "Temperature (tmp) : {:.2f} C".format(Sensors.get_tmp_temperature())) ugfx.Label( 5, 20, 240, 15, "Temperature (hdc) : {:.2f} C".format(Sensors.get_hdc_temperature())) ugfx.Label( 5, 35, 240, 15, "Humidity (hdc) : {:.2f} %".format(Sensors.get_hdc_humidity())) ugfx.Label(5, 50, 240, 15, "Light (opt) : {:.2f} Lux".format(Sensors.get_lux())) ugfx.Label(5, 65, 240, 15, "Mag Field: (drv) : {:.2f} ".format(mag.convert())) ugfx.Label(5, 80, 240, 15, "Sensor samplerate : {} ms".format(Sensors.sample_rate())) charging = Sensors.get_charge_status() if charging == Sensors.BAT_PRE_CHARGING or charging == Sensors.BAT_FAST_CHARGING: ugfx.Label(5, 110, 240, 15, "Battery is : charging") elif charging == Sensors.BAT_DONE_CHARGING: ugfx.Label(5, 110, 240, 15, "Battery is : full") elif charging == Sensors.BAT_NOT_CHARGING: ugfx.Label(5, 110, 240, 15, "Battery is : discharging") ugfx.Label(5, 125, 240, 15, "Battery is : {:.2f} %".format(sim800.batterycharge())) sleep(2)
# # Basic exercise of ADC single-sample interface. Assumes two channels configured # in board.c # from machine import ADC adc0 = ADC(0) try: adcX = ADC(0) print("pass") except: print("error: multiple opens") try: adcX = ADC(99) print("error: bogus channel open") except: print("pass") adc1 = ADC(1) print(adc0, adc1) for i in range(10): print(adc0.convert(), adc1.convert())