I'd like to connect a small solar panel (2v 50ma) to a USB cable and measure the output on python. Now I was wondering if this would work and how to make it work.
How many volts can I send into my pc? And would pyUSB work for reading this?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
You cannot connect a voltage source directly to the USB data lines - USB is a complex digital communications system.
You would require an Analog to Digital converter (ADC) that could interface to USB, and connect your solar panel to the ADC analog input.
Looks like the simplest way would be this which means one of these with a shunt resistor to convert the current to a voltage drop. The bad news is that it isn't the smallest possible package for the job; the good news is that it's a single package (since the PIC does all the USB) with supporting hardware, and there's more than enough room to expand if you want to get fancy (e.g. parallel LCD output, keypad input, multiple panels, etc.).
You can then use PySerial to talk with the PIC since it will show up as a serial port on the computer.
You can't do this directly.
Get a microcontroller with an ADC and an USB interface, then use the ADC to read from the solar panel and transmit this over USB (or other communication method) to the computer where Python is running.