#!/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')
from machine import UART import machine import os uart = UART(0, baudrate=115200) os.dupterm(uart) machine.main('Ping') #machine.main("Final_test.py")
from machine import UART import machine import os uart = UART(0, baudrate=115200) os.dupterm(uart) machine.main('GPS.py')
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')
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')
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')
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")
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")
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')
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
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')
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
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")
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")
from machine import UART import machine import os uart = UART(0, baudrate=115200) os.dupterm(uart) machine.main('server_connection.py')
#!/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')
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') #------------------------------------------------------------------------------#
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')
from machine import UART import machine import os uart = UART(0, baudrate=115200) os.dupterm(uart) machine.main('otaa_node.py')
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()
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
# 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
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():
from machine import UART import machine import os uart = UART(0, baudrate=115200) os.dupterm(uart) # run the hackster demo machine.main('hackster.py')