Hi! I have an Arduino Uno and I've set up a CT sensor to measure current on my analog pin 1 using the exact setup here: http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only. Works great!
I also have an interrupt (digital pin 2, interrupt 0) where i'm listening for a 9v "ping". Its on the same breadboard with a voltage divider (2x10k resistors, dropping that down to about 4.5v). Digital pin 2 has the 20k pulldown resistor enabled. This also works great on its own.
But as soon as my CT circuit picks up a signal, 2k watts (about 16 amps), it sometimes sets off the interrupt! (not always, about half the time, its kinda random)
I'm wondering what would cause this. Should I use different resistor values to compensate for some kind of interference? Just wondering if any of you seasoned arduino peeps would have any advice. Thanks!!
Here's my code, just for reference:
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
volatile int count = 0;
void setup()
{
pinMode(2, INPUT); // interrupt 0
digitalWrite(2, HIGH); // trun on pull up resistor
Serial.begin(9600);
attachInterrupt(0, riser, RISING);
emon1.current(1, 111.1); // Current: input, calibration.
}
void loop()
{
double Irms = emon1.calcIrms(1480); // Calculate Irms only
Serial.print(Irms*120.0); // Apparent power
Serial.print(" ");
Serial.print(Irms); // Irms
Serial.print(" ");
Serial.println(count);
delay(500);
}
void riser()
{
count++;
}