main.py don't start after poweron
-
- Posts: 44
- Joined: Fri Sep 02, 2016 4:07 pm
- Location: Austria
main.py don't start after poweron
Hello!!!
I'm new here and I've already my first problem. I tried a lot of code snippets and everything is working like expected.
Now I tried create a main.py file, that should start after poweron of the board. ...but it is not working.
Could anybody give me a hint how to do that?
I'm using the development board "Witty Cloud" with the ESP-12F.
Thanks a lot...
I'm new here and I've already my first problem. I tried a lot of code snippets and everything is working like expected.
Now I tried create a main.py file, that should start after poweron of the board. ...but it is not working.
Could anybody give me a hint how to do that?
I'm using the development board "Witty Cloud" with the ESP-12F.
Thanks a lot...
Re: main.py don't start after poweron
How did you "create" the file? Perhaps you can walk us through what you have done so far and what output you get, that makes you think it's not working?
-
- Posts: 44
- Joined: Fri Sep 02, 2016 4:07 pm
- Location: Austria
Re: main.py don't start after poweron
Yes, of course...
At first I installed the firmware esp8266-20160901-v1.8.3-81-g9c04ef2.bin and then I create a new boot.py and main.py file with Vi.
here the content of "boot.py":
content of "main.py":
Now I flashed the latest firmware esp8266-20160905-v1.8.3-112-gb4df3e7.bin but main.py is still not running...
What could be the reason for that?
EDIT: It seems that main.py is loaded but main() not executed... Why?
At first I installed the firmware esp8266-20160901-v1.8.3-81-g9c04ef2.bin and then I create a new boot.py and main.py file with Vi.
here the content of "boot.py":
Code: Select all
import webrepl
print("boot.py loaded...")
webrepl.start()
Code: Select all
import esp
import machine
import time
def toggle(p):
p.value(not p.value())
def main():
pin = machine.Pin(2, machine.Pin.OUT)
for i in range(10):
toggle(pin)
time.sleep_ms(500)
if __name__ == 'main':
print("main entered")
esp.osdebug(0)
main()
What could be the reason for that?
EDIT: It seems that main.py is loaded but main() not executed... Why?
Last edited by lukesky333 on Mon Sep 05, 2016 9:36 am, edited 1 time in total.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: main.py don't start after poweron
I think one of the things @platforma was after was how you transferred the two files to the ESP8266. However if it's now working then you've evidently done this successfully
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 44
- Joined: Fri Sep 02, 2016 4:07 pm
- Location: Austria
Re: main.py don't start after poweron
For file transfer I'm using mpfshell.
The problem is, that main.py is loaded but main() not executed... Any idea why???
EDIT: OK, sorry for that stupid question/problem.
wrong:
correct:
The problem is, that main.py is loaded but main() not executed... Any idea why???
EDIT: OK, sorry for that stupid question/problem.
wrong:
Code: Select all
if __name__ == 'main':
Code: Select all
if __name__ == '__main__':
Re: main.py don't start after poweron
Just to ask a few simple questions:
Do you see the message printed "main entered", e.g. after reboot with Ctrl-D?
How do you tell that main() is not executed. Did you try a print statement inside main(), just to sort our any connection issue with the LED?
Do you see the message printed "main entered", e.g. after reboot with Ctrl-D?
How do you tell that main() is not executed. Did you try a print statement inside main(), just to sort our any connection issue with the LED?
-
- Posts: 44
- Joined: Fri Sep 02, 2016 4:07 pm
- Location: Austria
Re: main.py don't start after poweron
Yes, I see... After fixing the code everything is working like expected.Roberthh wrote:Do you see the message printed "main entered", e.g. after reboot with Ctrl-D?
Not yet, but the code is working now.Roberthh wrote:How do you tell that main() is not executed. Did you try a print statement inside main(), just to sort our any connection issue with the LED?
Thanks a lot for the help!!!
Re: main.py don't start after poweron
Easy mistake to get caught out on, glad you got it working!
Re: main.py don't start after poweron
Hi,
I'm new to ESP & Micropython, I wanted to run micropython code by including it in firmware .....I get following error on powering on NodeMCU.
"could not open file 'main.py' for reading"
I did following
1) Built esp sdk toolchain using documentaion available at
https://learn.adafruit.com/building-and ... d-firmware
2) Created main.py with following code at "/home/vagrant/micropython/esp8266/scripts" on ubuntu VM
3) compiled firmware & copied it to /vagrant folder
4) Flashed the firmware on NodeMCU using esptool.py
I'm not able to find out what went wrong....
import machine
pin = machine.Pin(5, machine.Pin.OUT)
import time
for i in range(100):
pin.value(1)
time.sleep(0.25)
pin.value(0)
time.sleep(0.25)
I'm new to ESP & Micropython, I wanted to run micropython code by including it in firmware .....I get following error on powering on NodeMCU.
"could not open file 'main.py' for reading"
I did following
1) Built esp sdk toolchain using documentaion available at
https://learn.adafruit.com/building-and ... d-firmware
2) Created main.py with following code at "/home/vagrant/micropython/esp8266/scripts" on ubuntu VM
3) compiled firmware & copied it to /vagrant folder
4) Flashed the firmware on NodeMCU using esptool.py
I'm not able to find out what went wrong....
import machine
pin = machine.Pin(5, machine.Pin.OUT)
import time
for i in range(100):
pin.value(1)
time.sleep(0.25)
pin.value(0)
time.sleep(0.25)
Re: main.py don't start after poweron
Two questions:
a) How much flash has your device? For a file system, at least 1 MByte is required. You can tell by exectuing from the command line
b) Try to erase the flash before loading micropython. Issue
a) How much flash has your device? For a file system, at least 1 MByte is required. You can tell by exectuing
Code: Select all
import port_diag
b) Try to erase the flash before loading micropython. Issue
Code: Select all
esptool.py erase_flash