📚🪛 Arduino library to calibrate and improve ADC measurements with the Raspberry Pi Pico.

Overview

Arduino-Pico-Analog-Correction

arduino-library-badge latest version issues open pr

Arduino library to calibrate and improve ADC measurements with the Raspberry Pi Pico. Can compensate ADC offsets, calculate the arithmetic mean of any number of measurements and temporarily disable the power-saving mode when analog-reading to improve the power supply ripple and noise.

This library is also available in the Arduino IDE, see Arduino Library List.

Using

You can use the example calibration sketch to grab the calibration values, just follow the instructions given in the sketch.

You can serial print the calibration values anytime using this command:

void returnCalibrationValues();

Other than that, you can take non-calibrated and calibrated measurements using the corresponding functions:

int analogRead(size_t pin);
int analogCRead(size_t pin, size_t avg_size=1);

Both of these temporarily disable the power-saving mode to improve noise. Only the second function allows taking an arbitrary number of measurements and returning the arithmetic mean while also using the linear calibration.

Limitations

This library is limited to a very simple linear calibration since there are practically only two trusted voltages available to be measured: GND (0V) and VCC (3.3V). This means that the calibration will ensure that the ADC measures GND as 0 and VCC as 4095 with any value in between beeing distributed linearly within these two.

In addition, as the very helpful Raspberry Pi Pico datasheet suggests, the on-board power supply noise and accuracy are not the best. To get the best results possible, you need to use an external voltage reference. This, however, introduces additonal drawbacks.

(Temporarily) Disabling the power-saving mode of the regulator is therefore a must-have to significantly reduce ripple on the ADC supply and is exactly what this library does independently from the calibration.

More info about the Pico's ADC can be found on this website by @ferret-guy, who did extensive testing to find out the exact specifications.

You might also like...
A run-time C++ library for working with units of measurement and conversions between them and with string representations of units and measurements

Units What's new Some of the CMake target names have changed in the latest release, please update builds appropriately Documentation A library that pr

Lib2 - C/C++ Library for Raspberry Pi Pico

Lib2 - C/C++ Library for Raspberry Pi Pico Description: Lib2 library implements wrapper functions and device driver for Raspberry Pi Pico. With lib2 i

I2C slave library for the Raspberry Pi Pico

I2C slave library for the Raspberry Pi Pico The Raspberry Pi Pico C/C++ SDK has all you need to write an I2C master, but is curiously lacking when it

A dataset containing synchronized visual, inertial and GNSS raw measurements.
A dataset containing synchronized visual, inertial and GNSS raw measurements.

GVINS-Dataset Author/Maintainer: CAO Shaozu (shaozu.cao AT gmail.com), LU Xiuyuan (xluaj AT connect.ust.hk) This repository hosts dataset collected du

This package provides localization in a pre-built map using ICP and odometry (or the IMU measurements).
This package provides localization in a pre-built map using ICP and odometry (or the IMU measurements).

Localization using ICP in a known map Overview This package localizes the lidar sensor in a given map using the ICP algorithm. It subscribes to lidar

Raspberry Pi Pico (RP2040) and Micro-ROS (ROS 2) Integration

The Pico is an amazing microcontroller and I couldn't wait for ROS 2 support or Arduino Core, so here is my approach. Once the Arduino Core for RP2040 is out it will be easier to use micro_ros_arduino.

A laser cut Dreamcast Pop'n Music controller and integrated memory card using the Raspberry Pi Pico's Programmable IO
A laser cut Dreamcast Pop'n Music controller and integrated memory card using the Raspberry Pi Pico's Programmable IO

Dreamcast Pop'n Music Controller Using Raspbery Pi Pico (RP2040) Intro This is a homebrew controller for playing the Pop'n Music games on the Sega Dre

A small arcade game utilizing the Raspberry Pi Pico and 20 arcade buttons!

Pico Light Arcade This is the code for the Pico Light Arcade game that can be seen here: https://twitter.com/ghidraninja/status/1422900329369178113 Ha

The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer
The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-source and can be used with OpenOCD as a general-purpose programmer

pico-probe-programmer The pico can be used to program other devices. Raspberry pi made such an effort. However there is no board yet, that is open-sou

