Can somebody tell me if the following is correct?
I want to use the PI to read out some photo transistor to follow the LED pulse of the electricity meter.
- Can I connect a phototransistor between the 3.3V line and a GPIO port (0-7)?
You could, but then you need to add a resistor between the GPIO and GND, but it is much more common to connect the phototransistor in between the GPIO and GND, and add a weak pullup resistor.Obviously a lighted phototransistor will read as a "0", not as a "1", but that isn't a problem.
[*]On other boards people are using a 4K7 resistor between the 3.3V and the GPIO port. They connect the other line to a GND. Do I need also a resistor and using the 3.3 / GPIO AND GND
Normally yes, but the GPIO's of the PI have programmable pulups (and maybe also pulldowns), which you can turn on, but with an external pullup/pulldown you do not need to turn on the internal ones.
[*]What is the most simple way to test the GPIO input? I've written a program to read out the input and want to test that before using the photo transistor. Can I connect a wire to the 3.3v and GPIO input line and shorten them to emulate a pulse?[/list]
It's not a very good idea to directly connect a GPIO pin to 3V3, if you have made a mistake in programming the GPI0 as inputs, and the GPIO is trying to output a "0", you will blow up the GPIO pin, and maybe damage the SoC.
That is one reason to use a pullup, and and active pulldown switch (phototransistor), if you shorten the GPIO pin while its an output its safer, for two reasons, 1 the GPIO is more likely to output a "0", and 2 the GPIO outputs are current limited.
To test the GPIO as input the best way is to use a 10K pullup, and shorten it to GND with a 100 Ohm resistor connected to GND.
Thanks for helping
You are welcome.