main.py doesn't run when connected to webrepl?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
UmbraAtrox
Posts: 4
Joined: Mon Jan 18, 2021 11:12 am

main.py doesn't run when connected to webrepl?

Post by UmbraAtrox » Tue Jan 19, 2021 2:44 am

This is my boot.py

Code: Select all

# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import uos, machine
import gc
import webrepl
webrepl.start()

btn = machine.Pin(5, machine.Pin.IN)
print('\n' +'\n')
if btn(): #short pin 5 (D1) to 3v3 for NORMAL BOOT
    print("Oh boy, i am running great today")
    print("Disabling REPL on UART0 (USB) so use WEBREPL or connect GPIO5 (D1) to GND for failsafe" + '\n')
    #uos.dupterm(None, 1) # disable REPL on UART(0)
else: #short pin 5 (D1) to gnd for FAILSAFE
    print("FAILSAFE")
    print("you shouldn't be here connect GPIO5 (D1) to 3V3 for Normal Mode" + '\n')



import myLib
myLib.connect_Wifi()
gc.collect()

this is my main.py

Code: Select all

import machine
print("do i run?")
mainbtn = machine.Pin(4, machine.Pin.IN)
so how i understood it on boot first boot.py runs and then main.py runs

When connected to USB:

Code: Select all

>>> btn
Pin(5)
>>> mainbtn
Pin(4)
When connected to Webrepl:

Code: Select all

>>> btn
Pin(5)
>>> mainbtn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'mainbtn' isn't defined
So somehow main.py doesn't run when connected to webrepl. which obvious thing did i miss? i feel pretty dumb right now.

Post Reply