Show Posts
Pages: [1] 2 3 ... 6
1  Community / Exhibition / Gallery / Re: Read the itron 100g dl gas meter on: March 25, 2014, 07:33:27 am
sorry never got a notice - this is late but you never know

the gear blocks the beam - so the analog reading  varies with the position of the cam

yes duct tape - blocks or limits the amount of light that the sensor see's - noon with full sun would get lots of false readings

but having a slow moving filter varying sunlight conditions didn't trigger false readings

gasFilterL += .01 * (gasReading-gasFilterL);

so if your current gasFilterL was 700 and then you get a bright spot and read 300 your new reading is lowed by .04

if you used an unfiltered value the 400 delta would have triggered a count
2  Using Arduino / Networking, Protocols, and Devices / Re: Wifi smart phone mac address capture on: January 15, 2013, 03:06:42 pm
http://blog.spiderlabs.com/2012/12/wardrive-raspberry-pi-style.html

I came acesss that the other day - used a pi and kismet

Also check out this company

http://euclidanalytics.com/product/

Able to log Mac address and signal levels to figure out if people walk by or into the store.


3  Using Arduino / Project Guidance / Re: Reading your smart meter? on: January 08, 2013, 10:34:41 pm
I have the same meter cl200

I got a simple IR from radio shack and used software to filter - mine is in direct sunlight - used duck tape to make a shield.

been running for 2 years - total error rate is .25% over that time rate - varies month to month most of the time about .5% and max about 3.5% - as I don't know what time the read it I always use 12 noon from my readings.

on a side topic - this month it all got discounted as I had to pull my meter to replace a main breaker that was over heating (and not tripping) and filling the house with a dead squirrel/fish type of smell. I'm guessing the anti what ever works because the power company came out and pulled all my stuff off the meter. When I pulled the meter it all came a part on me - the clear plastic twists off and the gray cover is only held on with some tabs also came off with out trying. I didn't push the (what looked like a reset) button under it all.... i should have taken't pictures but at the time was only trying to get the power off to replace the meter so my home wouldn't burn down

anyways here's my code - the odd filtering is to try and account for different sunlight levels then reading the meter.

Code:
unsigned long powerCount = 0;
unsigned long powerCountLast = 0;
unsigned long powerLastBlink = 0;
unsigned long powerK5count =0;
unsigned long powerW1=0;
unsigned long powerW2=0;
unsigned long powerW3=0;
unsigned long powerW4=0;
unsigned long powerW5=0;

float powerBlinkLength = 80;
float powerBlinkRate = 200;
int powerBlinkFlag = 1;
float powerFilterR = 600;
float powerFilterH = 600;
float powerFilterC = 600;
float powerMaxL = 1;
float powerMaxH = 0;
int powerReading = 0;

void PowerLoop() {
 
  powerReading = analogRead(power_input);
  powerFilterR += .55 * (powerReading-powerFilterR);
  powerFilterH += .01 * (powerReading-powerFilterH);
  powerFilterC += .9 * (powerReading-powerFilterC);
 
  if (powerFilterC/powerFilterH < powerMaxL) powerMaxL = powerFilterC/powerFilterH;
  if (powerFilterC/powerFilterH > powerMaxH) powerMaxH = powerFilterC/powerFilterH;
 
  serialPrint();
 
  if ((powerFilterC/powerFilterH <.9 && powerBlinkFlag ==1 && millis()-powerLastBlink > 50) || powerLastBlink > millis())
  {
      powerBlinkFlag = 0;
      powerCount++;
      float rate = millis()-powerLastBlink;
      if(rate>0) powerBlinkRate += .05 *(rate-powerBlinkRate);
      powerLastBlink = millis();   
  }
  else if (powerFilterC/powerFilterH > 1.01 && powerBlinkFlag == 0)
  {
    if ( millis()-powerLastBlink > 30|| powerLastBlink > millis()){
      float rate = millis()-powerLastBlink;
      if (rate>0) powerBlinkLength +=  .05*(rate-powerBlinkLength);
      powerBlinkFlag = 1;
    }
  }
 unsigned long w = millis() - lastconnect;
 
 if ( w < 60000) { powerW1 = powerCount; }
 else if (w < 120000) { powerW2 = powerCount; }
 else if (w < 180000) { powerW3 = powerCount; }
 else if (w < 240000) { powerW4 = powerCount; }
 else if (w < 300000) { powerW5 = powerCount; }
}
4  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: November 14, 2012, 07:57:27 pm
that's great!
5  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 31, 2012, 05:22:43 pm
Current is the issue

