Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong ADC Vref divisor for MKS TinyBee #23903

Merged
merged 3 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Marlin/src/HAL/ESP32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,15 @@ void MarlinHAL::adc_init() {
}
}

#ifndef ADC_REFERENCE_VOLTAGE
#define ADC_REFERENCE_VOLTAGE 3.3
#endif

void MarlinHAL::adc_start(const pin_t pin) {
const adc1_channel_t chan = get_channel(pin);
uint32_t mv;
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
adc_result = mv * 1023.0 / 3300.0;
adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f;

// Change the attenuation level based on the new reading
adc_atten_t atten;
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/pins/esp32/pins_MKS_TINYBEE.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
//#define E0_AUTO_FAN_PIN 148 // need to update Configuration_adv.h @section extruder
//#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder

//
// ADC Reference Voltage
//
#define ADC_REFERENCE_VOLTAGE 2.5 // 2.5V reference VDDA

//
// MicroSD card
//
Expand Down