Exemplo n.º 1
0
def main():
    pycom.heartbeat(False)
    enable_gc()
    Pycoproc(Pycoproc.PYTRACK)

    if ENABLE_WIFI:
        wlan = WLAN(mode=WLAN.STA)
        connect_wlan(wlan=wlan)

    lora, sckt = init_lora()
    rtc = machine.RTC()
    setup_rtc(rtc=rtc)

    while True:
        payload = sckt.recv(64)
        print("Raw payload: {}".format(payload))
        data = parse_payload(payload=payload)

        if data:
            print("Received: {}".format(data))
            map_to_rgbled(data["roll"], vmax=180)

            if ENABLE_WIFI:
                post_roll(data["roll"])

        time.sleep(0.05)
Exemplo n.º 2
0
def main():
    pycom.heartbeat(False)
    enable_gc()
    pycoproc = Pycoproc(Pycoproc.PYTRACK)
    acc = LIS2HH12()
    lora, sckt = init_lora()
    rtc = machine.RTC()
    setup_rtc(rtc=rtc)

    while True:
        log_acc(acc=acc)
        payload = "{},{}".format(acc.roll(), acc.pitch())
        print("Sending: {}".format(payload))
        sckt.send(payload)
        pycom.rgbled(0x0000FF)
        time.sleep(0.5)
        pycom.rgbled(0x000000)
        time.sleep(0.5)
Exemplo n.º 3
0
from LIS2HH12 import LIS2HH12
# setup as a station

import gc

time.sleep(2)
gc.enable()

# setup rtc
rtc = machine.RTC()
rtc.ntp_sync("pool.ntp.org")
utime.sleep_ms(750)
print('\nRTC Set from NTP to UTC:', rtc.now())
utime.timezone(7200)
print('Adjusted from UTC to EST timezone', utime.localtime(), '\n')
py = Pycoproc(Pycoproc.PYTRACK)
l76 = L76GNSS(py, timeout=30)
chrono = Timer.Chrono()
chrono.start()
li = LIS2HH12(py)
#sd = SD()
#os.mount(sd, '/sd')
#f = open('/sd/gps-record.txt', 'w')
while (pybytes):
    coord = l76.coordinates()
    #f.write("{} - {}\n".format(coord, rtc.now()))
    print('Sending data', coord)
    pybytes.send_signal(1, coord)
    pybytes.send_signal(2, li.acceleration())
    time.sleep(10)
Exemplo n.º 4
0
    b = cfg('pybytes_on_boot')
    print('fix pybytes_on_boot config ({}) and reboot'.format(b))
    pycom.pybytes_on_boot(b)
    time.sleep(1)
    machine.reset()

board_ver = cfg('v')
board = cfg('b')
py = None
if board == 'Pygate':
    board_ver_str = ''
else:
    if board_ver == 1:
        from pycoproc_1 import Pycoproc
        if board == 'Pytrack':
            py = Pycoproc(Pycoproc.PYTRACK)
        elif board == 'Pysense':
            py = Pycoproc(Pycoproc.PYSENSE)
        else:
            raise Exception('Unknown board type', b)
    elif board_ver == 2:
        from pycoproc_2 import Pycoproc
        py = Pycoproc()
        pid = py.read_product_id()
        if pid == Pycoproc.USB_PID_PYTRACK:
            board = 'Pytrack'
        elif pid == Pycoproc.USB_PID_PYSENSE:
            board = 'Pysense'
        else:
            raise Exception('PID not supported', pid)
    else:
