ZtimE
Posts: 3
Joined: Tue Nov 13, 2012 6:45 pm

GPIO to measure volt, mA

Tue Nov 13, 2012 6:57 pm

Hi guys and girls!

New to this forum though i've had the Raspberry Pi for a while , haven't had the time to play with it yet.

I have a project i want to do but after googeling around i can't find anything similar.
I want to use the Pi to measure volt , mA and resistance and log it to a database . I will then use a webinterface to control the whole thing.
Will use this in my job where i work with the electronics for controlling fans and ventilation. In some cases the system are to old and can't log values.
Then i would like to get some cables and "hijack" the signals to measure them.

Now the software bit i'm not that worried about, that i can handle. However in electronics i'm a total beginner.

I have been looking for curciut board voltmeters online but i can't find anything.
In my head i've pictured it like this, i connect a analog/digital converter to the GPIO and to that converter i connect the volt/mA meters.

Is this possibly to do? I'm i crazy for attempting this?
What do you guys think?

/Jonas

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK

Re: GPIO to measure volt, mA

Tue Nov 13, 2012 10:23 pm

ZtimE wrote:Hi guys and girls!

New to this forum though i've had the Raspberry Pi for a while , haven't had the time to play with it yet.

I have a project i want to do but after googeling around i can't find anything similar.
I want to use the Pi to measure volt , mA and resistance and log it to a database . I will then use a webinterface to control the whole thing.
Hmm so you want to build a web controlled and logging DMM (Digital MultiMeter).

First thing to remember you cannot measure resistance on a live circuit with a MultiMeter.

Second you have not said what range you require to measure, if the unit is to be autoranging and how many measurements at the same time.

Thirdly what sort of budget you think this will be. Building true multimeters is expensive as they have to cope with all sorts of ranges and have protection circuits. I you want to measure more than around 30V DC and about 50V AC you will have to consider safety aspects and standards to meet especially if using for work. If measuring more tha 1A DC or AC, you will have to put in some beefy components. If meausring less than 100mV or about 10mA, you really need a well laid out PCB and minimal connections to reduce noise and other artifacts affecting the readings.
Will use this in my job where i work with the electronics for controlling fans and ventilation. In some cases the system are to old and can't log values.
Great so the circuit will need surge and spike protection and ablity to measure them not doubt, in other words high voltages and currents.
Then i would like to get some cables and "hijack" the signals to measure them.
With statements like that, I think you need to get a qualified engineer to assess your requirements as your knowledge level sounds like you may cause problems.

I am remided of fact a couple of weeks ago I went across to a friends and rewired their light fittings as the friend of their son who "knew" about electrics could not work out how to wire up light fittings without blowing the fuses.
Now the software bit i'm not that worried about, that i can handle. However in electronics i'm a total beginner.

I have been looking for curciut board voltmeters online but i can't find anything.
In my head i've pictured it like this, i connect a analog/digital converter to the GPIO and to that converter i connect the volt/mA meters.
Yes and no. Yes connect some form of A/D converter and No you will need a lot of circuitry before it for sorting out range scaling so you dont end up with 240V on the A/D, or other similar things.
Is this possibly to do? I'm i crazy for attempting this?
What do you guys think?

/Jonas
Hmm I could not comment on your mental status :-)

If only measuring one parameter do searches for USB DMM or USB Multimeter and see what instruments you can find that plug into USB or have a USb or even network interface.

Also look at loggers they exist already and have done for years.

Don't reinvent the whell unless you have to, reuse or apply existing items to fit your needs.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14478
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO to measure volt, mA

Tue Nov 13, 2012 10:26 pm

There are plenty Analog to digital converters that are suitable for the PI, especially there are many A/D chips for the I2C bus that are useable, but you have to understand this:

all these converters only can measure (DC) voltages!

If you want to measure something else than a DC voltage, you have to convert whatever you want to measure to a DC voltage first!

For example, if you want to measure a DC current, you must run the current through a resistor, so there is a DC voltage proportional to the current over that resistor, and its that (DC) voltage you will actually be measuring!

If you need to measure an AC voltage you will be confronted with the difficult task of converting it to a proportional DC voltage first.

If you want to measure resistance, you should send a "known current" through that resistor, and then measure the voltage over said resistor, etc etc.

ZtimE
Posts: 3
Joined: Tue Nov 13, 2012 6:45 pm

Re: GPIO to measure volt, mA

Tue Nov 13, 2012 11:09 pm

Wow fast answers, thanks !

