The Nano RP2040 Connect board has on-board storage that allows you to turn the device into a data logger without any extra components.
In order to utilize this feature, we need to install the latest release of OpenMV's flavor of MicroPython.
This tutorial can be completed with only the Nano RP2040 Connect board and open-source software.
The goals of this tutorial are:
format directly on the Nano RP2040 Connect.
1. The first step is to install the latest version of the OpenMV firmware (MicroPython) on the Nano RP2040 board. This version is available through the link below:
2. Unzip the contents, and locate the
file inside of the ARDUINO_NANO_RP2040_CONNECT folder.
3. Force the bootloader on the Nano RP2040 Connect, by connecting a jumper wire between
pins as shown in the image below. When the mass storage device opens, drag the
onto it, and the latest version will install.
4. Install and open the Thonny IDE. Navigate to Run > Select Interpreter and choose the "MicroPython(generic)" from the list. Your board should now appear in the other dropdown menu:
If your board appears, it has been successful. In this case, it is called
Board in FS mode (/dev/cu.usbmodem11201)
Now that the OpenMV MicroPython firmware is installed on your device, and it is detected using Thonny, we can create our datalogger.
The script for the datalogger is quite basic, and has the following functionality:
The script for this tutorial can be found below:
1import machine2from machine import Pin3import time45adc_pin = machine.Pin(29)6adc = machine.ADC(adc_pin)7led = Pin(6, Pin.OUT)8readings = 0910# create a file named "data.csv"11file=open("data.csv","w")12file.write("data"+"\n")1314while True:1516 led.value(1)17 reading = adc.read_u16()18 print("ADC: ",reading)1920 time.sleep_ms(100)2122 # convert and write the reading from the analog pin23 file.write(str(reading)+"\n")2425 led.value(0)26 time.sleep_ms(100)27 readings += 12829 # if 25 readings are done, finish the program30 if readings >= 25:31 file.close()32 break
Copy paste this code into the Thonny editor, and click on the Green Play Button (F5). The values recorded are also printed in the terminal, so we can compare it later. After running, it should look like this:
When you run the script, the board should now start blinking fast, every 100 milliseconds, and it will do so 25 times (as is specified in the code, the number can be changed).
Once done, navigate to Finder / Explorer, and locate a drive called "NO NAME". This should now include a
file. This contains the 25 readings we just made by running the script.
If you are using a Mac, you may need to change a setting that allows you to see external disks. If you can't see the drive, go to Finder > Preferences and tick the boxes that appear.
Congratulations, you have now successfully recorded data and stored it in a
file onboard the Nano RP2040 Connect.
Please note that you should never open this file whenever a file management operation is ongoing. This will most likely corrupt your file and you won't be able to obtain the data. Best practice is to record the data, wait a little, and then open up the
In this tutorial, we turned a Nano RP2040 Connect board into a data logger, without the use of any external components (such as an SD card).
This is an incredibly useful tool whenever you are working with data collection, and the script found in this tutorial can be easily be altered to fit your project.
While we in this tutorial only recorded values from an analog pin, there are many other things to do, such as: