Send analog read value over ble_write();


#1

This is my code, I want it to send an analog value at a pin on my blend, over BLE. Here is my current code, any ideas on what is wrong would be much appreciated.

#include <SPI.h>
#include <boards.h>
#include <RBL_nRF8001.h>
 
void setup() {
  ble_begin();
  Serial.begin(9600);     
}


void loop() {
  Serial.println(analogRead(A0));                   
  if ( ble_connected() ) {
    ble_write(analogRead(A0));
  }
  ble_do_events();        
  delay(5);                                                        
}

#2

The delay between each loop is so short that the under layer buffer would overflow before BLE sending out all of the data. And the delay should be more than 20ms. Also make sure the RDYN and REQN pins are shorted correctly, or use the ble_set_pins() to specify these pins explicitly.