Think i was a bit unclear about everything
techpaul wrote: First thing to remember you cannot measure resistance on a live circuit with a MultiMeter.
I should have explained further, the idea i had was to disconnect a temperaturesensor (there usally called PT1000 and its just a resistor) and log that value.
techpaul wrote: Second you have not said what range you require to measure, if the unit is to be autoranging and how many measurements at the same time.
Units to be measured is 0-10V 2-10V (AC/DC) and 4-20mA
techpaul wrote: Thirdly what sort of budget you think this will be. Building true multimeters is expensive as they have to cope with all sorts of ranges and have protection circuits. I you want to measure more than around 30V DC and about 50V AC you will have to consider safety aspects and standards to meet especially if using for work. If measuring more tha 1A DC or AC, you will have to put in some beefy components. If meausring less than 100mV or about 10mA, you really need a well laid out PCB and minimal connections to reduce noise and other artifacts affecting the readings.
I wont be measuring that high voltages / currents so that will not be problem, however it sounds like measuring 4-20mA might be a problem . Especially since my thought was to have like 5 - 10 of them.
techpaul wrote: Great so the circuit will need surge and spike protection and ablity to measure them not doubt, in other words high voltages and currents.
Sure protection will be needed but there wont be any high voltages or currrents
Then i would like to get some cables and "hijack" the signals to measure them.
techpaul wrote: With statements like that, I think you need to get a qualified engineer to assess your requirements as your knowledge level sounds like you may cause problems.
Again i think some clarification is needed, the idea i had was to connect in between the source (regulator) and the target (for example an actuator)
So instead of : Regulator -> Actuator it becomes Regulator -> my box -> actuator

techpaul wrote: Yes and no. Yes connect some form of A/D converter and No you will need a lot of circuitry before it for sorting out range scaling so you dont end up with 240V on the A/D, or other similar things.
Right, that sounds like a tricky part. Since i want to be able to scale on at least two scales (0-10V and 2-10V)
techpaul wrote: If only measuring one parameter do searches for USB DMM or USB Multimeter and see what instruments you can find that plug into USB or have a USb or even network interface.

Also look at loggers they exist already and have done for years.

Don't reinvent the whell unless you have to, reuse or apply existing items to fit your needs.
Yeah this was more of a fun home projects that could be used for work if needed. The point is to learn more about electronics.
I was thinking about measuring 5-10 values at the same time .
majhonngg wrote: There are plenty Analog to digital converters that are suitable for the PI, especially there are many A/D chips for the I2C bus that are useable, but you have to understand this:

all these converters only can measure (DC) voltages!

If you want to measure something else than a DC voltage, you have to convert whatever you want to measure to a DC voltage first!

For example, if you want to measure a DC current, you must run the current through a resistor, so there is a DC voltage proportional to the current over that resistor, and its that (DC) voltage you will actually be measuring!

If you need to measure an AC voltage you will be confronted with the difficult task of converting it to a proportional DC voltage first.

If you want to measure resistance, you should send a "known current" through that resistor, and then measure the voltage over said resistor, etc etc.
Yeah i actually found some A/D for i2c bus when i knew what to google for , just didn't know where to look.

Ok converting to DC from AC sounds like a difficult part, is it easier when i now the scales? (0-10V etc.)

Thanks for the quick answers guys , really helpful!

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 14478
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO to measure volt, mA

Tue Nov 13, 2012 11:29 pm

Converting AC to DC can be as simple as using a single diode and a capacitor to "follow the peaks of the AC signal, to create a DC voltage equivalent to the peak AC voltage", or as complex as a whole board full of operational amplifiers, if you want to do it well, and convert the "real mean square" (RMS) value of the AC to an equivalent DC signal. That means, convert it in such a way that the AC signal would induce the same amount of energy into a resistor, as the equivalent DC signal will. so it depends on what you mean by "converting to an equivalent DC voltage".

Expensive digital AC voltage meters, and cheap analog moving coil meters both show the RMS value of the AC signal, the digital meter does it with lots of complex analog logic, and the analog meter because the equivalent energy that is what "drives the moving coil". In other words for analog meters it is "natural" to show the RMS value.

The biggest trick for the digital meter is to do it correctly, even if the AC signal isn't a simple sinusoid signal.

perhaps all that isn't necessary for your application, and you can simply use a signal rectifier.

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK

Re: GPIO to measure volt, mA

Tue Nov 13, 2012 11:35 pm

ZtimE wrote:Wow fast answers, thanks !

