Ejemplo n.º 1
0
#!/usr/bin/env python
#
# Copyright (c) 2019, Pycom Limited.
#
# This software is licensed under the GNU GPL version 3 or any
# later version, with permitted additional terms. For more information
# see the Pycom Licence v1.0 document supplied with this file, or
# available at https://www.pycom.io/opensource/licensing
#

from machine import UART
import machine
import pycom
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

# Read in from NV RAM for the next state
key = pycom.nvs_get('test')
print(key)
if key == 0:
    machine.main('initial_state.py')
elif key == 1:
    machine.main('trigger_pong_example.py')
else:
    machine.main('sleep_wait.py')
Ejemplo n.º 2
0
from machine import UART
import machine
import os
uart = UART(0, baudrate=115200)
os.dupterm(uart)

machine.main('Ping')
#machine.main("Final_test.py")
Ejemplo n.º 3
0
from machine import UART
import machine
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

machine.main('GPS.py')
Ejemplo n.º 4
0
from machine import UART
import machine
import os
from network import WLAN

uart = UART(0, baudrate=115200)
os.dupterm(uart)

wifi_ssid = 'YOURWIFISSID'
wifi_pass = '******'

if machine.reset_cause() != machine.SOFT_RESET:
        
    wlan = WLAN(mode=WLAN.STA)
    
    wlan.connect(wifi_ssid, auth=(WLAN.WPA2, wifi_pass), timeout=5000)

    while not wlan.isconnected(): 
         machine.idle()


machine.main('main.py')
Ejemplo n.º 5
0
from machine import UART
import machine
from network import WLAN
import os
import ujson

# Set up USB UART
uart = UART(0, baudrate=115200)
os.dupterm(uart)

with open("secret.json", "r") as f:
    secrets = ujson.load(f)

# Set up LAN
wlan = WLAN()  # get current object, without changing the mode

if machine.reset_cause() != machine.SOFT_RESET:
    wlan.init(mode=WLAN.STA)
    # configuration below MUST match your home router settings!!
    wlan.ifconfig(config=('10.0.0.50', '255.255.255.0', '10.0.0.254',
                          '8.8.8.8'))

if not wlan.isconnected():
    # change the line below to match your network ssid, security and password
    wlan.connect(secrets["SSID"],
                 auth=(WLAN.WPA2, secrets["WIFIPassword"]),
                 timeout=5000)
    while not wlan.isconnected():
        machine.idle()  # save power while waiting
machine.main('control1.py')
Ejemplo n.º 6
0
from machine import UART
import machine
from network import WLAN
import os
import ujson

# Set up USB UART
uart = UART(0, baudrate=115200)
os.dupterm(uart)

with open("secret.json", "r") as f:
    secrets = ujson.load(f)

# Set up LAN
wlan = WLAN()  # get current object, without changing the mode

if machine.reset_cause() != machine.SOFT_RESET:
    wlan.init(mode=WLAN.STA)
    # configuration below MUST match your home router settings!!
    wlan.ifconfig(config=('10.0.0.50', '255.255.255.0', '10.0.0.254',
                          '8.8.8.8'))

if not wlan.isconnected():
    # change the line below to match your network ssid, security and password
    wlan.connect(secrets["SSID"],
                 auth=(WLAN.WPA2, secrets["WIFIPassword"]),
                 timeout=5000)
    while not wlan.isconnected():
        machine.idle()  # save power while waiting
machine.main('test7.py')
Ejemplo n.º 7
0
import machine
import os
from network import WLAN

mch = os.uname().machine
if not 'LaunchPad' in mch and not 'WiPy' in mch:
    raise Exception('Board not supported!')

wifi = WLAN()

print(machine)
machine.idle()
print(machine.freq() == (80000000, ))
print(machine.unique_id() == wifi.mac())

machine.main('main.py')

rand_nums = []
for i in range(0, 100):
    rand = machine.rng()
    if rand not in rand_nums:
        rand_nums.append(rand)
    else:
        print('RNG number repeated')
        break

for i in range(0, 10):
    machine.idle()

print("Active")
Ejemplo n.º 8
0
import machine
import os
from network import WLAN

mch = os.uname().machine
if not "LaunchPad" in mch and not "WiPy" in mch:
    raise Exception("Board not supported!")

