Holooly Plus Logo

Question 9.11: You want to connect an analog panel volt meter to a Raspberr......

You want to connect an analog panel volt meter to a Raspberry Pi.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

Assuming you have a 5V volt meter, you can use a PWM output to drive the meter directly, connecting the negative side of the meter to ground and the positive side to a GPIO pin (Figure 9-14). However, if the meter is the common 5V kind, you’ll only be able to display voltages up to 3.3V.

If you want to use almost the full range of a 5V volt meter, you will need a transistor to act as a switch for the PWM signal and a 1kΩ resistor to limit the current to the base of the transistor.

To make this recipe, you will need:

• 5V panel meter (“Miscellaneous” on page 382)
• Breadboard and jumper wires (see “Prototyping Equipment” on page 380)
• Two 1kΩ resistors (see “Resistors and Capacitors” on page 380)
• Transistor 2N3904 (see “Transistors and Diodes” on page 381)

The breadboard layout for this is shown in Figure 9-15.

Discussion

To test the volt meter, use the same program as you did for controlling the brightness of the LED in Recipe 9.2.

You will probably notice that the needle gives a steady reading at either end of the scale, but everywhere else jitters a bit. This is a side effect of the way the PWM signals are generated. For a steadier result, you can use external PWM hardware like the 16-channel module used in Recipe 10.2.

See Also

For more information about how old-fashioned volt meters work, see Wikipedia.

For more information on using a breadboard and jumper wires with the Raspberry Pi, see Recipe 8.10.

Table A-9. Miscellaneous
1200mAh LiPo battery Adafruit: 258
5V relay SparkFun: COM-00100
5V panel meter SparkFun: TOL-10285
Servo motor SparkFun: ROB-09065, Adafruit: 1449
5V 1A power supply Adafruit: 276
Low power 6V DC motor Adafruit: 711
0.1 inch header pins SparkFun: PRT-00116, Adafruit: 392
5 V 5-pin unipolar stepper motor Adafruit: 858
12 V, 4-pin bipolar stepper motor Adafruit: 324
Magician chassis with gearmotors SparkFun: ROB-10825
Tactile push switch SparkFun: COM-00097, Adafruit: 504
Miniature slide switch SparkFun: COM-09609, Adafruit: 805
Rotary encoder Adafruit: 377
4×3 keypad SparkFun: COM-08653
Piezo buzzer SparkFun: COM-07950, Adafruit: 160
Table A-3. Prototyping equipment
Description Suppliers
M-M jumper wires SparkFun: PRT-08431, Adafruit: 759
M-F jumper wires SparkFun: PRT-09140, Adafruit: 825
F-F jumper wires SparkFun: PRT-08430, Adafruit: 794
Half-sized breadboard SparkFun: PRT-09567 Adafruit: 64
Pi Cobbler Adafruit: 1105
Table A-4. Resistors and capacitors
270Ω 0.25W resistor Mouser: 293-270-RC
470Ω 0.25W resistor Mouser: 293-470-RC
1kΩ 0.25W resistor Mouser: 293-1k-RC
3.3kΩ 0.25W resistor Mouser: 293-3.3k-RC
4.7kΩ 0.25W resistor Mouser: 293-4.7k-RC
10 kΩ trimpot Adafruit: 356, SparkFun: COM-09806, Mouser: 652-3362F-1-103LF
Photoresistor Adafruit: 161, SparkFun: SEN-09088
220nF capacitor MCM: 31-0610, Mouser: 80-C322C224M5U5HA
Table A-5. Transistors and diodes
FQP30N06 N-channel MOSFET transistor SparkFun: COM-10213, Adafruit: 355
2N3904 NPN bipolar transistor SparkFun: COM-00521, Adafruit: 756
1N4001 diode SparkFun: COM-08589, Adafruit: 755
9.14
9.15

Related Answered Questions

Question: 9.10

Verified Answer:

The way to do this is to use a technique called Ch...
Question: 9.9

Verified Answer:

Use PWM to control the power to each of the red, g...
Question: 9.8

Verified Answer:

Using the Tkinter user interface framework, write ...
Question: 9.7

Verified Answer:

Using the Tkinter user interface framework, write ...
Question: 9.5

Verified Answer:

Use a relay and small transistor. Figure 9-5 shows...
Question: 9.1

Verified Answer:

Connect an LED (see “Opto-Electronics” on page 381...
Question: 9.3

Verified Answer:

Use a piezo-electric buzzer connected to a GPIO pi...
Question: 9.4

Verified Answer:

These high-power LEDs use far too much current to ...
Question: 9.6

Verified Answer:

Use a PowerSwitch Tail II (see “Modules” on page 3...