Storing Mission Critical Data in Flash Memory on the Raspberry Pi Pico W

In this video lesson we show how mission critical data can be saved in Flash Memory on the Raspberry Pi Pico W. There is just 2 MB of flash memory available, and the flash memory is only specified for 100,000 write cycles. This means we must be careful and deliberate in when to use flash memory, and it should not be used as a general purpose data logger. For example, if you wrote a memory location once a second, you could reach cycle limit in a few days. However, storing things like calibration data, user preferences and so forth are excellent uses of the memory.

In order to demonstrate this capability, we will show a program where the position of the servo is saved in a .json file in flash memory. If power is lost, the program goes and reloads the last position of the servo from the .json file, and then proceeds from there. We use the following circuit:

This demonstration circuit controls servo position by two push buttons

We also include the code developed in this lesson below for your convenience: