===== Setting up the microcontrollers =====
To test the microcontrollers, open up [[https://thonny.org/|Thonny]] and use the hamburger menu in the bottom right menu to select ''MicroPython (ESP32)'' while the board is plugged in. If it doesn't bring up a REPL prompt, you'll need to install MicroPython on the unit
==== Installing Micropython ====
A tutorial for installing MicroPython is available at the [[https://micropython.org/download/ESP32_GENERIC_C3/| MicroPython website]]. Thonny will tell you what port the device is connected on, but you'll need to close it before you use the ''ESPTool'' program. You can run both commands at the same time via the following:
esptool erase_flash & esptool –baud 460800 write_flash 0 ESP32_GENERIC_C3-20250911-v1.26.1.bin
==== Uploding Code ====
Plug the device in, and connect to it via Thonny. Use the ''View'' tab to check the ''Files'' option. Copy the ''main.py'' file to the device, create (and enter) a ''lib'' folder on it, and then upload ''functools.py'' to the folder. Connect the sensor and run the ''main.py'' code to check if it works, it should output a message saying ''addresses found:0x10'' and then start streaming data.
{{phylabs:lab_courses:phys-120_130-wiki-home:spring-experiments:new_polarization:main.py}}
{{phylabs:lab_courses:phys-120_130-wiki-home:spring-experiments:new_polarization:functools.py}}
===== Setting up PCs =====
Computers will need to have ''tkintertable'' and ''pyserial-py'' packages installed. The rest should be part of a default anaconda install.
The computer side needs the following file: {{phylabs:lab_courses:phys-120_130-wiki-home:spring-experiments:new_polarization:interface.py}}
Setting up the default for the ''.py'' extension to ''C:\Program Data\Anaconda3\python.exe'' is also needed.
===== Using the software =====
The interface is pretty self-explanitory. I've tried to remove bits that we didn't need for the current implementation to keep it clean. It will close itself if the sensor isn't already hooked up when it starts.
''Calibrate'' just normalized the current sensor reading to 1000 by measuring the light level on the sensor and coming up with an appropriate constant. May work very poorly for low light levels.