Notifications
Clear all

AnalogRead from Raspberry Pi Pico in Arduino IDE

5 Posts
3 Users
3 Likes
2,992 Views
(@babag)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

Does anyone have any experience using analogRead with a Raspberry Pi Pico in the Arduino IDE?  I was a bit surprised to see that it returned a value between 0 and 1028.  I was expecting to get values between 0 and 4096 since the Pico has 12 bit ADC's.  Is this just an idiosyncrasy of the Arduino IDE's analogRead that I am going to have to live with or is there some thing I need to set to get the full 12 bit resolution?


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

I think it's 0 to 4095, not 4096.

However,

Raspberry Pi Pico has 3 ADC channels with 12 bit resolution. which should have a sampling rate between 0-4095 but as we are programming the Raspberry Pi Pico with MicroPython we get 16 bit resolution with a sampling rate of 65536(0-65535) because MicroPython ADC library scaled it from 12 bit to 16 bit.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@babag

Posted by: @babag

Does anyone have any experience using analogRead with a Raspberry Pi Pico in the Arduino IDE?  I was a bit surprised to see that it returned a value between 0 and 1028.  I was expecting to get values between 0 and 4096 since the Pico has 12 bit ADC's.  Is this just an idiosyncrasy of the Arduino IDE's analogRead that I am going to have to live with or is there some thing I need to set to get the full 12 bit resolution?

Have you tried setting the Arduino read resolution?
It doesn't mention the Raspberry Pi Pico, but this was probably written before its release:

analogreadresolution function


   
Lee G and Ron reacted
ReplyQuote
(@babag)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

@frogandtoad - that did the trick, thanks for the quick response.


   
Ron reacted
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@babag

Posted by: @babag

@frogandtoad - that did the trick, thanks for the quick response.

No worries, glad you got it working.


   
ReplyQuote