Error while compiling for Nano Every Board

Hey guys,

I’m pretty new to coding and arduino overall, but i want to build a simple watering machine for my plants.

The sensors deliver the humidity as frequency, so I’m using the FreqCount library.

So now the problem is, that I have an Arduino Uno, where my code works perfectly, but i want to use a Nano Every. But i can’t find any solution to the error.

Hope someone can help me,
cheers

EDIT: I downloaded the Library using the library Manager, name is “FreqCount” Version 1.3.0 from Paul Stoffregen.

This is my code (basic to test the values the sensors return):

#include <FreqCount.h>

void setup() {
  Serial.begin(9600);
  FreqCount.begin(1000);
}

void loop() {
  if (FreqCount.available()) {
    unsigned long count = FreqCount.read();
    Serial.println(count);
  }
}

And this is the error while trying to upload to my nano:

Arduino: 1.8.9 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\util/FreqCountTimers.h:64:4: error: #error "Unknown chip, please edit me with timer+counter definitions"

   #error "Unknown chip, please edit me with timer+counter definitions"

    ^~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp: In static member function 'static void FreqCountClass::begin(uint16_t)':

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:44:2: error: 'counter_init' was not declared in this scope

  counter_init();

  ^~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:44:2: note: suggested alternative: 'count_ready'

  counter_init();

  ^~~~~~~~~~~~

  count_ready

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:45:16: error: 'timer_init' was not declared in this scope

  gate_length = timer_init(msec);

                ^~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:45:16: note: suggested alternative: 'isprint'

  gate_length = timer_init(msec);

                ^~~~~~~~~~

                isprint

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:48:2: error: 'timer_start' was not declared in this scope

  timer_start();

  ^~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:48:2: note: suggested alternative: 'va_start'

  timer_start();

  ^~~~~~~~~~~

  va_start

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:50:2: error: 'counter_start' was not declared in this scope

  counter_start();

  ^~~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:50:2: note: suggested alternative: 'count_ready'

  counter_start();

  ^~~~~~~~~~~~~

  count_ready

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp: In static member function 'static void FreqCountClass::end()':

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:74:2: error: 'timer_shutdown' was not declared in this scope

  timer_shutdown();

  ^~~~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:75:2: error: 'counter_shutdown' was not declared in this scope

  counter_shutdown();

  ^~~~~~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:75:2: note: suggested alternative: 'count_output'

  counter_shutdown();

  ^~~~~~~~~~~~~~~~

  count_output

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp: In function 'void TIMER_ISR_VECTOR()':

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:85:14: error: 'counter_read' was not declared in this scope

  count_lsw = counter_read();

              ^~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:85:14: note: suggested alternative: 'count_ready'

  count_lsw = counter_read();

              ^~~~~~~~~~~~

              count_ready

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:86:6: error: 'counter_overflow' was not declared in this scope

  if (counter_overflow()) {

      ^~~~~~~~~~~~~~~~

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:86:6: note: suggested alternative: 'count_lsw'

  if (counter_overflow()) {

      ^~~~~~~~~~~~~~~~

      count_lsw

C:\Users\nifew\Documents\Arduino\libraries\FreqCount\FreqCount.cpp:87:3: error: 'counter_overflow_reset' was not declared in this scope

   counter_overflow_reset();

   ^~~~~~~~~~~~~~~~~~~~~~

Bibliothek FreqCount in Version 1.3 im Ordner: C:\Users\nifew\Documents\Arduino\libraries\FreqCount  wird verwendet
exit status 1
Error Compiling for board Nano Every.

As you've discovered, not all libraries are compatible with the Nano Every. The Nano Every uses a relatively new microcontroller (ATmega4809) so most of the existing libraries were not written with this chip in mind. Luckily, Arduino provides a universal API so that libraries that only use high level code can work with any microcontroller. It's the libraries that use low level code where you might have compatibility problems.

In some cases, it could be fairly easy to modify a library to be compatible with the Nano Every. It's possible that someone here on the forum could provide you with some advice for that or suggest an alternative library. It will be necessary for us to be able to look at the library though. Please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded the FreqCount library from. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

Thanks, I already thougt that it isn’t compatible.

There is another library which measures frequency, but unfortunatly it doesn’t cover the range the sensors put out.