Hi, I want to record the AC current time stamp data into my RaspberryPi from current sensor (WCS1600) via an ADC(ADS1015) that is being supplied to my mobile.
Herewith I have attached a schematic diagram of the setup.
For the pyhton codes, I have referred following link https://github.com/OpenLabTools/RPi_ADS1115/blob/master/code/continuous_read_adc.py with some modification. It is mentioned below:
from Adafruit_ADS1x15 import ADS1x15
import numpy as np
import matplotlib.pyplot as plt
pga = 1
ADS1015 = 0x00
adc = ADS1x15(ic=ADS1015)
print "sps value should be one of: 128, 250, 490, 920, 1600, 2400, 3300, otherwise the value will default to 1600"
frequency = 1000
sps = 3300
time1 = 10
period = 1.0 / frequency
datapoints = int(time1*frequency)
adc.start_adc(0, pga, sps)
V_dd = 3.3
n = 12
senstivity = 0.022
for x in range (0,datapoints) :
dataarray[x,0] = time.time()-startTime
dataarray[x,1]= ((adc.get_last_result())*(V_dd)/(2**n))/ senstivity
while (t2-t1 < period) :
dataSamples = logdata()
TIME = dataarray[:,]
CURRENT = dataarray[:,]
plt.plot(TIME,CURRENT 'r', linewidth=1)
The input side the charger reads (110-220 V, 50 Hz, 0.3A).So we can expected a sinusoidal wave for the current time stamp with maximum current restricted to 0.3A.
However, on plotting the time vs current below graph is achieved which is obviously wrong:
Can somebody please let me know why am I not getting sinusoidal waveform, I would be very much appreciative
This topic was modified 2 years ago by ranjanpal