Exemplo n.º 5
0
This example continuously sends a REQA for ISO14443A card type
If a card is discovered, it will read the UID
If DECODE_CARD = True, will attempt to authenticate with CARDkey
If authentication succeeds will attempt to read sectors from the card
'''

from pycoproc_1 import Pycoproc
from MFRC630 import MFRC630
import time
import pycom

# This is the default key for an unencrypted MiFare card
CARDkey = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
DECODE_CARD = False

py = Pycoproc(Pycoproc.PYSCAN)
nfc = MFRC630(py)

RGB_BRIGHTNESS = 0x8

RGB_RED = (RGB_BRIGHTNESS << 16)
RGB_GREEN = (RGB_BRIGHTNESS << 8)
RGB_BLUE = (RGB_BRIGHTNESS)

counter = 0

# Make sure heartbeat is disabled before setting RGB LED
pycom.heartbeat(False)

# Initialise the MFRC630 with some settings
nfc.mfrc630_cmd_init()
Exemplo n.º 6
0
import time
import pycom
import machine
from machine import Pin

from LIS2HH12 import LIS2HH12
from SI7006A20 import SI7006A20
from LTR329ALS01 import LTR329ALS01
from MPL3115A2 import MPL3115A2, ALTITUDE, PRESSURE
from pycoproc_1 import Pycoproc

py = Pycoproc(Pycoproc.PYSENSE)  # Expansion board object
#pres = MPL3115A2(py, mode=PRESSURE) # Returns pressure in Pa. Mode may also be set to ALTITUDE, returning a value in meters
dht = SI7006A20(py)  # Temperature, Relative humidity and dew point
li = LTR329ALS01(py)  # Light

pycom.heartbeat(False)  # Turn off flashing
pycom.rgbled(0x00)  # Off

Wake_Input = Pin('P10', mode=Pin.IN,
                 pull=Pin.PULL_UP)  # Wake inpt from MAX20361

# Solar State Machine
while True:
    if not Wake_Input():  # active low from logic clamp
        print("Wake")

        Cab_T = dht.temperature()  # Deg C
        Cab_H = dht.humidity()  # % Relative Humidity
        Cab_L = li.light()[1]  # Red Light Lux
Exemplo n.º 7
0
# See https://docs.pycom.io for more information regarding library specifics

import time
import pycom
from pycoproc_1 import Pycoproc
import machine

from LIS2HH12 import LIS2HH12
from SI7006A20 import SI7006A20
from LTR329ALS01 import LTR329ALS01
from MPL3115A2 import MPL3115A2, ALTITUDE, PRESSURE

pycom.heartbeat(False)
pycom.rgbled(0x0A0A08)  # white

py = Pycoproc(Pycoproc.PYSENSE)

mp = MPL3115A2(
    py, mode=ALTITUDE
)  # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals
print("MPL3115A2 temperature: " + str(mp.temperature()))
print("Altitude: " + str(mp.altitude()))
mpp = MPL3115A2(
    py, mode=PRESSURE
)  # Returns pressure in Pa. Mode may also be set to ALTITUDE, returning a value in meters
print("Pressure: " + str(mpp.pressure()))

si = SI7006A20(py)
print("Temperature: " + str(si.temperature()) +
      " deg C and Relative Humidity: " + str(si.humidity()) + " %RH")
print("Dew point: " + str(si.dew_point()) + " deg C")
Exemplo n.º 8
0

# Timer
import time

# SD Card
import os
from machine import SD

# GPS
from L76GNSS import L76GNSS
from pycoproc_1 import Pycoproc


# GPS Constructor
GPS = L76GNSS(Pycoproc(Pycoproc.PYTRACK), timeout=30)

# Mount SD Card
sd = SD()
os.mount(sd, '/sd')

FileNo = 0
FileName = ''
while True: # Find a unique file name on the SD card
    try:
        FileName = '/sd/' + str(FileNo) + '.csv' # Path, file name and extension.
        FileNo = FileNo + 1 # Increment through file numbers
        open(FileName, 'r') # Test to see if file exists, if not then break out of loop
    except:
        break
Exemplo n.º 9
0
'''

DEBUG = False  # change to True to see debug messages

from pycoproc_1 import Pycoproc
from MFRC630 import MFRC630
from LIS2HH12 import LIS2HH12
from LTR329ALS01 import LTR329ALS01
import binascii
import time
import pycom
import _thread

VALID_CARDS = [[0x43, 0x95, 0xDD, 0xF8], [0x43, 0x95, 0xDD, 0xF9]]

py = Pycoproc(Pycoproc.PYSENSE)
nfc = MFRC630(py)
lt = LTR329ALS01(py)
li = LIS2HH12(py)

RGB_BRIGHTNESS = 0x8

RGB_RED = (RGB_BRIGHTNESS << 16)
RGB_GREEN = (RGB_BRIGHTNESS << 8)
RGB_BLUE = (RGB_BRIGHTNESS)

# Make sure heartbeat is disabled before setting RGB LED
pycom.heartbeat(False)

# Initialise the MFRC630 with some settings
nfc.mfrc630_cmd_init()