Sharing code is how we learn, but we don’t want to share too much. In this how-to, we learn where to safely store our account credentials, and how to work with them.
Getting your Raspberry Pi project online is now cheaper and easier thanks to the Raspberry Pi Pico W. It only takes five lines of code to connect your Raspberry Pi Pico W to the world, but sharing your code can leave you open to a few security concerns.
Your MicroPython code now contains your Wi-Fi password, API keys and bespoke URLs. So how do we mitigate the risk while keeping our data portable?
Creating a MicroPython module is the best way to keep your secrets out of your project code. We can import the module just like any other module, and reference its contents in the same manner.
In this how-to, we will create a secrets module and use it, along with Open Weather to get the current weather details for our home location. The project code can be easily shared with others, without fear of including any personal information.