Skip to content

Commit 5f3f678

Browse files
committed
ESP32C3: Get analogRead working correctly
Thanks to SimonGAndrews! we need to call it twice to get a decent value on the C3 for some reason! https://forum.espruino.com/conversations/395499/?offset=100#17482163
1 parent 9b3cc7f commit 5f3f678

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
: ESP32C3: Get analogRead working correctly
2+
13
2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
24
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
35
Fix for unexpected power draw on newest batch of Bangle.js devices

targets/esp32/jshardwareAnalog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ int readADC(Pin pin){
145145
#if ESP_IDF_VERSION_MAJOR>=4
146146
// ESP_IDF 4.x - int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw() instead
147147
int value=adc1_get_raw(channel);
148+
#if CONFIG_IDF_TARGET_ESP32C3
149+
// we need to call it twice to get a decent value on the C3 for some reason!
150+
// https://forum.espruino.com/conversations/395499/?offset=100#17482163
151+
value=adc1_get_raw(channel);
152+
#endif
148153
#else
149154
value = adc1_get_voltage(channel);
150155
#endif

0 commit comments

Comments
 (0)