import time
import utime
from lib.pysense import Pysense
from lib.LTR329ALS01 import LTR329ALS01
from lib.LIS2HH12 import LIS2HH12
from lib.SI7006A20 import SI7006A20
from lib.LTR329ALS01 import LTR329ALS01
from lib.MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE
from machine import Timer
#import Exersices.logger

py = Pysense()
mp = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals
mpp = MPL3115A2(py,mode=PRESSURE)
si = SI7006A20(py)
lt = LTR329ALS01(py)
li = LIS2HH12(py)
# https://github.com/pycom/pycom-libraries/blob/master/pysense/main.py

led_on = True
LED_DEFAULT = 0xFFFFFF

chrono = Timer.Chrono()
chrono.start()

pycom.heartbeat(False)

def freeze(sec = 0):
    time.sleep(sec)
    
file = open('data.txt', 'w')
示例#2
0
 def __init__(self):
     self.lt = LTR329ALS01()
示例#3
0
文件: main.py 项目: apdofficial/Lopy
pycom.rgbled(0x000000)
 
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
 
# set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
 
# make the socket non-blocking
s.setblocking(False)
 
# create a raw LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
s.setblocking(True)
 
# init the libraries
lib_1 = LTR329ALS01()
lib_2 = SI7006A20()
lib_3 = MPL3115A2() 
while True:
    # Read data from the libraries and place into payload
    # payload is returning following
    # Temperature(degrees Celsius), Luminosity(Lux), Humidity(%), Pressure (Pascal)
    
    payload2 = "%.0f %3.0f %3.0f %.0f" % (int(lib_2.temperature()), int(lib_1.light()[0]), int(lib_2.humidity()), int(lib_3.pressure()))
    payload= (struct.pack("<h",int(lib_2.temperature()*1))+struct.pack("<h",int(lib_1.light()[0]*1))+struct.pack("<h", int(lib_2.humidity()*1))+struct.pack("<h",int(lib_3.pressure())))

    #printing data to terminal
    print("Sending data -> %s" % payload)
    print("Temperature(degrees Celsius), Luminosity(Lux), Humidity(%), Pressure (Pascal)")
    print("Printing data -> %s" % payload2, "\n")
    # send the data over LPWAN network
示例#4
0
time.sleep(0.1)
pycom.rgbled(0x0000ff)
time.sleep(0.5)
pycom.rgbled(0x000000)

# Create a raw LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
# Set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)
# Make the socket non-blocking
s.setblocking(False)

# Init the libraries
pysense = Pysense()
mpl3115a2 = MPL3115A2()  # Barometric Pressure Sensor with Altimeter
ltr329als01 = LTR329ALS01()  # Digital Ambient Light Sensor
si7006a20 = SI7006A20()  # Humidity and Temperature sensor
lis2hh12 = LIS2HH12()  # 3-Axis Accelerometer

while True:

    # Read the values from the sensors
    voltage = pysense.read_battery_voltage()
    temperature = mpl3115a2.temperature()
    pressure = mpl3115a2.pressure()
    light = ltr329als01.light()[0]
    humidity = si7006a20.humidity()
    roll = lis2hh12.roll()
    pitch = lis2hh12.pitch()

    # Debug sensor values