Use a 10k to protect

Also try a zero valve for the denounce to see if that's the issue
6  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 30, 2012, 07:01:04 pm
stop before you damage your input pin - forget my code and the meter

start here!

http://www.ladyada.net/learn/arduino/lesson5.html

after you master lesson5

you need to wire the meter up like a switch with a resistor


7  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 29, 2012, 05:18:45 pm
Sorry - I cut and pasted my code because it had other stuff in it. Here's the complete code unedited. I'm using ide version 18.

Code:
// Synchronization loop for long intervals (more than 32 seconds)
#define TimeLapLong(t1) (long)((unsigned long)millis()-(unsigned long)t1)
#define TimeLapWord(t1) (int)((word)millis()-(word)t1)
const long WATER_DEBOUNCE = 50;
const long LIGHTNING_1 = 250;
const long LIGHTNING_2 = 500;
const long TIME_SEND = 10000;
const long TIME_CLICK = 60000;

const int lightning_pin = 2;
const int errorCt = 50;

const int water_pin = 4;

unsigned long waterTotal = 0;

int waterLastRead = LOW;

unsigned long waterHit = 0;
//unsigned int waterDebounce = 50;

#define OUTBUFFER_SIZE 300

char outbuffer[OUTBUFFER_SIZE+1];
int outbufferIdx = 0;

unsigned long updatesSince = 0;

unsigned int lightning=0;
unsigned long lightning10=0;
unsigned long lightningTotal=0;
unsigned long lightningTotal60=0;
unsigned int lightning60[60];
unsigned int lightningPos = 0;
unsigned long lightningAttach1 = 0;
unsigned long lightningAttach2 = 0;

unsigned int water5[5];

void setup(){
  
  pinMode(lightning_pin, INPUT);
  digitalWrite(lightning_pin,HIGH);
  for(int x = 0;x<60;x++) lightning60[x] = 0;
  
  pinMode(water_pin,INPUT);
  digitalWrite(water_pin,HIGH);
  waterLastRead = digitalRead(water_pin);
  for(int x = 0;x<5;x++) water5[x] = 0;
  
  Serial.begin(115200);
}


int interupoff = 1;
int swappedState = 1;

unsigned long timetosend =0;
unsigned long timeclick=0;
//unsigned long timetoattach=0;


void loop()
{
  
  //if (digitalRead(water_pin) != waterLastRead &&  (millis()-waterHit) > waterDebounce ) {
    if (digitalRead(water_pin) != waterLastRead &&  TimeLapWord(waterHit) >=0 ) {
waterTotal++;
    waterLastRead = !waterLastRead;
    waterHit = millis() + WATER_DEBOUNCE; //millis();
 }
  
  int dRead = digitalRead(lightning_pin);

  //Serial.println(dRead);

  //if (swappedState == 0 && interupoff == 0 && dRead == 1 && (millis() - timetoattach) > 250) swappedState = 1;
  if (swappedState == 0 && interupoff == 0 && dRead == 1 && TimeLapWord(lightningAttach1)) swappedState = 1;
  
   if (interupoff == 1) {
     if ( dRead == 0) {
       lightningAdd();
     }
} else if(TimeLapWord(lightningAttach2) && swappedState == 1){
  
      interupoff = 1;
   }
    
    //if(millis() - timeclick > 60000) {
      if(TimeLapLong(timeclick)>=0) {
        timeclick += TIME_CLICK; //millis();
        
        for(int x = 0;x<4;x++) water5[x] = water5[x+1];
        water5[4] = waterTotal;
        
        lightningTotal60 = 0;
        lightning60[lightningPos]=lightning;

        for(int x = 0;x<60;x++) {
          if (lightning60[x] < errorCt) lightningTotal60 += lightning60[x];
        }
        
        lightning10=0;
        int z;
        for(int x = 0;x<10;x++) {
          z = lightningPos - x;
          if (z<0) z += 60;
          if (lightning60[z] < errorCt) lightning10 += lightning60[z];
        }
      
        lightningPos++;
        if (lightningPos>59) lightningPos = 0;

        lightning = 0;
    }
    
    //if(millis() - timetosend > 10000)   // 10000 every 10 seconds
    if(TimeLapWord(timetosend)>=0)
    {
      timetosend += TIME_SEND; //millis(); // += 10000; //millis();
      
      outbufferIdx = 0;
          
      OutTitle('T','0');
      OutBufferPrint(0,lightning,1);
      
      OutTitle('T','t');    
      OutBufferPrint(1,lightningTotal,1);

      OutTitle('T','l');
      if (lightning < errorCt) {
        OutBufferPrint(2,lightning10 + lightning,1);
      } else {
        outbuffer[outbufferIdx++] = '0';
      }
      
      OutTitle('T','6');
      if (lightning < errorCt) {
        OutBufferPrint(2,lightningTotal60 + lightning,1);
      } else {
        outbuffer[outbufferIdx++] = '0';
      }
      
      OutTitle('H','0');
      OutBufferPrint(1,waterTotal,1);
      
      OutTitle('H','5');
      OutBufferPrint(1,waterTotal-water5[0],1);
      
      OutTitle('T','u');
      OutBufferPrint(3,updatesSince,1000);
      updatesSince++;

      OutTitle('T','i');
      
      for (int x=0;x<60;x++){
        int v = (int)lightning60[x];
          if (v>9) Out('.');
          if (x == lightningPos) Out('>');
          OutBufferPrint(4,v,1);
          if (v>9) Out('.');
      }
            
      Out(':');
      //OutBufferPrint(5,millis(),1);
      //Out(':');
      //OutBufferPrint(6,millis()- timeclick,1);
      //Out(':');
      //OutBufferPrint(7,dRead,1);
      //Out(':');
      OutBufferPrint(8,outbufferIdx,1);
      outbuffer[outbufferIdx++] ='\n';
      outbuffer[outbufferIdx++] ='\0';
      
      Serial.println(outbuffer);  
    }
  }
  
