Merge branch 'wifi' into 'master'
Wifi See merge request arofarn/micropy-light!2
This commit is contained in:
commit
32ebdd4d30
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
code/wifi_config.py
|
25
code/boot.py
25
code/boot.py
@ -1,7 +1,32 @@
|
|||||||
# This file is executed on every boot (including wake-boot from deepsleep)
|
# This file is executed on every boot (including wake-boot from deepsleep)
|
||||||
#import esp
|
#import esp
|
||||||
#esp.osdebug(None)
|
#esp.osdebug(None)
|
||||||
|
|
||||||
import gc
|
import gc
|
||||||
|
import time
|
||||||
|
import network
|
||||||
import webrepl
|
import webrepl
|
||||||
|
from wifi_config import known_wifi_ap
|
||||||
|
|
||||||
|
# Connect to one of the known wifi AP
|
||||||
|
interface = network.WLAN(network.STA_IF)
|
||||||
|
interface.active(True)
|
||||||
|
wifi_ap_list = interface.scan()
|
||||||
|
|
||||||
|
for ap in wifi_ap_list:
|
||||||
|
if interface.isconnected():
|
||||||
|
break
|
||||||
|
|
||||||
|
ap_ssid = ap[0].decode("utf-8")
|
||||||
|
if ap_ssid in known_wifi_ap.keys():
|
||||||
|
print("Known wifi network found : {}".format(ap_ssid))
|
||||||
|
print("Try to connect...")
|
||||||
|
interface.connect(ap_ssid, known_wifi_ap[ap_ssid])
|
||||||
|
|
||||||
|
# Wait for wifi
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
webrepl.start()
|
webrepl.start()
|
||||||
|
|
||||||
|
print("Boot.py : Done")
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
@ -23,6 +23,7 @@ __version__ = 0.2
|
|||||||
import time
|
import time
|
||||||
import machine
|
import machine
|
||||||
import neopixel
|
import neopixel
|
||||||
|
|
||||||
from uos import uname
|
from uos import uname
|
||||||
from encoder import Encoder
|
from encoder import Encoder
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ ENCODER = Encoder(ENC_PIN_B, ENC_PIN_A,
|
|||||||
ENC_BUT = machine.Pin(ENC_PIN_C, machine.Pin.IN)
|
ENC_BUT = machine.Pin(ENC_PIN_C, machine.Pin.IN)
|
||||||
|
|
||||||
#Variables d'état
|
#Variables d'état
|
||||||
BRIGHTN = 0 # Luminosité (0 - 100)
|
BRIGHTN = 50 # Luminosité (0 - 100)
|
||||||
PWR = False # Est-ce que l'éclairage est allumé ?
|
PWR = False # Est-ce que l'éclairage est allumé ?
|
||||||
BUTTN_STATE = 1
|
BUTTN_STATE = 1
|
||||||
|
|
||||||
|
6
code/wifi_config_template.py
Normal file
6
code/wifi_config_template.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Just a dic with each known wifi access point's SSID and WPA key
|
||||||
|
# Update it with your own setting and rename it "wifi_config.py"
|
||||||
|
|
||||||
|
known_wifi_ap = {"wifi_ssid": "wifi_wpa_key",
|
||||||
|
"wifi_ssid_2": "wifi_wpa_key_2",
|
||||||
|
}
|
10
pymakr_wifi.conf
Normal file
10
pymakr_wifi.conf
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"address": "192.168.1.20",
|
||||||
|
"username": "",
|
||||||
|
"password": "frE3d0M4",
|
||||||
|
"sync_folder": "code",
|
||||||
|
"sync_file_types": "py,txt,log,json,xml,html,js,css,mpy,pem,cet,crt,key",
|
||||||
|
"sync_all_file_types": true,
|
||||||
|
"open_on_start": true,
|
||||||
|
"safe_boot_on_upload": false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user