Skip to content

Commit

Permalink
Correct ADC Vref divisor for MKS TinyBee
Browse files Browse the repository at this point in the history
MKS TinyBee uses a 2.5V VDDA ADC reference instead of the more common 3.3V.  2500.0 = 2.5V.
Board uses a Zener diode - measuring the actual voltage on any disconnected thermistor pin and using that value ( x 1000) will improve precision.
  • Loading branch information
HoverClub committed Mar 14, 2022
1 parent 63c2965 commit 931fd6b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Marlin/src/HAL/ESP32/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,12 @@ 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;

#if MB(MKS_TINYBEE)
adc_result = mv * 1023.0 / 2500.0; // TinyBee uses 2.5v VDDA ref
#else
adc_result = mv * 1023.0 / 3300.0;
#endif

// Change the attenuation level based on the new reading
adc_atten_t atten;
if (mv < thresholds[ADC_ATTEN_DB_0] - 100)
Expand Down

0 comments on commit 931fd6b

Please sign in to comment.