void OutTitle(char c1, char c2)
{
  if (outbufferIdx < OUTBUFFER_SIZE -4) {
    outbuffer[outbufferIdx++] = '[';
    outbuffer[outbufferIdx++] = c1; //'T';
    outbuffer[outbufferIdx++] = c2;
    outbuffer[outbufferIdx++] = ']';
  }
}
void Out(char c)
{
  if (outbufferIdx < OUTBUFFER_SIZE -1) {
  outbuffer[outbufferIdx++] = c;
  }
}
void OutBufferPrint(int id, unsigned long reading,unsigned long  i) {
  unsigned long temp;
  
  //if (id > 10){
  //  outbuffer[outbufferIdx++] = 48+(id/10);
   // id -= (id/10)*10;
  //}
  
  //outbuffer[outbufferIdx++] = ',';
  
  while (i*10 <= reading){
   i*=10;
  }
  
  while (i>0){
    if (outbufferIdx >= OUTBUFFER_SIZE -1) break;
     temp = reading/i;
     reading -= temp * i;
     outbuffer[outbufferIdx++] = 48+temp;
     i/=10;
    }
}  

void lightningAdd()
{
  //timetoattach = millis();
  lightningAttach1 = millis() + LIGHTNING_1;
  lightningAttach2 = millis() + LIGHTNING_2;
  interupoff = 0;
  swappedState = 0;
  lightning++;
  lightningTotal++;
}

//int freeRam1 () {
//  extern int __heap_start, *__brkval;
//  int v;
//  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
//}




8  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 28, 2012, 07:48:19 pm
I'm using the red and blue wires - the other two wires I believe are use for the taper protection feature. I don't have them connected.

this is what I do - poll the water  meter - track 5 minutes and total counts - send out the serial every 10 seconds

Code:
// Synchronization loop for long intervals (more than 32 seconds)
#define TimeLapLong(t1) (long)((unsigned long)millis()-(unsigned long)t1)
#define TimeLapWord(t1) (int)((word)millis()-(word)t1)
const long WATER_DEBOUNCE = 50;
const long TIME_SEND = 10000;
const long TIME_CLICK = 60000;
const int water_pin = 4;
unsigned long waterTotal = 0;
int waterLastRead = LOW;
unsigned long waterHit = 0;
unsigned int water5[5];
unsigned long timetosend =0;
unsigned long timeclick=0;

void setup(){
 
  pinMode(water_pin,INPUT);
  digitalWrite(water_pin,HIGH);
  waterLastRead = digitalRead(water_pin);
  for(int x = 0;x<5;x++) water5[x] = 0;
 
  Serial.begin(115200);
}

