Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Python/Raspberry Circuit Continuity/Resistance tester

Sat Apr 16, 2016 2:40 pm

Hi all, probably 10 year ago while shopping at maplins i spoke to an electrician who had with him a resistor tester that he had made, it was hard wired just using raw components(maybe a pic chip) and was amazing!, telling the resistance of any resistive device attached to its contacts.. i know a multimeter would tell the same but he had built that himself.

i always wanted to build one but could never figure out how, now ive used python a few times im thinking there must be a way to build a multimeter type device but am struggling to find any code examples to start with or build from.

after alot of research it seems id be able to use a mcp3008 analog to digital converter, id hope to run 3.3/5v through the resistive device then measure the volts at the opposite side to determine the drop in voltage, then id hope to work out the resistance based from the voltage drop but am not sure of the math for this.
I believe i would also need to know the current of the circuit (i presume this would change depending on whats connected) to be able to work out the resistance? could i use an additional device attached to raspberry to work out current(if the calculation would require current)?

would be great if anybody is able to shed some light on this or point me in the right direction.
id like to be able to use it to test the resistance of anything from a 0.25w resistor to a 3phase motor.

ive since found some code for a LDR that i will start with, i suppose in simpler terms im trying to work out a ohms reading based from this volts read returned from the mcp3008

Code: Select all

def ReadChannel(channel):
  adc = spi.xfer2([1,(8+channel)<<4,0])
  data = ((adc[1]&3) << 8) + adc[2]
  return data
 

def ConvertVolts(data,places):
  volts = (data * 3.3) / float(1023)
  volts = round(volts,places)
  return volts

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sat Apr 16, 2016 4:57 pm

seems im able to answer this.. yes i would need to know the current of the resistive load, but this can be obtained by using a resistor, then working out the voltage difference over that resistor to work out the current, then using that current and the voltage drop over the resistive load i could work out what resistance the load is.
Last edited by Davies on Sat Apr 16, 2016 6:02 pm, edited 1 time in total.

hippy
Posts: 7731
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sat Apr 16, 2016 6:02 pm

The other trick which doesn't need an ADC, only a comparator, is to charge up a capacitor, measure how long it takes to charge, and calculate resistance from that.

You can of course build a basic capacitance meter the same way.

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sat Apr 16, 2016 6:11 pm

thanks hippy, i do have a soil moisture sensor that works in that way and did try to test using it.. though it didnt return a reading when connecting a resistor across it.. probably because of the charging time on the internal capacitor..
the moisture sensor also seems to be somewhat unstable so im goin to try the adc method hoping that will yield a stable result, though the way you suggest must have been how the guy at maplins did it as im sure his device also tested capacitance

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sat Apr 16, 2016 10:50 pm

Image
i think the circuit above would work, if ADC1 was 4.5v and input was 5v first calculation would be 0.5v / 100ohms = 0.005amp
then if ADC2 was 1.2v i would say 4.5v - 1.2v = 3.3v / 0.005amp would mean the resistive load is 660ohms
although it would be 3.3v total and a 10k resistor.
i think this would be right, but please somebody correct me if im wrong.

hippy
Posts: 7731
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sun Apr 17, 2016 7:31 am

ADC2 should not read as anything other than 0V

Davies
Posts: 150
Joined: Sat Apr 04, 2015 4:24 pm

Re: Python/Raspberry Circuit Continuity/Resistance tester

Sun Apr 17, 2016 10:40 am

ah, ofcoarse.. it would be like trying to measure between two places along a neutral line. perhaps another resistor between resistive load and ground then bring in adc2 just before the resistor.. or perhaps removing the ground completely and dumping back to adc2 may work? ive ordered a few mcp3008 so i can test something out with this.

Return to “Python”