Post
by Roberthh » Thu Jul 18, 2019 7:06 pm
Looking at you main.py and boot.py, it it quite a bit of code. Of the things I find surprising:
- the functions wifi_connect() is defined in boot.py, but called in main.py
- you import MQTT lib in boot.py and define client there, but call client.connect in main.py
- same with onewire, ds1820, main_running_led, and so on.
I would never do that, because it is not that boot.py imports main.py. They just happen to run in the same name space. If you import main.py (or my_module.py) from boot.py, the relation is more obvious, and things are guaranteed to work. That still does not explain why it works at Ctrl-D, and not on power on.
Also: You tell that main.py is running by the blinking LED in the main loop of main.py. But until then a lot could have failed. For the test like yours, I would add a LED loop at the very beginning of main.py, including the redefinition of the Pin object. Thus you can be sure that all you need for the test is locally present.
P.S.: The roles of boot.py and main.py are not clearly distinct. You can leave boot.py (almost) empty and put everything in main.py, or, like @pythoncoder suggested, let main.py only import your service code.