ESP32 script hanging on 'adc.readADC_SingleEnded'

Hieronymus
Posts: 1
Joined: Thu May 06, 2021 2:33 pm

ESP32 script hanging on 'adc.readADC_SingleEnded'

Postby Hieronymus » Thu May 06, 2021 2:49 pm

Hi all,

I have an ADS1115 connected to an ESP32 and I would like it to read voltages on the analog ports.

However, any script uploaded to the ESP stops running at the following:

adc.readADC_SingleEnded

No matter whether the ADS1115 is connected to the ESP32 or not and regardless of any other wiring solutions. I also tried different baud rates, different wiring solutions, different USB ports etc. Mostly using a 3.0V cell battery. But it didn't matter, the program just won't run, at least that's how it looks like from the Serial Monitor.

For completeness, here is a sample code ( also tried the example scripts provided in the IDE):

Anyone with ideas please?

cheers

Code: Select all

#include <Wire.h>
#include <Adafruit_ADS1X15.h>
 
Adafruit_ADS1115 adc;

void setup(void) 
{
  
  Serial.begin(115200); 
  adc.begin();
}

void loop(void) 
{
  Serial.print("Test line 1 ");
  float Voltage = 0.0;
  int16_t adc0;  
  adc0 = adc.readADC_SingleEnded(0);// script stops here

  Serial.print("Test line 2 ");// not visible in Serial Monitor
  
  Voltage = (adc0 * 0.1875)/1000;  
  Serial.print("AN0: "); 
  Serial.print(adc0);
  Serial.print("\tVolts: ");
  Serial.println(Voltage,2);   
  delay(1000);
}
Serial Monitor output:

Code: Select all

16:45:01.988 -> ets Jun  8 2016 00:22:57
16:45:01.988 -> 
16:45:01.988 -> rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
16:45:01.988 -> flash read err, 1000
16:45:01.988 -> ets_main.c 371 
16:45:02.360 -> ets Jun  8 2016 00:22:57
16:45:02.394 -> 
16:45:02.394 -> rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
16:45:02.394 -> configsip: 0, SPIWP:0xee
16:45:02.394 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
16:45:02.394 -> mode:DIO, clock div:1
16:45:02.394 -> load:0x3fff0018,len:4
16:45:02.394 -> load:0x3fff001c,len:1216
16:45:02.394 -> ho 0 tail 12 room 4
16:45:02.394 -> load:0x40078000,len:10944
16:45:02.394 -> load:0x40080400,len:6388
16:45:02.394 -> entry 0x400806b4
16:45:02.495 -> Test line 1

lloydburch
Posts: 1
Joined: Wed Sep 15, 2021 6:53 pm

Re: ESP32 script hanging on 'adc.readADC_SingleEnded'

Postby lloydburch » Thu Sep 16, 2021 3:54 am

This can be caused by not having "PullUp" resistors SCL and SDA. From 3K to 5K on each pin to +3.3 should work. I know that the ESP32 has internal PullUps, but I don't think they are active on clock and data.

ESP_Sprite
Posts: 9778
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 script hanging on 'adc.readADC_SingleEnded'

Postby ESP_Sprite » Thu Sep 16, 2021 6:42 am

lloydburch wrote:
Thu Sep 16, 2021 3:54 am
This can be caused by not having "PullUp" resistors SCL and SDA. From 3K to 5K on each pin to +3.3 should work. I know that the ESP32 has internal PullUps, but I don't think they are active on clock and data.
The exact problem actually is that the internal ESP32 pullups aren't really suitable for I2C - they're in the order range of 50K, which is way to high.

wjquigs
Posts: 7
Joined: Fri Aug 11, 2023 9:41 pm

Re: ESP32 script hanging on 'adc.readADC_SingleEnded'

Postby wjquigs » Fri Aug 11, 2023 9:55 pm

Hello,
I'm having the same problem. I tried 5k and 2k resistors between SCL/SDA and +3.3V and that didn't change anything. Any recommendations?
Thanks.
William
2023-08-11 14.53.57.jpg
2023-08-11 14.53.57.jpg (7.97 MiB) Viewed 1687 times

Who is online

Users browsing this forum: No registered users and 30 guests