• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

what code should go in to boot.py vs main.py

Q&A Forum › what code should go in to boot.py vs main.py
0 Vote Up Vote Down
chin3789 asked 6 years ago
2 Answers
0 Vote Up Vote Down
chin3789 answered 6 years ago

what type code should be programmed into boot.py and main.py in micropython programming ? Can we keep all the code in a single file boot.py ?

0 Vote Up Vote Down
Sara Santos Staff answered 6 years ago

Hi, ideally this is what should go in each file accordingly to Adafruit:

“boot.py – This file is run first on power up/reset and should contain low-level code that sets up the board to finish booting. (…)
main.py – If this file exists it’s run after boot.py and should contain any main script that you want to run when the board is powered up or reset.”

So, I don’t think it is recommended to include your main script on the boot.py file, specially if it contains loops. However, if you don’t need to change any of the default configurations on the boot.py file (they are all commented by default), you should be able to run all your code in main.py.

I hope this is clear.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.