wifi = WLAN()

print(machine)
machine.idle()
print(machine.freq() == (80000000, ))
print(machine.unique_id() == wifi.mac())

machine.main("main.py")

rand_nums = []
for i in range(0, 100):
    rand = machine.rng()
    if rand not in rand_nums:
        rand_nums.append(rand)
    else:
        print("RNG number repeated")
        break

for i in range(0, 10):
    machine.idle()

print("Active")
Ejemplo n.º 9
0
from machine import UART
from machine import Pin
import machine
import os
import time
uart = UART(0, baudrate=57600)
os.dupterm(uart)

bpin = Pin('GP14', mode=Pin.IN, pull=Pin.PULL_UP)
for i in range(10):
    time.sleep_ms(50)
    if bpin():
        break

if bpin():
    # run the demo if the second pushbutton is not pressed
    machine.main('iotdemo.py')
Ejemplo n.º 10
0
import machine

from network import WLAN

#ssid and password of wireless router to connect to
wifi_ssid = 'Hardiman 2.4GHz'
wifi_pass = '******'

if machine.reset_cause() != machine.SOFT_RESET:
    # use station (client mode)
    wlan = WLAN(mode=WLAN.STA)

    wlan.connect(wifi_ssid, auth=(WLAN.WPA2, wifi_pass), timeout=5000)

    while not wlan.isconnected():
        machine.idle()

print('Connected to wifi')
# display interface configuration
print(wlan.ifconfig())
machine.main('main.py')  # only needed in boot.py
Ejemplo n.º 11
0
        network_to_use = network_to_use[0]
        network_props = ConfigNetwork.KNOWN_NETWORKS[network_to_use]
        pwd = network_props['pwd']
        sec = [e.sec for e in available_networks
               if e.ssid == network_to_use][0]
        if 'config' in network_props:
            wl.ifconfig(config=network_props['config'])
        wl.connect(network_to_use, (sec, pwd), timeout=10000)
        while not wl.isconnected():
            machine.idle(
            )  # save power while waiting for connection to succeed
        print("Connected to " + network_to_use + " with IP address: " +
              wl.ifconfig()[0])

    except Exception as e:
        print("Failed to connect to any known network... Exception: {}".format(
            e))
        print("Going into AP mode")

        print("Setting with default ssid: {0} and default auth {1}".format(
            def_ssid, def_auth))
        wl.init(mode=WLAN.AP,
                ssid=def_ssid,
                auth=def_auth,
                channel=6,
                antenna=WLAN.INT_ANT,
                hidden=False)

#TODO For now going to tests module. Remove this
machine.main('tests.py')
Ejemplo n.º 12
0
from machine import UART
from machine import Pin
import machine
import os
import time

uart = UART(0, baudrate=57600)
os.dupterm(uart)

bpin = Pin('GP6', mode=Pin.IN, pull=Pin.PULL_UP)
for i in range(10):
    time.sleep_ms(50)
    if bpin():
        break

if bpin():
    # run the demo if the second pushbutton is not pressed
    machine.main('helix.py')
    pass
Ejemplo n.º 13
0
import machine
import os
from network import WLAN

mch = os.uname().machine
if not 'LaunchPad' in mch and not'WiPy' in mch:
    raise Exception('Board not supported!')

wifi = WLAN()

print(machine)
machine.idle()
print(machine.freq() == (80000000,))
print(machine.unique_id() == wifi.mac())

machine.main('main.py')

rand_nums = []
for i in range(0, 100):
    rand = machine.rng()
    if rand not in rand_nums:
        rand_nums.append(rand)
    else:
        print('RNG number repeated')
        break

for i in range(0, 10):
    machine.idle()

print("Active")
Ejemplo n.º 14
0
import machine
import os
from network import WLAN

mch = os.uname().machine
wifi = WLAN()

print(machine)
machine.idle()

if machine.freq() < 80000000 or machine.freq() > 240000000:
    print("CPU frequency out of range")

print(machine.unique_id() == wifi.mac()[0])

machine.main('main.py')

rand_nums = []
for i in range(0, 100):
    rand = machine.rng()
    if rand not in rand_nums:
        rand_nums.append(rand)
    else:
        print('RNG number repeated')
        break

