Пример #1
0
def get_sdata(lite_s):

    v = raw2Lux(lite_s.light())
    print("Light (raw2lux): " + str(v))
    
    return int(v)
Пример #2
0
# See https://docs.pycom.io for more information regarding library specifics

from pysense import Pysense
from LIS2HH12 import LIS2HH12           # 3-Axis Accelerometer
from SI7006A20 import SI7006A20         # Humidity and Temperature Sensor
from LTR329ALS01 import LTR329ALS01     # Digital Ambient Light Sensor
from raw2lux import raw2Lux             # ... additional library for the light sensor
from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE  # Barometric Pressure Sensor with Altimeter 

py = Pysense()

# Digital Ambient Light Sensor
lite_s = LTR329ALS01(py)
print("Light raw (channel Blue lux, channel Red lux): " + str(lite_s.light()))
print("Light (raw2lux): " + str(raw2Lux(lite_s.light())))


# Barometric Pressure Sensor with Altimeter
bara_s = MPL3115A2(py,mode=ALTITUDE) # Returns height in meters.
barp_s = MPL3115A2(py,mode=PRESSURE) # Returns pressure in Pascals.
print("MPL3115A2 temperature: " + str(bara_s.temperature()))
print("Altitude: " + str(bara_s.altitude()))
print("Pressure: " + str(barp_s.pressure()))

# Humidity and Temperature Sensor
temp_s = SI7006A20(py)
print("Temperature: " + str(temp_s.temperature())+ " deg C and Relative Humidity: " + str(temp_s.humidity()) + " %RH")
print("Dew point: "+ str(temp_s.dew_point()) + " deg C")

# 3-Axis Accelerometer
acel_s = LIS2HH12(py)
Пример #3
0
flash_led_to(YELLOW)
# joining TTN
join_lora(True)

py = Pysense()
tempHum = SI7006A20(py)
ambientLight = LTR329ALS01(py) 

while True:
    # create a LoRa socket
    s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
    s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0)
    s.setblocking(True)

    temperature = tempHum.temp()
    humidity = tempHum.humidity()
    luxval = raw2Lux(ambientLight.lux())

    print("Read sensors: temp. {} hum. {} lux: {}".format(temperature, humidity, luxval))

    # Packing sensor data as byte sequence using 'struct'
    # Data is represented as 3 float values, each of 4 bytes, byte orde 'big-endian'
    # for more infos: https://docs.python.org/3.6/library/struct.html
    payload = struct.pack(">fff", temperature, humidity, luxval)

    s.send(payload)
    flash_led_to(GREEN)

    time.sleep(15)
Пример #4
0
def get_light():
	return raw2Lux(ambientLight.lux())