Frequency Counter library for atmega32u4

The guys at KHM in Cologne cooked up a very handy Frequency Counter library for arduino.  Seeing as my humidity sensor is based around the HCH1000, basically a variable capacitor, one simple way to measure the humidity is to use the sensor in an oscillator, and use the output frequency as an indicator of the humidity.  (I really need to get around to writing that up properly, it’s in progress, I promise)

Anyway, I have more boards than just an Arduino, and I also use mostly raw C.  So I’ve update the library to work with either the atmega 168 or 328 on arduino boards, but also with the atmega32u4 found on PJRC’s nifty little Teensy boards

You can get the code over on github (You need FreqCounter.c and .h)

  1. Hi KarlP,

    I’ve arduino micro with ATmega32u4. I get your library and upload this sketch

    #include  
    void setup(){
     Serial.begin(57600);
     pinMode(x, INPUT);  // what pin ?
    }
    long int frq
    void loop(){
     f_comp= 8;
     FreqCounter__start(f_comp, 100);
     frq = blockingRead(f_comp, 100);
     Serial.println(frq);
     delay(50);
    }

    what is the frequency input pin on arduino micro board ? I’ve tried all digital pin but I’m not able to read frequency but I might be wrong.
    Do you have any suggestion ? thank you

  2. Firstly, this is not an arduino library. You need to use the pin connected to Timer1 input. “T1” it is often called. But again, this is nto an arduino library.

  3. oh now i understand why i cant compile it, its not an arduino library…

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>