Cannot Use ADC2 For BLE Data Transfer (PlatformIO)

Ukaton
Posts: 5
Joined: Sat Sep 14, 2019 5:46 am

Cannot Use ADC2 For BLE Data Transfer (PlatformIO)

Postby Ukaton » Sat Sep 14, 2019 6:05 am

I'm working on a https://hackaday.io/project/165333-miss ... mission-st and I'm running into an issue with data transfer between a BLE scanner iOS app and the sensors attached to my ESP32. I've been trying to read pressure sensor values on ADC2 GPIOs while BLE is enabled, but all the pins on ADC2 read high (e.g. 0xffff...ff). When I don't use BLE to read ADC2 GPIOs, I can read them just fine through a Serial connection. The only GPIOs I can read using BLE are those on ADC1, which are GPIOs 32, 33, 34, 35, 36, and 39.

Is there any way to make it so that the GPIOs on ADC2 can be read using BLE? Has anyone else run into this issue? I know there are known issues with reading GPIOs on ADC2 while WiFi is enabled, but not necessarily when BLE is enabled. I have tried to turn off WiFi during setup, but including the WiFi.h library makes the binary too large since BLE's library is already massive as is. Below is some super basic GPIO pin polling/reading. If I'm doing something critically wrong, please let me know! Thank you!

Code: Select all

// main.cpp
#ifdef ENABLE_BLUETOOTH
  #include "ble.h"
#endif

#include "sensor.h"
#include "helpers.h"

void setupBluetoothPins() 
{
  for (int i = 0; i < pcbSensorCount; i++) 
  {
    pinMode(pcbPins[i], OUTPUT);
  }
}

void bluetoothSensorLoop()
{
  for (int i = 0; i < pcbSensorCount; i++)
  {
    uint8_t val = analogRead(pcbPins[i]);
    pcbSensors[i] = (uint8_t)val;
  }
  setSensorCharacteristic(pcbSensors, pcbSensorCount*sizeof(uint8_t));
}

void loop()
{
 while(true) {
   bluetoothSensorLoop();
   delay(300);
  }
}

void setup() 
{
  // put your setup code here, to run once:
  setupPins();

  Serial.begin(115200);
  #ifdef ENABLE_BLUETOOTH
    setupBLE();
  #endif
}

dandaman72
Posts: 2
Joined: Tue Sep 01, 2020 12:29 pm

Re: Cannot Use ADC2 For BLE Data Transfer (PlatformIO)

Postby dandaman72 » Tue Sep 01, 2020 9:41 pm

Hey Ukaton,

I know this was a year ago but did you figure this out? I am having the same problem.

Thanks!

Who is online

Users browsing this forum: No registered users and 53 guests