Skip to content

External Vref #574

May 5, 2022 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I think you'll need to do it using the raw Pico-SDK calls and adjust the formula accordingly.

You can use the routine in core as a template:

extern "C" float analogReadTemp() {
CoreMutex m(&_adcMutex);
if (!m) {
return 0.0f; // Deadlock
}
if (!adcInitted) {
adc_init();
}
adc_set_temp_sensor_enabled(true);
delay(1); // Allow things to settle. Without this, readings can be erratic
adc_select_input(4); // Temperature sensor
int v = adc_read();
adc_set_temp_sensor_enabled(false);
float t = 27.0f - ((v * 3.3f / 4096.0f) - 0.706f) / 0.001721f; //

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@NuclearPhoenixx
Comment options

@NuclearPhoenixx
Comment options

@earlephilhower
Comment options

@NuclearPhoenixx
Comment options

Answer selected by NuclearPhoenixx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants