Any Current Sensor sample code?

Questions about Modern Device and JeeLabs Sensors
firestream99
Posts: 2
Joined: Sat Feb 16, 2013 5:39 am

Any Current Sensor sample code?

Post 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,

oz
Site Admin
Posts: 542
Joined: Mon May 12, 2008 4:19 pm

Re: Any Current Sensor sample code?

Post 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

firestream99
Posts: 2
Joined: Sat Feb 16, 2013 5:39 am

Re: Any Current Sensor sample code?

Post by firestream99 »

Thx. That should get me going.

Post Reply