# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime led = machine.Pin(25, machine.Pin.OUT) while True: led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |
# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime led = machine.Pin(25, machine.Pin.OUT) from DHT22 import DHT22 from machine import Pin dht_sensor=DHT22(Pin(15),dht11=False) while True: #--DHT22-------------------------------------------- T, H = dht_sensor.read() if T is None: print("Error en el sensor!") else: print("Sensor DHT22->","{}ºC {}%".format(T,H)) led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |
# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime led = machine.Pin(25, machine.Pin.OUT) from DHT22 import DHT22 from machine import Pin dht_sensor=DHT22(Pin(15),dht11=False) analog_value = machine.ADC(28) while True: #--DHT22-------------------------------------------- T, H = dht_sensor.read() if T is None: print("Error en el sensor!") else: print("Sensor DHT22->","{}ºC {}%".format(T,H)) #--LDR-------------------------------------------- reading = analog_value.read_u16() print("LDR-> ADC: ",reading) led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |
# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime from bmp180 import BMP180 from machine import I2C, Pin led = machine.Pin(25, machine.Pin.OUT) from DHT22 import DHT22 from machine import Pin dht_sensor=DHT22(Pin(15),dht11=False) analog_value = machine.ADC(28) i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000) bmp180 = BMP180(i2c) bmp180.oversample_sett = 2 baseline = bmp180.pressure/100 ALTURA = 790 print ("Doble sensor DHT22 y DS18x20") #Write in cmd found addresses i2cScan = i2c.scan() counter = 0 for i in i2cScan: print('I2C Address ' + str(counter) + ' : '+hex(i).upper()) print ("**************************") #--------------- while True: #--DHT22-------------------------------------------- T, H = dht_sensor.read() if T is None: print("Error en el sensor!") else: print("Sensor DHT22->","{}ºC {}%".format(T,H)) #--LDR-------------------------------------------- reading = analog_value.read_u16() print("LDR-> ADC: ",reading) #..BMP180--------------------------------------------- temperatura = bmp180.temperature presion = bmp180.pressure/100 alt2=44330.0* (1-pow(presion/baseline,1/5.255) ) alt2=ALTURA+alt2 alt2=round(alt2) temperatura=round(temperatura,1) presion=round(presion) print("Tem_BMP180=",temperatura,"ºC Presion=", presion," ALTITUD=",alt2) led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |
# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime from bmp180 import BMP180 from machine import I2C, Pin import onewire, ds18x20, time led = machine.Pin(25, machine.Pin.OUT) from DHT22 import DHT22 from machine import Pin dht_sensor=DHT22(Pin(15),dht11=False) analog_value = machine.ADC(28) i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000) bmp180 = BMP180(i2c) bmp180.oversample_sett = 2 baseline = bmp180.pressure/100 ALTURA = 790 print ("Doble sensor DHT22 y DS18x20") #Write in cmd found addresses i2cScan = i2c.scan() counter = 0 for i in i2cScan: print('I2C Address ' + str(counter) + ' : '+hex(i).upper()) print ("**************************") #--------------- ds_pin = machine.Pin(22) ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) roms = ds_sensor.scan() while True: #--DHT22-------------------------------------------- T, H = dht_sensor.read() if T is None: print("Error en el sensor!") else: print("Sensor DHT22->","{}ºC {}%".format(T,H)) #--LDR-------------------------------------------- reading = analog_value.read_u16() print("LDR-> ADC: ",reading) #..BMP180--------------------------------------------- temperatura = bmp180.temperature presion = bmp180.pressure/100 alt2=44330.0* (1-pow(presion/baseline,1/5.255) ) alt2=ALTURA+alt2 alt2=round(alt2) temperatura=round(temperatura,1) presion=round(presion) print("Tem_BMP180=",temperatura,"ºC Presion=", presion," ALTITUD=",alt2) #--DS18B20-------------------------------------------- ds_sensor.convert_temp() time.sleep_ms(750) x=0 for rom in roms: #print ("Sensor=",x," ",rom," Temperatura=",ds_sensor.read_temp(rom)) print ("Sensor_DS18B20_nº",x," "," Temperatura=",ds_sensor.read_temp(rom)) x=x+1 print("---------------------") led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |
# SETA43 # seta43.duckdns.org # seta43.blogspot.com # Palencia / España # 31-08-2022 import machine import utime from bmp180 import BMP180 from machine import I2C, Pin import onewire, ds18x20, time from DHT22 import DHT22 from machine import Pin from ssd1306 import SSD1306_I2C led = machine.Pin(25, machine.Pin.OUT) dht_sensor=DHT22(Pin(15),dht11=False) analog_value = machine.ADC(28) i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000) bmp180 = BMP180(i2c) bmp180.oversample_sett = 2 baseline = bmp180.pressure/100 ALTURA = 790 WIDTH = 128 # oled display width HEIGHT = 64 oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) print ("Doble sensor DHT22 y DS18x20") #Write in cmd found addresses i2cScan = i2c.scan() counter = 0 for i in i2cScan: print('I2C Address ' + str(counter) + ' : '+hex(i).upper()) print ("**************************") #--------------- ds_pin = machine.Pin(22) ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin)) roms = ds_sensor.scan() while True: #--DHT22-------------------------------------------- T, H = dht_sensor.read() if T is None: print("Error en el sensor!") else: print("Sensor DHT22->","{}ºC {}%".format(T,H)) #--LDR-------------------------------------------- reading = analog_value.read_u16() print("LDR-> ADC: ",reading) #..BMP180--------------------------------------------- temperatura = bmp180.temperature presion = bmp180.pressure/100 alt2=44330.0* (1-pow(presion/baseline,1/5.255) ) alt2=ALTURA+alt2 alt2=round(alt2) temperatura=round(temperatura,1) presion=round(presion) print("Tem_BMP180=",temperatura,"ºC Presion=", presion," ALTITUD=",alt2) #--DS18B20-------------------------------------------- ds_sensor.convert_temp() time.sleep_ms(750) x=0 for rom in roms: #print ("Sensor=",x," ",rom," Temperatura=",ds_sensor.read_temp(rom)) print ("Sensor_DS18B20_nº",x," "," Temperatura=",ds_sensor.read_temp(rom)) x=x+1 oled.fill(0) oled.text("-Seta43- ",0,8) tmp=str(T)+" C DHT22" oled.text(tmp,0,16) tmp=str(H)+" % DHT22" oled.text(tmp,0,24) tmp=str(presion)+" mBa BMP180" oled.text(tmp,0,32) tmp=str(alt2)+ " m BMP180" oled.text(tmp,0,40) tmp=str(reading)+" luz LDR" oled.text(tmp,0,48) oled.show() print("---------------------") led.value(0) utime.sleep(0.5) led.value(1) utime.sleep(0.5) |