Think i was a bit unclear about everything
techpaul wrote:First thing to remember you cannot measure resistance on a live circuit with a MultiMeter.
I should have explained further, the idea i had was to disconnect a temperaturesensor (there usally called PT1000 and its just a resistor) and log that value.
One at a time is easy and all isolated.
techpaul wrote: Second you have not said what range you require to measure, if the unit is to be autoranging and how many measurements at the same time.
Units to be measured is 0-10V 2-10V (AC/DC) and 4-20mA
4-20mA in simplest terms is relatively easy as it is a resistor to convert to voltage. However 4-20mA brings in problems as this can often be upto 20 to 30 V (I have seen higher) and in some cases it is floating so the lowest vltage could be sitting at 50V in respect to mains earth, which your Pi and other bits are referenced to. That is why it is easy on battery powered DMM, everything floats safely and does not get damaged.
techpaul wrote: Thirdly what sort of budget you think this will be. Building true multimeters is expensive as they have to cope with all sorts of ranges and have protection circuits. I you want to measure more than around 30V DC and about 50V AC you will have to consider safety aspects and standards to meet especially if using for work. If measuring more tha 1A DC or AC, you will have to put in some beefy components. If meausring less than 100mV or about 10mA, you really need a well laid out PCB and minimal connections to reduce noise and other artifacts affecting the readings.
I wont be measuring that high voltages / currents so that will not be problem, however it sounds like measuring 4-20mA might be a problem . Especially since my thought was to have like 5 - 10 of them.
When fans and motors start they put high voltage spikes into everything via the power rails and by radiating electromagnetic interference. Larger the unit the larger the spikes.
techpaul wrote:Great so the circuit will need surge and spike protection and ablity to measure them not doubt, in other words high voltages and currents.
Sure protection will be needed but there wont be any high voltages or currrents
See Above
Then i would like to get some cables and "hijack" the signals to measure them
techpaul wrote:With statements like that, I think you need to get a qualified engineer to assess your requirements as your knowledge level sounds like you may cause problems.
Again i think some clarification is needed, the idea i had was to connect in between the source (regulator) and the target (for example an actuator)
So instead of : Regulator -> Actuator it becomes Regulator -> my box -> actuator
But even if you are measuring 20V it will be 20V referenced to what? As that 20V could be several volts above mains earth, but still have only a relative 20V across it. Actuators are magnetic devices so more spikes. If reading AC requires AC to DC conversion to make readings.
techpaul wrote: Yes and no. Yes connect some form of A/D converter and No you will need a lot of circuitry before it for sorting out range scaling so you dont end up with 240V on the A/D, or other similar things.
Right, that sounds like a tricky part. Since i want to be able to scale on at least two scales (0-10V and 2-10V)
All the scaling has to be done by circuits that operate through isolation to change ranges using relays and the likes.
techpaul wrote: If only measuring one parameter do searches for USB DMM or USB Multimeter and see what ....
Don't reinvent the whell unless you have to, reuse or apply existing items to fit your needs.
Yeah this was more of a fun home projects that could be used for work if needed. The point is to learn more about electronics.
I was thinking about measuring 5-10 values at the same time .
The area you are looking is more like not learning to drive a car but learning how to drive an articulated lorry around an assault course. I would start simpler and work up to that level.

Start with software for getting one channel multimeter by USB even if logging resistance, then work out how to meaure one channel of resistance with electronics (you can use your USB DMM to debug the circuit). Then look at measuring voltages and currents using pots or other low voltage and low current sources, then look at how to do multiple channels. Then look at how you get isolation and range scaling, also how to change between current, volatge, resistance, AC and DC with isolation. You need isolation to keep the measurement away from dangerous voltages and protect the rest of the equipment.

I am not saying dont do anything, but start simpler and safer. Acquire the electronics knowledge in steps and build up on it. It is more rewarding if you get lots of successes which are getting complicated as you go on.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

ZtimE
Posts: 3
Joined: Tue Nov 13, 2012 6:45 pm

Re: GPIO to measure volt, mA

Wed Nov 14, 2012 3:21 pm

techpaul wrote: I am not saying dont do anything, but start simpler and safer. Acquire the electronics knowledge in steps and build up on it. It is more rewarding if you get lots of successes which are getting complicated as you go on.
Yes this seems like the way to go , i need to get my basic electronic knowledge .
I'll start of with some basic tutorials and build from there!

Thanks for all the great advise!

Return to “Interfacing (DSI, CSI, I2C, etc.)”