void loop()
{
    if (digitalRead(water_pin) != waterLastRead &&  TimeLapWord(waterHit) >=0 ) {
waterTotal++;
        waterLastRead = !waterLastRead;
        waterHit = millis() + WATER_DEBOUNCE; //millis();
    }

if(TimeLapLong(timeclick)>=0) {
        timeclick += TIME_CLICK; //millis();
       
        for(int x = 0;x<4;x++) water5[x] = water5[x+1];
        water5[4] = waterTotal;
}

// 10000 every 10 seconds
    if(TimeLapWord(timetosend)>=0)
    {
      timetosend += TIME_SEND; //millis(); // += 10000; //millis();
      outbufferIdx = 0;

      OutTitle('H','0');
      OutBufferPrint(1,waterTotal,1);
     
      OutTitle('H','5');
      OutBufferPrint(1,waterTotal-water5[0],1);

      outbuffer[outbufferIdx++] ='\n';
      outbuffer[outbufferIdx++] ='\0';
     
      Serial.println(outbuffer); 

      }
}

void OutBufferPrint(int id, unsigned long reading,unsigned long  i) {
  unsigned long temp;
 
  while (i*10 <= reading){
   i*=10;

  while (i>0){
    if (outbufferIdx >= OUTBUFFER_SIZE -1) break;
     temp = reading/i;
     reading -= temp * i;
     outbuffer[outbufferIdx++] = 48+temp;
     i/=10;
    }

  }
9  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 28, 2012, 09:52:38 am
You need "water meter couplings" do a search on google and you will see what they look like.

See one of my comments above - they cost about $18 for a pair of them. I when too a plumbing supply place (the big box stores aren't going to have them). You should be able to find them on eBay.

Polling every 30 seconds is not going to work you will miss pulses - could use an interrupt to catch the pulses.

10  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: October 26, 2012, 10:58:04 pm
I can't recall if I found a doc or just tried different pairs - I've had mine running for 11 months - so I'll check out the color pair that I wired up and post back in the next day or so.
11  Using Arduino / Sensors / Re: HOw to detect the flow of water through a pipe on: September 25, 2012, 08:09:29 am
I got really lucky on ebay and got a new elster amco meter v-100 3/4" for $15 including shipping. It cost me an additional $18 for the couplings that I sourced at the local plumbing supply house - I tried to get the couplings online - but couldn't really find any thing that much cheaper based on not knowing actually what would work. 

This type of meter is simple pulse and I'm using it for whole house water count.

A quick search on ebay (just now) I found a buy it now for about $46 with shipping.



12  Using Arduino / Programming Questions / Re: Energy monitor -- code quality on: May 03, 2012, 09:15:45 pm
What I do is use a plug/small nas computer that polls my ardunio every 5 min. That way the ardunio doesn't need to know the time. The ardunio just keeps a count of the number of pulses and passes it on and then resets the count. I also do an internal 1 min count for each of the 5 minutes and pass that along too. The small plug computer save the data to a txt file and also to pachube
13  Using Arduino / Sensors / Re: Using optical mouse sensor to measure velocity on: April 26, 2012, 09:11:59 pm
put a vane(??) in the tube - based on length of vane seen in sensor = v
you would have to test different v's to get length...

never-mind - I reread your post - sand not water - sorry!
14  Using Arduino / Interfacing w/ Software on the Computer / Re: Serial Comunication On Linux, compiled on Windows on: January 10, 2012, 08:41:23 am
I use picocom to set the don't reset on disconnect (-r) and to set the serial rate (-b 115200)
picocom -r -b 115200 /dev/ttyUSB0

and head to get my output

I call a bash script every five minutes to read, clean up, write and post to pachube

Code:
#!/bin/sh
FILEDATE="`date +%Y%m`"
FILEOUT="/etc/lgt-$FILEDATE.log"
DATE="`date +%Y%m%d%H%M%S' '%d-%b-%Y' '%T`"
USBOUT="`/opt/bin/head -n2 /dev/ttyUSB0`"
#echo "$DATE"
echo "$DATE $USBOUT" | tr -d '\n' >> $FILEOUT
T6="`echo $USBOUT | tr -d '\n' | cut -d "]" -f 5 | cut -d "[" -f 1`"
curl --request PUT --header "X-PachubeApiKey: xxxxxx"  --data "23,$T6" "api.pachube.com/v2/feeds/xxxx.csv"
echo "$T6"
exit 0


15  Using Arduino / Project Guidance / Re: Making my own solenoid on: December 05, 2011, 10:36:16 am
ok - how about a cam some thing like: http://en.wikipedia.org/wiki/Scotch_yoke
Pages: [1] 2 3 ... 6