Can I able to use python grove pi current sensor in a computer

grovepi
sensors
electricity

#1

I have a XBee that is connected to the computer and I have grove current sensor which is connected to the AD2 pin of XBee . My question is can I able to use the following command for getting accurate current value of that sensor. I got this formula from the Grove wikki
amplitude_current = (float)(sensor_value / 1024 * grove_vcc / 800 * 2000000)

        # Calculate effective value (mA)
        effective_value = amplitude_current / 1.414

        # minimum_current = 1 / 1024 * grove_vcc / 800 * 2000000 / 1.414 = 8.6(mA)
        # Only for sinusoidal alternating current

        print "sensor_value", sensor_value
        print "The amplitude of the current is", amplitude_current, "mA"
        print "The effective value of the current is", effective_value, "mA"

Thanks in advanced
Arun


#2

Hi @arunnediyasala,

I’d say that’s the correct formula for getting the effective value. Here’s a very interesting topic on the Grove Current Sensor. I suggest you give it a good read.

Thank you!


#3

@RobertLucian Thanks for your replay. I read the document you have provided in that I found Arduino A) pin out put value is from 0 to 36 but XBee ADC pin value is range from 0 to 1023 . So the above formula is suitable for my case .When I try to test 156Wh. I am getting 140 Wh. Should I calibrate this model for getting the accurate value.


#4

Hi @arunnediyasala,

I would make a suite of tests for different values - say 10 tests and then I’d check if adjusting the values (by offsetting them or by some sort of factoring it) is enough for predicting new values. Visualizing both curves (for both the calculated value and the measured one) should give lots of insight.

Following these tests and readjustments, if the sensor is not capable of predicting accurately, then it means it’s the sensor that’s not accurate enough for the task. Otherwise, then it means it was just a problem of calibrating it.

Hope this makes sense for you and helps you.

Thank you!


#5

@RobertLucian Thanks for your detailed replay.


#6

Great. I’ll leave this thread open should you want to ask anything else. If not, please let me know so I can close the thread.

Thank you!