Skip to content

Commit

Permalink
ESP32C3: Get analogRead working correctly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gfwilliams committed Aug 9, 2024
1 parent 9b3cc7f commit 5f3f678
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
: ESP32C3: Get analogRead working correctly

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Fix for unexpected power draw on newest batch of Bangle.js devices
Expand Down
5 changes: 5 additions & 0 deletions targets/esp32/jshardwareAnalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ int readADC(Pin pin){
#if ESP_IDF_VERSION_MAJOR>=4
// ESP_IDF 4.x - int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw() instead
int value=adc1_get_raw(channel);
#if CONFIG_IDF_TARGET_ESP32C3
// 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
value=adc1_get_raw(channel);
#endif
#else
value = adc1_get_voltage(channel);
#endif
Expand Down

0 comments on commit 5f3f678

Please sign in to comment.