Browse Source

🐛 MKS TinyBee - 2.5V ADC Vref (#23903)

John Robertson 3 years ago
parent
commit
653c847bfb
No account linked to committer's email address
2 changed files with 10 additions and 1 deletions
  1. 5
    1
      Marlin/src/HAL/ESP32/HAL.cpp
  2. 5
    0
      Marlin/src/pins/esp32/pins_MKS_TINYBEE.h

+ 5
- 1
Marlin/src/HAL/ESP32/HAL.cpp View File

229
   }
229
   }
230
 }
230
 }
231
 
231
 
232
+#ifndef ADC_REFERENCE_VOLTAGE
233
+  #define ADC_REFERENCE_VOLTAGE 3.3
234
+#endif
235
+
232
 void MarlinHAL::adc_start(const pin_t pin) {
236
 void MarlinHAL::adc_start(const pin_t pin) {
233
   const adc1_channel_t chan = get_channel(pin);
237
   const adc1_channel_t chan = get_channel(pin);
234
   uint32_t mv;
238
   uint32_t mv;
235
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
239
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
236
-  adc_result = mv * 1023.0 / 3300.0;
240
+  adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f;
237
 
241
 
238
   // Change the attenuation level based on the new reading
242
   // Change the attenuation level based on the new reading
239
   adc_atten_t atten;
243
   adc_atten_t atten;

+ 5
- 0
Marlin/src/pins/esp32/pins_MKS_TINYBEE.h View File

114
 //#define E1_AUTO_FAN_PIN                    149  // need to update Configuration_adv.h @section extruder
114
 //#define E1_AUTO_FAN_PIN                    149  // need to update Configuration_adv.h @section extruder
115
 
115
 
116
 //
116
 //
117
+// ADC Reference Voltage
118
+//
119
+#define ADC_REFERENCE_VOLTAGE                2.5  // 2.5V reference VDDA
120
+
121
+//
117
 // MicroSD card
122
 // MicroSD card
118
 //
123
 //
119
 #define SD_MOSI_PIN                           23
124
 #define SD_MOSI_PIN                           23

Loading…
Cancel
Save