Exemplo n.º 1
0
def setup():

    i2c = I2C(Pin(5), Pin(4))

    global sensor_bmp
    sensor_bmp = bmp180.BMP180(i2c, debug=False)

    global sensor_si
    sensor_si = si7021.SI7021(i2c, debug=False)

    global pwm2
    pwm2 = PWM(Pin(2), freq=2, duty=512)

    global MESSAGES

    MESSAGES = {
        'BMP_T': None,
        'BMP_P': None,
        'SI_T': None,
        'SI_H': None,
    }


    global publish
    publish = make_publish()
Exemplo n.º 2
0
def setup():

    #OLED RESET PIN
    pin16 = machine.Pin(16, machine.Pin.OUT)
    pin16.value(1)

    #i2c = I2C(Pin(5), Pin(4)) #ESP8266 - ESP32 DEVKIT
    i2c = I2C(sda=Pin(4), scl=Pin(15))

    global sensor_si
    sensor_si = si7021.SI7021(i2c, debug=True)

    global display
    display = ssd1306.SSD1306_I2C(128, 64, i2c)

    display.fill(0)
    display.text('HELLO', 0, 10)
    display.show()

    global ping
    ping = ""

    global si_temperature
    si_temperature = -251
    global si_humidity
    si_humidity = -251

    global pwm2
    #pwm2 = PWM(Pin(2), freq=2, duty=512) #ESP8266 - ESP32 DEVKIT
    pwm2 = PWM(Pin(25), freq=2, duty=512)  #ESP32+LORA+OLED
Exemplo n.º 3
0
 def __init__(self):
     import si7021
     from machine import I2C, Pin
     try:
         i2c = I2C(sda=Pin(5), scl=Pin(4))
         self.sensor = si7021.SI7021(i2c)
     except:
         print("Debug: Unable to initialize sensor")
 def __init__(self):
     self._name = "Westhill Laser Measument System"
     self._wlan = network.WLAN(network.STA_IF)
     self.connect_wifi()
     self._sd = machine.SDCard(slot=3, sck=machine.Pin(14), miso=machine.Pin(12)
                              ,mosi=machine.Pin(13),cs=machine.Pin(15))
     uos.mount(self._sd, SD_FILE)
     self._th_sensor = si7021.SI7021(4, 21)
     self._buzz = Buzzer(26)
Exemplo n.º 5
0
def setup():

    #i2c = I2C(Pin(5), Pin(4)) #ESP8266 - ESP32 DEVKIT
    i2c = I2C(sda=Pin(4), scl=Pin(5))  #Wemos D1: pin4=D2, pin5=D1

    global sensor_si
    sensor_si = si7021.SI7021(i2c, debug=True)

    global pwm2
    pwm2 = PWM(Pin(2), freq=2, duty=512)  #ESP8266 - ESP32 DEVKIT
Exemplo n.º 6
0
import binascii
import machine
import lora
from config import dev_eui, app_eui, app_key
import si7021
from wrapper import LED

# Connect to LoRaWAN
n = lora.LORA()
n.connect(dev_eui, app_eui, app_key)

# LED status
led = -1

# Connect sensor
sensor = si7021.SI7021()


def handle_state(data):
    global led
    state = None

    try:
        state = ujson.loads(data)[0]
    except ValueError as e:
        print("Exception occured while parsing state")
        return

    print("Parsed state: ", state)

    if (int(state['led']['desired']) > 0):
Exemplo n.º 7
0
essid = 'ssid'
password = '******'
channelId = 100
writeKey = 'writeKey'


def do_connect():
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect(essid, password)
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())


i2c = I2C(scl=Pin(22), sda=Pin(21))  # I2Cオブジェクトを作る
si7021 = si7021.SI7021(i2c)  # SI7021オブジェクトを作る
do_connect()
am = ambient.Ambient(channelId, writeKey)

while True:
    temp = si7021.temp
    humid = si7021.humid
    print(temp, humid)  # SI7021オブジェクトを使い、温度、湿度を取得
    r = am.send({'d1': temp, 'd2': humid})
    print('status code:', r.status_code)
    time.sleep(5)
Exemplo n.º 8
0
import urequests
import time
import si7021
from machine import I2C, Pin
from i2c_lcd8050 import I2cLcd
import si7021
        
while True:
    try:
        #Définition des pins des mesures
        DEFAULT_I2C_ADDR = 0x27
        i2C_c = machine.I2C(machine.Pin(2), machine.Pin(0))
        i2C_l = I2C(scl=Pin(2), sda=Pin(0))
        s = si7021.SI7021(i2C_c)
        lcd = I2cLcd(i2C_l, DEFAULT_I2C_ADDR, 2, 16)

        #Définitions des variables de température de d'humidité
        xtemp = round(s.temperature(),1)
        xhumidite = round(s.humidity(),1)
            
        #Mise a jour de l'écran
        lcd.clear()
        lcd.putstr("Temp : " + str(xtemp) + " C \nHumidite : "  + str(xhumidite) + "%")
        #Post des donnéees
        xURL=("http://192.168.137.24:5000/API/ESP/ADD_DATA/{}/{}".format(xtemp,xhumidite))
        r = urequests.post(xURL)
        print(r)
                
        time.sleep(300) #300 = 5 minutes
        
    except:
Exemplo n.º 9
0
def th_sensor_setup(_scl, _sda):
    print("Temperature/Humidity Sensor Setup")
    i2c = I2C(-1, scl=Pin(_scl), sda=Pin(_sda))
    s = si7021.SI7021(i2c)
    return s
Exemplo n.º 10
0
    if not wlan.isconnected():
        print('connexion au réseau...')
        wlan.connect('MI 9', 'chounette')
        #wlan.connect('Julien-IOT', '')
        while not wlan.isconnected():
            pass
    print('Connecté à l\'internet')


connectToInternet()

import si7021
from machine import I2C, Pin

i2c = I2C(-1, Pin(2), Pin(0))
s = si7021.SI7021(i2c)

temp_avg = []
hum_avg = []

while True:
    from time import sleep_ms, ticks_ms

    #Récupération des données depuis la sonde
    temp = s.temperature()
    humidity = s.humidity()

    data = {'temperature': temp, 'humidity': humidity}

    #Moyenne des 5 derniers relevé
    temp_avg = []
Exemplo n.º 11
0
from machine import I2C
from machine import Pin
import time
import si7021

i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
sensor = si7021.SI7021(i2c)
time.sleep_ms(500)

while True:
    print("Temperature: ", sensor.temperature())
    print("Humidity: ", sensor.humidity())
    time.sleep_ms(20)
Exemplo n.º 12
0
def th_sensor_setup(_scl, _sda, _freq):
    print("Temperature/Humidity Sensor Setup")
    i2c = I2C(scl=Pin(_scl), sda=Pin(_sda), freq=_freq)
    s = si7021.SI7021(i2c)
    time.sleep_ms(500)
    return s