.st0{fill:#FFFFFF;}

Arduino

Found: a bug in analogRead() returns false readings in SAMD21 Arduinos 

 September 4, 2019

By  Peter

Join Our Mailing List

We publish fresh content each week. Read how-to's on Arduino, ESP32, KiCad, Node-RED, drones and more. Listen to interviews. Learn about new tech with our comprehensive reviews. Get discount offers for our courses and books. Interact with our community.

One email per week, no spam, unsubscribe at any time.

Alain Pannetrat recently wrote a blog article in which he shows how he found a bug in the implementation of the Arduino analogRead() function for the SAMD21.

The SAMD21 is used in the Arduino Zero, and in Alain’s Omzlo CANZERO node.

The bug in analogRead() causes the readings on the SAMD21 analog pins to be offset by around 35mV. This is hardly the end of the world, but still a very interesting finding that has real-world implications.

This error will produce incorrect results in any calculations that involve analog readings. Temperature, light, voltage from a battery to calculate available energy, etc.

Alain’s process of finding the source of the error is very interesting. Originally, he theorised that the error can be either in the hardware of the microcontroller, or the implementation of the SAMD21 analogRead() function.

Hardware or software?

More testing was needed, and Alain went on to write his own bare-minimal analogRead function to see exactly what comes out of the microcontorller.

This test showed an accurate voltage measurement from the microcontroller, which meant that the bug seems to be in the software implementation of analogRead.

Nice find Alain!

Read all the details in the Omzlo blog.


Tags

analogRead, bug, SAMD21


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Understanding the power requirements is crucial for any enthusiast using the Arduino Uno in their projects. How you manage voltage, amperage, and power sources impacts the success or failure of your endeavours. In this guide,

Read More
The Ultimate Guide to Powering Your Arduino Uno Board

If you are curious about how electronic devices work, understanding the fundamentals of the operation of their basic components is essential. Every electronic device—from the smartphones in our pockets to the satellites orbiting our planet—contains

Read More
A Guide to Essential Electronic Components in Circuits