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?

  • \$\begingroup\$ :/ C'mon... reword this, keeping my previous answer in mind :P \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 16 '13 at 21:14
  • \$\begingroup\$ Yea sorry, but this way atleast I'll get a "total idiot response", which is sorta what I need. xD (decent at programming but new at making hardware.) \$\endgroup\$ – Coolcrab Jun 16 '13 at 21:19
  • \$\begingroup\$ You need a current sensor, and it has to interface with USB. Ask about that. \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 16 '13 at 21:20
  • \$\begingroup\$ Yea, thats what they say :P my setup s getting more and more complicated. \$\endgroup\$ – Coolcrab Jun 16 '13 at 21:29

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.

  • \$\begingroup\$ So like one of these? ebay.co.uk/itm/… \$\endgroup\$ – Coolcrab Jun 16 '13 at 21:24
  • \$\begingroup\$ @Coolcrab - no - that one is intended to interface with an Arduino or other microcontroller - you would want one with a USB interface. \$\endgroup\$ – Peter Bennett Jun 16 '13 at 22:30

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.).


simulate this circuit – Schematic created using CircuitLab

You can then use PySerial to talk with the PIC since it will show up as a serial port on the computer.

  • \$\begingroup\$ How exactly do these PIC's work? And are they different from any other ADC's? (For example: ebay.co.uk/itm/… ) \$\endgroup\$ – Coolcrab Jun 16 '13 at 22:08
  • \$\begingroup\$ A PIC is a small microcontroller. It executes code and performs I/O however it is configured to. The ADC you link to is a simple analog-to-digital converter with non-USB serial output, and so needs to connect to another chip (such as a PIC) in order to communicate over USB. \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 16 '13 at 22:12
  • \$\begingroup\$ You should show that the ground connection for the ADC is shared with the solar cell ground. \$\endgroup\$ – Connor Wolf Jun 17 '13 at 4:53
  • \$\begingroup\$ @ConnorWolf: Better? \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 17 '13 at 5:05
  • \$\begingroup\$ I'd have put the input and input ground on the same side of the box, but it's good enough. \$\endgroup\$ – Connor Wolf Jun 17 '13 at 5:06

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.

  • \$\begingroup\$ Could you give an example? :p (Quite new at this) \$\endgroup\$ – Coolcrab Jun 16 '13 at 21:28
  • \$\begingroup\$ I don't have any, sorry. \$\endgroup\$ – Renan Jun 16 '13 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.