Page 1 of 1

Any Current Sensor sample code?

Posted: Sat Feb 16, 2013 5:57 am
by firestream99
Hi,

I just bought the current sensor in order to develop a solution that allows us to determine if a TV is on or not for our smart home company. I haven't been able to find any sample code that shows how to use this from a JeeNode. Can anyone point me to an example?

Thx,

Re: Any Current Sensor sample code?

Posted: Sat Feb 16, 2013 11:58 am
by oz
Here's some code that uses the JeeLabs calls

/* ReadAnAnalogPin
Reads an analog pin on a JeeNode and prints to the serial monitor
*/

#include <Ports.h>
#include <RF12.h> // needed to avoid a linker error :(

Port port (1);

void setup(){
Serial.begin(57600); // std JeeLabs serial rate
}

void loop(){
int value = port.anaRead();
Serial.println (value);
delay(100);
}


You could also just use Examples -> Basics -> AnalogReadSerial
for a quick read of an analog pin and print to the serial monitor

Port1 AIO pin = A0, Port2 AIO = A1, etc

Hope that helps,

Paul

Re: Any Current Sensor sample code?

Posted: Mon Feb 18, 2013 6:47 am
by firestream99
Thx. That should get me going.