Power meter sensor from BTE16-18 & Arduino Nano V3 by MilanGajic 3d model
Warning. This content is not moderated and could be offensive.
smoke
3dmdb logo
Thingiverse
Power meter sensor from BTE16-18 & Arduino Nano V3 by MilanGajic

Power meter sensor from BTE16-18 & Arduino Nano V3 by MilanGajic

by Thingiverse
Last crawled date: 3 years, 1 month ago
I have an old fashioned power meter with the spinning disk but wanted to get my power usage into Cacti.
I fashioned this cheapo sensor and it works ike a charm.
Sensor used:
BTE16-18 IR Reflection sensor from Aliexpress (https://goo.gl/4wDt8Z $0.78)
Connections:
Sensor->Arduino
VCC -> 5V
GND -> GND
OUT -> Pin D2
RST of the arduino is bridged to GND with a 10µF capacitor to prevent the Arduino from resetting when a serial conection is established (this works on a Nano V3 but different methods apply to other Arduinos). You MUST pull this capacitor if you want to upload code to the Arduino.
The IR will reflect off the plastic housing of the meter and it will be impossible to callibrate if you do not isolate the IR emitter. I just made a small tube out of some electrical tape that fits just around the emitter an sits flush against the plastic window; this fixed all callibration issues.
The sensor should be set up to look at the shiny side of the spinning disk. When the black stripe comes by it wil trigger the sensor (='tick'). The arduino will keep track of the ticks and the count can be read throught the USB serial interface of the Arduino. After connecting, issue command 'c' (count) to read the current count or 'd' (delta ... seemed logical at the time) to read the current count and reset the counter.
Shell code to check current tick count only:
#!/bin/sh
echo 'c' > /dev/ttyUSB0
ticks=$(head -n 1 /dev/ttyUSB0)
echo "ticks:$ticks"
Shell code to read current tick count and reset the counter:
#!/bin/sh
echo 'd' > /dev/ttyUSB0
ticks=$(head -n 1 /dev/ttyUSB0)
echo "ticks:$ticks"
Arduino code for Arduino Nano V3:
int buttonPin = 2;
volatile int buttonCounter = 0;
int buttonState = 0;
int inByte = 0;
void countButtonPresses();
void setup(){
pinMode(buttonPin, INPUT);
Serial.begin(9600);
buttonState=digitalRead(buttonPin);
attachInterrupt(0,countButtonPresses,FALLING);
}
void loop(){
while(Serial.available()==0){}
inByte = Serial.read();
switch (inByte)
{
case 99:
Serial.println(buttonCounter);
break;
case 100:
Serial.println(buttonCounter);
buttonCounter = 0;
break;
}
}
void countButtonPresses()
{
buttonCounter++;
}

Tags