HanyTalaatRamadan
Posts: 3
Joined: Fri Dec 22, 2017 11:01 pm

Analog Reads from SCT-013 current sensor using MCP3008

Sat Dec 23, 2017 2:39 am

Hi ,

i'm new to Current monitor and analog sensor with Raspberry

i'm using SCT-013 with Raspberry Pi 3 and connected to MCP3008 to read analog input from SCT-013 to calculate the Current Amp , i followed datasheet to wire MCP3008 to Raspberry and SCT-013 connected to CH0 .

i tried Python code mentioned here :
viewtopic.php?t=123962

but i got 1308 mV all the time while i'm connected to 100 Watt lamp and AC 240 V even if the sensor caliper is not connected to Elec. cable !

can you explain to me how to use

wh7qq
Posts: 1448
Joined: Thu Oct 09, 2014 2:50 am

Re: Analog Reads from SCT-013 current sensor using MCP3008

Sat Dec 23, 2017 7:34 pm

The SCT is a transformer...period. It outputs AC that must be rectified and filtered to DC for the A-D converter. It also has to be pre-loaded for scaling purposes and it may have to be divided down, depending on current flow and the range of the A-D. See the SCT-013 data sheet and/or various web pages (google it) for necessary values. I recall seeing an article and diagram for the Arduino on-line. I just use mine for on-off information and don't care too much about accuracy...just rectify and scale for the RPi's GPIO input.

Forgive me if this labors the obvious but you say you are new to it...you can only use one side of the AC pair inside the jaws of the SCT. Why you are seeing so much voltage on your measuring setup when not connected sounds like your meter is messed up or your monitoring circuit is picking up stray AC. If you monitor the AC voltage on the output, it should be zero with nothing connected and some AC value when the line is drawing power. DC may be random with a high impedance DC meter as most DVM's are.

HanyTalaatRamadan
Posts: 3
Joined: Fri Dec 22, 2017 11:01 pm

Re: Analog Reads from SCT-013 current sensor using MCP3008

Wed Dec 27, 2017 2:06 am

Thanks for help :)

my Project is to calculate the produced power and load Amp of Generator , so that i used SCT-013 100AMP.
the same circuit used with Arduino and it works fine , MCP3008 wiring is correct .
i'm using the following code to test the output but i got 0

Code: Select all

# Simple example of reading the MCP3008 analog input channels and printing
# them all out.
# Author: Tony DiCola
# License: Public Domain
import time

# Import SPI library (for hardware SPI) and MCP3008 library.
import Adafruit_GPIO.SPI as SPI
import Adafruit_MCP3008


# Software SPI configuration:
CLK  = 23 #18
MISO = 21 #23
MOSI = 19 #24
CS   = 24 #25
mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)

# Hardware SPIHardware SPI configuration:
#SPI_PORT   = 0
#SPI_DEVICE = 0
#mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
print('Reading MCP3008 values, press Ctrl-C to quit...')
# Print nice channel column headers.
print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*range(8)))
print('-' * 57)
# Main program loop.
while True:
    # Read all the ADC channel values in a list.
    values = [0]*8
    for i in range(8):
        # The read_adc function will get the value of the specified channel (0-7).
        values[i] = mcp.read_adc(i)
    # Print the ADC values.
    print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*values))
  # Pause for half a second.
    time.sleep(0.5)
any help why i'm getting 0 and if i enabled hardware SPI Section i got a random numbers for other pins and 795 for CH0 while it connected to power or not !

Richad Harianja
Posts: 1
Joined: Tue Feb 13, 2018 3:51 am

Re: Analog Reads from SCT-013 current sensor using MCP3008

Tue Feb 13, 2018 4:04 am

Help me please, I have a SCT 013-000 sensor but i do not have python program code. I want to use these sensors to measure electric current power. The sensor is connected with raspberry pi.

wh7qq
Posts: 1448
Joined: Thu Oct 09, 2014 2:50 am

Re: Analog Reads from SCT-013 current sensor using MCP3008

Tue Feb 13, 2018 8:31 pm

If as you say
so that i used SCT-013 100AMP.
the same circuit used with Arduino and it works fine , MCP3008 wiring is correct .
i'm using the following code to test the output but i got 0
all I can suggest is to go back to basics and check to be sure the SCT-013 is actually putting out a voltage with an AC voltmeter. Mine outputs 8+ VRMS with about 20 amps through the primary to an open circuit secondary (which they say never to do). Then, step by step, troubleshoot through the signal chain. You can apply a known DC voltage to the input of the 3008 to show if it is working (you may have to step it down with a divider). I have no idea if your code is bad or good but you can test that with the DC input as well. Good Luck.

Return to “Troubleshooting”