1

I'm working on a prototype which uses the RedBearLabs Blend Micro with the NSC's nrf8001 ble chip, but have ran into a problem that I'm not sure how to solve.

I have two tactile buttons connected to the input pins on the Blend Micro, which are used to increase or decrease counters (integers) in my sketch that is in turn displayed on a OLED screen. When I use these buttons to manipulate the counter in offline mode (meaning that the bluetooth is not connected) I can repeatedly press the buttons very quickly and the counter is increased with every push - but when I connect to my phone and try to push the buttons with high frequency (>1-2 per second) the program is not able to react to every button interaction, causing only every second or third click to be registered.

The only thing that I do differently when I am connected is that I'm sending 5 bytes using "ble_write" (part of the RBL nrf8001 library), which seem to cause this delay resulting in missed clicks. Even sending one byte using "ble_write(X)" seem to slow down the sketch so much that this phenomena occurs.

Do any of you had similar problems and possible ways to solve this? I've been considering batching clicks together until I reach a certain amount and then send them at all once - this however may risk that a button is being pressed at the same time as the ble_write is executed, causing missed click.

Offline click looks like this:

if(digitalRead(A4)) {
while (digitalRead(A4)) {        }
offlineIn++;
localIn++;
totCount++;
sleepTimer = 0;
  }

And the online like this:

if (digitalRead(A4)) {
  while (digitalRead(A4)) {        }
  totCount++;
  localIn++;
  sleepTimer = 0;    
  ble_write('0');
  ble_write('0');
  ble_write('0');
  ble_write('1');
  ble_write('1');
}

Thanks!

-1

I've solved it by overclocking my blend micro to 16mhz (done in the Arduino IDE). Not a perfect solution but works. :)

  • This is a bad solution. Likely what you have accomplished is to halve delays intentionally put there to properly operate the BLE. If that works, then you should just be using half delays. – Chris Stratton Nov 18 '16 at 17:52
  • Good point. If I would optimise this I would probably need to look into the libraries used in more detail, but since this actually worked - I'm fine with the results. – Vnu_Filip Nov 22 '16 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.