for i in range(0, 10):
    machine.idle()

print("Active")
Ejemplo n.º 15
0
from machine import UART
import machine
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

machine.main('server_connection.py')
Ejemplo n.º 16
0
#!/usr/bin/env python
#
# Copyright (c) 2019, Pycom Limited.
#
# This software is licensed under the GNU GPL version 3 or any
# later version, with permitted additional terms. For more information
# see the Pycom Licence v1.0 document supplied with this file, or
# available at https://www.pycom.io/opensource/licensing
#

from machine import UART
import machine
import pycom
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

# Read in from NV RAM for the next state
key = pycom.nvs_get('test')
print(key)
if key == 0:
    machine.main('initial_state_SN1.py')
elif key == 1:
    machine.main('main_SN1.py')
else:
    machine.main('sleep_wait_SN1.py')
Ejemplo n.º 17
0
from machine import UART
import os
import machine
import ubinascii

uart = UART(0, 115200)
os.dupterm(uart)
#------------------------------------------------------------------------------#
#Imprime version del Firmware OS
print('Version OS:' + os.uname().release)
print("Machine CPU frequency: %dMHz" % (machine.freq() / 1000000))
print("Machine ID:%s" % ubinascii.hexlify(machine.unique_id()))
#------------------------------------------------------------------------------#
#Archivo Main para publicación de datos.
machine.main('otaa_node_acc_deepsleep.py')
#------------------------------------------------------------------------------#
Ejemplo n.º 18
0
import os
import machine
import pycom

uart = machine.UART(0, 115200)
os.dupterm(uart)

pycom.heartbeat(False)

machine.main('pms.py')
print('==========Starting main.py==========\n')
Ejemplo n.º 19
0
from machine import UART
import machine
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

machine.main('otaa_node.py')
Ejemplo n.º 20
0
import machine
if machine.Pin("G17", mode=machine.Pin.IN,
               pull=machine.Pin.PULL_UP).value() == 0:
    machine.main("noop.py")

import config
machine.WDT(timeout=config.WATCHDOG_TIMEOUT * 1000)

import pycom
pycom.heartbeat_on_boot(False)
pycom.heartbeat(False)
pycom.wifi_on_boot(False)

import network
network.WLAN().deinit()
network.Bluetooth().deinit()
network.Server().deinit()
Ejemplo n.º 21
0
from network import WLAN
import machine
import pycom
import time

pycom.heartbeat(False)
wlan = WLAN(mode=WLAN.STA)

access_points = wlan.scan()
for ap in access_points:
	if ap.ssid == '<ssid>':
		wlan.connect(ap.ssid, auth=(ap.sec, '<pass>'))
		while not wlan.isconnected():
			machine.idle() # save power while waiting

		# 5 second blue flash to show successful connection
		pycom.rgbled(0x0000FF)
		time.sleep(5)
		pycom.rgbled(0x000000)

		machine.main("main.py")
		break
Ejemplo n.º 22
0
# boot.py -- run on boot-up
from station.manager import init_station
import machine

print("Station is starting...")

init_station()  # Initiate the station

machine.main("main.py")  # Returning to the main
Ejemplo n.º 23
0
import machine
import pycom
import time
from network import WLAN
import urequests

# Configure second UART bus on pins P3(TX1) and P4(RX1)
uart1 = machine.UART(1, baudrate=9600)
uart1.init(baudrate=9600, bits=8, parity=None, stop=2)

machine.main('main.py')
print('==========SETUP==========\n')

wlan = WLAN(mode=WLAN.STA)

url = "http://0.0.0.0:5000/collect/"

nets = wlan.scan()
for net in nets:
    if net.ssid == 'ChristineLagarde':
        print('Network found!')
        wlan.connect(net.ssid, auth=(net.sec, 'pardonmyfrench'), timeout=5000)
        while not wlan.isconnected():
            machine.idle()  # save power while waiting
        print('WLAN connection succeeded!')
        break

data = []


def http_post():
Ejemplo n.º 24
0
from machine import UART
import machine
import os

uart = UART(0, baudrate=115200)
os.dupterm(uart)

# run the hackster demo
machine.main('hackster.py')