How to include a module

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Posts: 10
Joined: Mon Mar 16, 2020 11:09 am

Re: How to include a module

Post by john7 » Tue Mar 17, 2020 9:11 am

OlivierLenoir wrote:
Tue Mar 17, 2020 8:46 am
john7 wrote:
Tue Mar 17, 2020 5:57 am
the code is working if I put it in The problem to import from another file.
  1. Create file on your computer with the here bellow code
  2. Connect to your board rshell -p /dev/ttyUSB0
  3. Use rshell to copy on your board cp /pyboard/
  4. From rshell start repl
  5. You can now import your module from wifi import WIFI
  6. ...
I see. Thank you. So the file has to be located on the board. Too bad, it's hard to debug complicated applications. For now I'll stuff all my code in

Posts: 429
Joined: Thu Apr 24, 2014 9:13 am

Re: How to include a module

Post by stijn » Tue Mar 17, 2020 3:14 pm

Even though that works, I'd advice against it. Not just for the sake of doing 'the right thing' but mainly because it'll force you to learn Python and debugging techniques etc. It's lik the difference between trying random things until it works (not much learned), and investigating the problem followed by applying a fix of which you understand why it works.

Post Reply