示例#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()
示例#2
0
def showTempBMP(tm):
    i2c = machine.I2C(sda=machine.Pin(Wemos.D2), scl=machine.Pin(Wemos.D1))
    bmp = bmp180.BMP180(i2c)
    tempBMP = bmp.temperature
    tm.write_int(0x0100000000000000)
    number_helper.show2FiguresNumberX3(tm, tempBMP)
    return tempBMP
示例#3
0
def setup():

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

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

    global pwm2
    pwm2 = PWM(Pin(2), freq=2, duty=512)
示例#4
0
def pre_sensor_setup(_scl, _sda, _freq):
    print("Pressure Sensor Setup")
    i2c = I2C(scl=Pin(_scl), sda=Pin(_sda), freq=_freq)
    s = bmp180.BMP180(i2c)
    s.oversample_sett = 2
    return s
示例#5
0
from machine import I2C
from machine import Pin
import time
import bmp180

i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
sensor = bmp180.BMP180(i2c)
sensor.oversample_sett = 2  #accuracy; 0-3, lower better, but slower

time.sleep_ms(500)

while True:
    print(sensor.pressure
          )  #apparently gives same value if <10s interval between calls
    time.sleep_ms(20)
示例#6
0
'''
    BMP180 demo

    Author: shaoziyang
    Date:   2018.2

    http://www.micropython.org.cn

'''
from machine import I2C
import time

import bmp180

b = bmp180.BMP180(I2C(1))

while True:
    time.sleep_ms(500)
    b.get()
示例#7
0
'''
    BMP180 demo

    Author: shaoziyang
    Date:   2018.2

    http://www.micropython.org.cn

'''
from microbit import *

import bmp180

b = bmp180.BMP180()

while True:
    sleep(500)
    b.get()
示例#8
0
import ds18x20
ds = ds18x20.DS18X20(onewire.OneWire(machine.Pin(Wemos.D2)))
roms = ds.scan()
print(roms)
ds.read_temp(roms[0]) 




```python
from machine import Pin, I2C
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
i2c.scan()

# subimos el fichero bmp180.py
 
```python
import bmp180 
bmp = bmp180. 
__class____name__I2C Pin
mathtimeunp BMP180
bmp = bmp180.BMP180(i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module> 
File "bmp180.py", line 48, in __init__
OSError: [Errno 19] ENODEV
bmp = bmp180.BMP180(i2c)
bmp.temperature
26.2409
bmp.pressure
            rc = mqttpub.reconnect()
            if rc != 0:
                rc = mqttpub.connect(broker, port, 60)
            if rc != 0:
                raise Exception('connectionError')
        except:
            tries -= 1
            mqttpub.disconnect()
            if tries == 0:
                raise Exception('connectionException')

    mqttpub.publish(topic, payload)


time4 = ''
BMPsensor = bmp180.BMP180()

sensorData = sql.connect('/srv/bmp180/sensordata.db')
sensorData.execute("PRAGMA journal_mode=WAL")
sensorData.execute("VACUUM")
bmp_data = sensorData.cursor()

def tick():

    while True:
        global time4
        press = BMPsensor.get_pressure()
        temp = BMPsensor.get_temperature()
        time1 = time.strftime('%M')
        if int(time1) % 3 == 0:
            time2 = time.strftime('%H:%M:%S')
示例#10
0
#!/usr/bin/python

import time
import smbus
import bmp180
import sqlite3 as sql

time4 = ''

bus = smbus.SMBus(1)
sensor = bmp180.BMP180(bus)
sensor.os_mode = 3

sensorData = sql.connect('/home/pi_f/python/sensordata.db')
sensorData.execute("PRAGMA journal_mode=WAL")
sensorData.execute("VACUUM")
bmp_data = sensorData.cursor()


def tick():

    while True:
        global time4
        press, temp = sensor.pressure_and_temperature()
        time1 = time.strftime('%M')
        if int(time1) % 3 == 0:
            time2 = time.strftime('%H:%M:%S')
            time3 = time.strftime('%S')
            if time3 == '00':  # exactly on the minute
                if time2 != time4:
                    time4 = time2  # Make sure we only run once