ArduinoCore-nRF528x-mbedos icon indicating copy to clipboard operation
ArduinoCore-nRF528x-mbedos copied to clipboard

More than 3 concurrent BLE Connections (Arduino Nano 33 BLE)

Open Dorsel89 opened this issue 5 years ago • 12 comments

Hi everyone, I would like to have more than 3 concurrent BLE connections with the Arduino Nano 33 BLE. As far as i understand i have to adjust the DM_CONN_MAX in cfg_stack.h.

Unfortunately, that doesn't work, do you have any tips on what I'm doing wrong? Thanks and kind regards!

Dorsel89 avatar Dec 18 '19 08:12 Dorsel89

Hello @dhalbert , i modified your text and it seems to be working :

void setup() 
{
Serial.begin(9600);
pinMode(A0, INPUT);
}

void loop() {
  // Attach A0 to 3.3V through a 220K or other high-value resistor,
  // so it's not stronger than the driven output.

 delay(100);
  Serial.println(analogRead(A0));



delay(100);
  Serial.println("Done");

}

the problem is still the same with touchsceen... but i'm wondering if it's not just about a pins definition problem ?

MattGlobal avatar Jan 25 '24 16:01 MattGlobal

@MattGlobal In the example you gave, there is no pinMode() between analogRead() calls. In my example, the pin usage alternates between pinMode() and analogRead(). My hypothesis is that the second call to analogRead() is assuming the pin is already set up where as in fact its settings where changed "behind the back" of analogRead().

dhalbert avatar Jan 26 '24 14:01 dhalbert

Here is the impl: https://github.com/arduino/ArduinoCore-mbed/blob/68fbece79947ce2a64bf49f7ba5f5f8111d89454/cores/arduino/wiring_analog.cpp#L101-L121 The first time through, a new mbed::AnalogIn object is created. That's reused on subsequent calls.

A workaround might be to call analogUpdate() before every call to analogRead(). I'll try that. (EDIT: ANALOG_CONFIG isn't defined, so analogUpdate() is not included, so it requires some surgery in the sources, which is not a clean workaround for the average user.) But there's an assumption being made in the code in this file that the pin state is not changing out from under analogRead().

dhalbert avatar Jan 26 '24 14:01 dhalbert