I'm a later beginner with ESP32-S3 - so bought a package ESP32-S3 Wroom Freenove.
Which I'm planning to learn to program python, and have som fun while, I've bought the Millinium Falcon in Lego, and want to do some thing like light in cockpitt - canons firing - Flying with light in the back etc as a little hoppy
I want it logon to my network, check the clock, and if myhourly number is between 9 & 20 I want it to run a sequence.
So how can I get a boolean to change it value by all - and sorry for my programming (could possibly be done more nice or original, but I just want to have fun with my Lego
I'm ended up with the forllowing as Code for a little start:
Code: Select all
import time
import network
ssidRouter = 'XXX'
passwordRouter = 'Not_D3clared'
millinium = bool()
# our connectiown method
#######################
def STA_Setup(ssidRouter,passwordRouter):
print("Setup start")
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('connecting to',ssidRouter)
sta_if.active(True)
sta_if.connect(ssidRouter,passwordRouter)
while not sta_if.isconnected():
pass
print('Connected, IP address:', sta_if.ifconfig())
current_time = time.localtime()
hour = current_time[3]
print('local timehour is : ', hour)
if ( hour >= 9 ):
print('Clock above 9')
if ( hour <= 20 ):
print('And below 20')
millinium = True
else:
print('And above 20')
millinium = False
else:
print('And below 9')
millinium = False
try:
STA_Setup(ssidRouter,passwordRouter)
print('Started out connecting')
print('Millinium Statement is : ', millinium)
while millinium:
print('Execution of script')
except:
sta_if.disconnect()
# EOF
Code: Select all
>>> %Run -c $EDITOR_CONTENT
MPY: soft reboot
Setup start
Connected, IP address: ('192.168.0.125', '255.255.255.0', '192.168.0.1', '192.168.0.1')
local timehour is : 18
Clock above 9
And below 20
Started out connecting
Millinium Statement is : False
>>>
Thanks in Advance for any input to this question?
U