Comments
  • How to fix these version upgrade compile errors?

    How to fix these version upgrade compile errors?

    I upgraded from previous version 1.2.x to latest PicoAnalogCorrection 1.3.0 in Arduino IDE v.2.0.3, which now produces these compile errors:

    <...my .ino file...> Compilation error: call of overloaded 'PicoAnalogCorrection(int)' is ambiguous
    

    as the final error after having produced these errors:

    ...268:55: error: call of overloaded 'PicoAnalogCorrection(int)' is ambiguous  
    268 | PicoAnalogCorrection pico( ANALOG_INPUT_BITS_OF_BOARD );
    
    <...my .ino file...>265:/home/master/Arduino/libraries/PicoAnalogCorrection/PicoAnalogCorrection.h:     30:3: note: candidate: 'PicoAnalogCorrection::PicoAnalogCorrection(size_t, float, size_t, size_t)'
    30 |   PicoAnalogCorrection(size_t adc_res=12, float vref=3.3, size_t gnd_val=0, size_t vcc_val=0);
    
    /home/master/Arduino/libraries/PicoAnalogCorrection/PicoAnalogCorrection.h:29:3: note: candidate: 'PicoAnalogCorrection::PicoAnalogCorrection(size_t, size_t, size_t)'
    29 |   PicoAnalogCorrection(size_t adc_res=12, size_t gnd_val=0, size_t vcc_val=0);
     
    /home/master/Arduino/libraries/PicoAnalogCorrection/PicoAnalogCorrection.h:21:7: note: candidate: 'constexpr PicoAnalogCorrection::PicoAnalogCorrection(const PicoAnalogCorrection&)'
    21 | class PicoAnalogCorrection {
      |       ^~~~~~~~~~~~~~~~~~~~
    /home/master/Arduino/libraries/PicoAnalogCorrection/PicoAnalogCorrection.h:21:7: note: candidate: 'constexpr PicoAnalogCorrection::PicoAnalogCorrection(PicoAnalogCorrection&&)'
    

    Thank you!

    bug good first issue 
    opened by kenneth558 2
Releases(v1.3.1)
Owner
NuclearPhoenix
Everything can be done with a microcontroller!
NuclearPhoenix
Tetris on a Raspberry Pi Pico mounted on a Pimoroni Pico Explorer

PicoTetris Classic Tetris game running on a Raspberry Pi Pico microcontroller. Pico C port by Richard Birkby Original JavaScript implementation - Jake

Richard Birkby 34 Dec 3, 2022
Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack

breakout_rpi_pico Breakout game for Raspberry Pi Pico with Pimoroni Pico Display pack Prebuilt binary (breakout.uf2) is here. To build your own binary

null 19 Oct 15, 2022
Pico-uart-bridge - Raspberry Pi Pico UART-USB bridge

Raspberry Pi Pico USB-UART Bridge This program bridges the Raspberry Pi Pico HW UARTs to two independent USB CDC serial devices in order to behave lik

Álvaro Fernández Rojas 156 Dec 23, 2022
Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5"

Raspberry-PI-PICO-display-RPI35 Prueba del Raspberry PI PICO con un display Raspberry PI TFT 3.5" Con ayuda de la libreria https://github.com/khoih-pr

null 1 Nov 10, 2021
calibrate a Livox LiDAR and a camera

Livox LiDAR-Camera Calibration This method is from the official method of Livox(https://github.com/Livox-SDK/livox_camera_lidar_calibration) It's just

null 10 Nov 24, 2022
ROS package to calibrate the extrinsic parameters between LiDAR and Camera.

lidar_camera_calibrator lidar_camera_calibrator is a semi-automatic, high-precision, feature-based camera and LIDAR extrinsic calibration tool. In gen

Networked Robotics and Sytems Lab 78 Dec 23, 2022
Reading ADC of NodeMCU and sending data to QT Application over UDP

QT-NodeMCU-Application Reading ADC of NodeMCU and sending data to QT Application over UDP The following program should be used to run Lua Script: http

Akif Aydogmus 1 Nov 18, 2021
Arduino API for the Raspberry Pico

Raspberry PI Pico - Arduino API On Friday I was receiving my Raspberry PI Pico and I had the opportunity to play around with it. Actually most of the

Phil Schatzmann 59 Jan 2, 2023
Raspberry Pi Pico Arduino core, for all RP2040 boards

Arduino-Pico Raspberry Pi Pico Arduino core, for all RP2040 boards This is a port of the RP2040 (Raspberry Pi Pico processor) to the Arduino ecosystem

Earle F. Philhower, III 929 Jan 5, 2023
This repository provides the implementation of a ADC real-time viewer for an analog sound sensor.

Real-time sound analysing using microcontroller FRDM-KL25Z Acest cod este realizat pentru o platforma autonoma realizata cu kitul de la NXP care are r

null 5 Jan 20, 2022