Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


for connection in connections:
station, password = connection.split()
station, password = connection.split("_")

print("Connecting to {}.".format(station))

Expand All @@ -30,7 +30,7 @@
if sta_if.isconnected():
break

time.sleep(1)
time.sleep(1)

if sta_if.isconnected():
break
Expand Down
20 changes: 20 additions & 0 deletions boot_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import time

try:
with open("passwords.txt") as f:
connections = f.readlines()
except OSError:
print("No passwords.txt file!")
connections = []


for connection in connections:
station, password = connection.split("_")

print("Connecting to {}.".format(station))
print("password to {}.".format(password))

for i in range(15):
print(".")

time.sleep(1)
3 changes: 1 addition & 2 deletions passwords.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
EarlGreyTea HotHotHot
MyHomeAccessPoint aueiUeh73NB
wifiname_password
30 changes: 29 additions & 1 deletion web_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from machine import RTC
from time import sleep


try:
seconds = ntptime.time()
except:
Expand All @@ -47,11 +48,38 @@ def dummy():

return response_template % body

pin = machine.Pin(10, machine.Pin.IN)
def light_on():
pin_out.value(1)
body = "You turned a light on!"
return response_template % body

def light_off():
pin_out.value(0)
body = "You turned a light off!"
return response_template % body


def switch():
body = "{state: %s}" % str(switch_pin.value())
return response_template % body


def light():
body = "{value: %s}" % str(adc.read())
return response_template % body


switch_pin = machine.Pin(10, machine.Pin.IN)
pin_out = machine.Pin(9, machine.Pin.OUT)
adc = machine.ADC(0)

handlers = {
'time': time,
'dummy': dummy,
'light_on': light_on,
'light_off': light_off,
'switch': switch,
'light': light,
}

def main():
Expand Down