Notifications
Clear all

AnalogRead from Raspberry Pi Pico in Arduino IDE


BabaG
(@babag)
Active Member
Joined: 5 months 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)
Noble Member
Joined: 2 years ago
Posts: 2262
 

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.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@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 liked
ReplyQuote
BabaG
(@babag)
Active Member
Joined: 5 months ago
Posts: 5
Topic starter  

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


Ron liked
ReplyQuote
frogandtoad
(@frogandtoad)
Noble Member
Joined: 3 years ago
Posts: 1213
 

@babag

Posted by: @babag

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

No worries, glad you got it working.


ReplyQuote