Using an Arduino Nano to sense wind speed

I tried using a Raspberry Pi to count the number of times the Wind Speed Anemometer revolved, but the Pi was unable to keep up.

So I used an Arduino Nano to do the counting.  The Raspberry Pi then looks for the output from the Arduino Nano


volatile byte count;

unsigned int loopcount;

unsigned int maxofcount;
unsigned int araysum;

unsigned int duration;
unsigned long tenseconds;
unsigned long sixtyseconds;

int countarray[6];

void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  attachInterrupt(0, arduino_anemometer, RISING);
  
  tenseconds = millis() + 10000;
  sixtyseconds = millis() + 60000;
  
  //countarray[]= {0,0,0,0,0,0};
  
  loopcount = 0;
  maxofcount = 0;
  Serial.print("Startup\n");
  //printwait();
  count = 0;
}

void loop()
{
  if (millis() > tenseconds) 
    {
      countarray[loopcount] = count;
      loopcount++;
      if (loopcount > 5)
        {
            maxofcount = getIndexOfMaximumValue(countarray, 6); 
            araysum = getSumofArray(countarray, 6);
            Serial.print("Current Count#");
            Serial.print(araysum,DEC);
            Serial.print("#Burst#");
            Serial.print(maxofcount,DEC); 
            Serial.print("#\r");
            
            loopcount = 0;
            sixtyseconds = millis() + 60000;
        }

      //printwait();
      tenseconds = millis() + 10000; 
      count = 0;
      //Serial.print("\n");
    }
  else
     {
        if(millis() < (tenseconds - 20000))
          {
            tenseconds = millis() + 10000;
          }
     } 
}

void arduino_anemometer()
{
  count++;
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
}


void printwait()
  {
      Serial.print("\n");
      Serial.print("                                   Current time - ");
      Serial.print(millis());
      Serial.print("      tenseconds = ");
      Serial.print(tenseconds);
      Serial.print("      sixtyseconds = ");
      Serial.print(sixtyseconds);
  }
  

int getIndexOfMaximumValue(int* array, int size)
  {
    int maxvalue = 0;
    for (int i=0; i<size; i++)
      {
        //Serial.print("\n");
        //Serial.print("              Array Number ");
        //Serial.print(i);
        //Serial.print("  Array value ");
        //Serial.print(array[i]);
        //Serial.print("  Max value ");
        //Serial.print(maxvalue);
  
        if (maxvalue < array[i])
          {
            maxvalue = array[i];
          }
    }
    return maxvalue;
  }

int getSumofArray(int* array, int size)
  {
    int sumofarray = 0;
    for (int i=0; i<size; i++)
      {
        sumofarray = sumofarray + array[i];
      }
    return sumofarray;
  }

MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino $5.95
End Date: Sunday Mar-3-2019 21:22:50 PST
Buy It Now for only: $5.95
5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino
5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino $16.99
End Date: Tuesday Mar-5-2019 10:28:20 PST
Buy It Now for only: $16.99
Arduino Nano V30 ATmega328 5V Micro controller USA seller fast shipping
Arduino Nano V30 ATmega328 5V Micro controller USA seller fast shipping $6.19
End Date: Tuesday Mar-19-2019 2:03:11 PDT
Buy It Now for only: $6.19
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board for Arduino
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board for Arduino $2.82
End Date: Thursday Mar-7-2019 21:40:45 PST
Buy It Now for only: $2.82
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino
MINI USB Nano V30 ATmega328P CH340G 5V 16M Micro controller board Arduino $5.95
End Date: Wednesday Mar-13-2019 17:30:24 PDT
Buy It Now for only: $5.95
USB Nano V30 ATmega168 16M 5V Mini controller CH340G For Arduino
USB Nano V30 ATmega168 16M 5V Mini controller CH340G For Arduino $2.40
End Date: Friday Mar-15-2019 8:27:09 PDT
Buy It Now for only: $2.40
1pcs Nano 30 Controller Board Compatible with For Arduino Nano CH340 USB Driver
1pcs Nano 30 Controller Board Compatible with For Arduino Nano CH340 USB Driver $2.84
End Date: Wednesday Mar-13-2019 18:47:44 PDT
Buy It Now for only: $2.84
5V 16M Nano ATmega168 ATmega328 CH340G V30 Mini USB Board Cable For Arduino
5V 16M Nano ATmega168 ATmega328 CH340G V30 Mini USB Board Cable For Arduino $2.72
End Date: Sunday Mar-10-2019 19:56:35 PDT
Buy It Now for only: $2.72
5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino
5Pcs USB CH340G Nano V30 16M 5V ATmega328P Micro Controller Board For Arduino $16.99
End Date: Friday Mar-22-2019 9:25:37 PDT
Buy It Now for only: $16.99
Arduino Nano Mini USB Bootloader For Arduino Nano 30 CH340C ATMEGA328P MU
Arduino Nano Mini USB Bootloader For Arduino Nano 30 CH340C ATMEGA328P MU $3.98
End Date: Sunday Mar-3-2019 13:33:07 PST
Buy It Now for only: $3.98

« Previous12345...910