Autonomo and AirQuality Sensor ISR issues

Hello, I am a new new user to an Autonomo + LoRabee + Grove Shield + AirQuality Sensor.

I’m having an issue with the example given here: because of what I think is an issue of the library and example using an AVR based timer. After researching a few forums including this one: Autonomo internal interupts / timers
I believe I need to get rid of the ISR used in the first example, poll millis() and execute when the time is there.

The only problem is, I’m not sure how to do this. Any help would be greatly appreciated!

Thanks in advance,


Hi Dana,

I had a quick look at that library.
There are a few issues with it as it is.

The first issue is the timer. It sets up a timer based interrupt to take a reading (from an AIN pin) at a fixed interval. That part of the code is incompatible with the SAMD platform as it uses AVR specific registers for the timer setup.

You could setup a SAMD timer interrupt and take the reading when the interrupt is fired. Alternatively, you could just do some scheduling in your loop() method and take a new reading when enough time has elapsed. This might be a good starting point.

Also, the library uses a lot of hard coded values. For example, it is hardcoded to read from pin A0, and it doesn’t give you the option of attaching the device to another AIN pin.

Another issue is that part of the required code is actually only present in the example (the ISR code).

You should also change the debug output to be sent to SerialUSB instead of Serial.

Thank you for the detailed reply Gabriel.

I’ve been busy over the past few days, but hopefully will spend some time this weekend to look at your suggestions. I’ll let you know how it works out :slight_smile:


Hi Gabriel,

I’ve made a few changes to the sketch based on this example:
Just to refresh your memory, I’m using a Sodaq Autonomo, LoRaBEE, Grove Shield, with a Grove AirQuality sensor.

The sketch below (hope a link to my gdrive is ok) shows an error at line 123 where I’m trying to initialize the sensor. I’ve tried to simplify the method by eliminating the timer.

I would love to just get one reading from this sensor, do you have any suggestions?

Best regards,

Link to my sketch:

Could you link to your modified AirQuality.h/cpp files as well.

Thanks for the quick reply Gabriel, here you are. I haven’t modified them though.

That library is not compatible with the SAMD platform (Autonomo, Arduion Zero etc).

It directly uses AVR registers in the init() method.

Ok thanks for the heads up Gabriel.

The reason for my interest in this sensor is that I’m currently developing a workshop for BlueCity 010 at the old Tropicana building. I’m looking to start a project powering this sensor with mycelium, and although we have the energy bit figured out, my knowledge in programming is limited.

Do you know of anyone that could help me configure the cpp files to work with the Autonomo SAMD platform. Additionally, due to the energy requirements of the micro controller, I am looking at integrating your SleepChangeInturrupt sketch to allow the Autonomo, Sensor and LoRaBEE to power down and conserve energy.

If you know of anyone who could help out with the project, I would be super greatful.

Thank you in advance,

Gabriel, is there any way (with your library) to eliminate te timer?