Save data from a TSL2591 light sensor (instructions) connected to a QT Py RP2040 with a STEMMA QT cable and your PC via USB.
When the 'boot' button on the QT Py is pressed, it continuously saves data from the light sensor in a csv file on your computer until the 'boot' button is pressed again.
NOTE: if you prefer not to use the 'boot' button to indicate start/stop, but you'd rather record light values continuously from the moment you execute the code and until a key on your keyboard is pressed, then check out the Continuous-acquisition branch in this repository instead.
NOTE: if you prefer to continuously record light values for an infinite time from the moment you execute the code and automaticaly save these values at a time of your choice once per day, then check out the Save-daily branch in this repository.
You need to have the python package serial installed in your environment.
-
Connect the QT Py to your computer via USB
-
Configure the QT Py according to these instructions if you have not already done so
-
Copy over the following to the "lib" folder on your CIRCUITPY (D:) drive from one of the CircuitPython library bundles:
Files:
- adafruit_tsl2591.mpy
- neopixel.mpy
Folders:
- adafruit_bus_device
- adafruit_circuitplayground
-
Copy the contents of the code.py file in this repository into the code.py file on your CIRCUITPY (D:) drive
-
Connect the light sensor to the QT Py with the STEMMA QT cable
-
Specify which USB port the QT Py is connected to by modifying the 'ser' variable within serial_reader.py (default port: COM3)
-
Specify which folder the csv file should be saved in on your PC by modifying the 'root_folder' variable within serial_reader.py (default location: C:/DATA/Sensor_data)
-
Run the serial_reader.py file in your terminal
-
When the word 'Ready' is shown, press the 'boot' button on the QT Py to start recording light values. These will also be printed out in your terminal. The LED on the QT Py will turn off to indicate that the recording is in progress
-
Press the 'boot' button again to stop recording values
-
A csv file with the recorded values and timestamps can now be found in the location you specified
Tip: you can modify the gain and integration time of the light sensor under 'SETTTINGS' in the code.py file.