LMIC-node with Adafruit ADS1115 adc1 lock error

Hello, I am trying to use the Adafruit ADS1115 with the platformIO example “LMIC-node”.

I have properly included the library

#include "Adafruit_ADS1X15.h"

Adafruit_ADS1115 ads;

I also tried to initialize the ADS

//  █ █ █▀▀ █▀▀ █▀▄   █▀▀ █▀█ █▀▄ █▀▀   █▀▄ █▀▀ █▀▀ ▀█▀ █▀█
//  █ █ ▀▀█ █▀▀ █▀▄   █   █ █ █ █ █▀▀   █▀▄ █▀▀ █ █  █  █ █
//  ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀   ▀▀▀ ▀▀▀ ▀▀  ▀▀▀   ▀▀  ▀▀▀ ▀▀▀ ▀▀▀ ▀ ▀


// Place code for initializing sensors etc. here.
Serial.begin(115200);
ads.setGain(GAIN_FOUR);
    if (!ads.begin()) {
       Serial.println("Failed to initialize ADS.");
       while (1);
    }
ads.startComparator_SingleEnded(0, 1000);

In the serial monitor window I get the error message

Failed to initialize ADS.

I also get this message in the serial monitor window at the very top.

E (140) ADC: adc1_lock?��*���͕�419): adc1 lock release called before acquire

I think this may be an I2C issue but im not sure.

Your post lacks essential details.
What board are you using?
Where is the rest of the serial output?

Hint: Have you checked if the Adafruit library uses the correct I2C pins for your board?

The board I am using is the Heltec WiFi LoRa23 (V2) and yes, the Adafruit library uses the correct I2C pins for this board. I’ve used the same type of board and ADS1115 in an Arduino sketch and got no issues initializing the ADS1115. I’ve only run into this issue using this example in PlatformIO.

Serial monitor output below:

--- Terminal on COM3 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
b (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:12784
load:0x40080400,len:3032
entry 0x400805e4
E (158) ADC: adc1_lock�f�␖��͕�419): adc1 lock release called before acquire


LMIC-node

Device-id:     wifi-lora-32-v2
LMIC library:  MCCI
Activation:    OTAA
Interval:      60 seconds     

Failed to initialize ADS.

Why are you calling this? LMIC-node already does.
It benefits to read the documentation.

My gut feeling says you have an I2C issue.

Have a look at file bsf_heltec_wifi_lora_32_v2.h for info about the board’s I2C pins.
Run an I2C scan sketch to see if the ADS is detected on the I2C bus. You can find an example here: i2c-scan-test
It was written for an ESP8266 so you may need to tweak a few lines.

Be aware that the SCL and SDA pins are defined incorrectly (in the standard Arduino core) for your board. This is documented in above file.

Then have a look at ads.begin() in the ADS library source code and verify that it uses the correct I2C pins.