.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"}

I’m thrilled to announce that my upcoming course, Introduction to Electronics, is just a few weeks away from being released on both Udemy and Tech Explorations. This course was designed with the absolute beginner in

Read More
New Course Coming soon: Introduction to Electronics

Robotics is one of the most engaging and effective ways to teach programming, problem-solving, and critical thinking. Today, we’re diving into the CrowBot Bolt, a programmable robot car explicitly designed for STEAM (Science, Technology, Engineering,

Read More
Exploring the CrowBot Bolt: A Hands-On Robotics Kit for STEAM Education