Power meter sensor from BTE16-18 & Arduino Nano V3
Description
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) <H1>Connections:</H1> 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. <H1>Shell Code To Check Current Tick Count Only:</H1> \#!/Bin/Sh Echo 'C' > /Dev/Ttyusb0 Ticks=$(Head -N 1 /Dev/Ttyusb0) Echo "Ticks:$Ticks" <H1>Shell Code To Read Current Tick Count And Reset The Counter:</H1> \#!/Bin/Sh Echo 'D' > /Dev/Ttyusb0 Ticks=$(Head -N 1 /Dev/Ttyusb0) Echo "Ticks:$Ticks" <H1>Arduino Code For Arduino Nano V3:</H1> 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++; }
Statistics
Likes
10
Downloads
0