🎁📬❄️📦 Holiday Shipping Deadlines are approaching! International customers and domestic ground - get your orders in 12/9/2020 📦❄️📬🎁
0

Two nRF52 boards having trouble sending data
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Two nRF52 boards having trouble sending data

by TKWEAVERARW on Thu Oct 22, 2020 10:55 am

I have two nRF52840 express feathers. One is the central and one is the peripheral - both are using an only slightly modified version of the examples for central and peripheral.

They connect fine, but I am trying to send data from one to the other -- when the data gets to the peripheral it is messed up.

Basically, I am trying to take a variable going from 1 to 120 at the central and then starting again and send that across bluetooth and have it spit out at the serial port for the peripheral.

Here is the relevant part of the code for CENTRAL and PERIPHERAL and the serial output for the peripheral:

CENTRAL

Code: Select all | TOGGLE FULL SIZE
void loop()
{
 
  if ( Bluefruit.Central.connected() )
  {
    if ( clientUart.discovered() )
    {

pixels++;
delay (400);
if (pixels>120)pixels=1;

 uint8_t data;
 data = uint8_t (pixels);

clientUart.print(data);
     
      }
    }
  }


PERIPHERAL

Code: Select all | TOGGLE FULL SIZE

void loop()
{
 


 
  if ( bleuart.available() )
  {

 uint8_t data;
 data = (uint8_t) bleuart.read();

pixels = int(data);

Serial.println(F("------------------------"));
    Serial.println(F("Incoming data:"));
  Serial.println(pixels);

   
  delay(5);

  }
}

 





SERIAL OUTPUT OF PERIPHERAL:

10:42:23.958 -> Incoming data:
10:42:23.958 -> 54
10:42:24.331 -> ------------------------
10:42:24.331 -> Incoming data:
10:42:24.331 -> 49
10:42:24.364 -> ------------------------
10:42:24.364 -> Incoming data:
10:42:24.364 -> 55
10:42:24.732 -> ------------------------
10:42:24.732 -> Incoming data:
10:42:24.732 -> 49
10:42:24.765 -> ------------------------
10:42:24.765 -> Incoming data:
10:42:24.765 -> 56
10:42:25.138 -> ------------------------
10:42:25.138 -> Incoming data:
10:42:25.138 -> 49
10:42:25.171 -> ------------------------
10:42:25.171 -> Incoming data:
10:42:25.171 -> 57
10:42:25.545 -> ------------------------
10:42:25.545 -> Incoming data:
10:42:25.545 -> 50
10:42:25.578 -> ------------------------
10:42:25.578 -> Incoming data:
10:42:25.578 -> 48
10:42:25.949 -> ------------------------
10:42:25.949 -> Incoming data:
10:42:25.949 -> 50
10:42:25.982 -> ------------------------
10:42:25.982 -> Incoming data:
10:42:25.982 -> 49
10:42:26.353 -> ------------------------
10:42:26.353 -> Incoming data:
10:42:26.353 -> 50
10:42:26.386 -> ------------------------
10:42:26.386 -> Incoming data:
10:42:26.386 -> 50


No matter how long I let this run the numbers all stay between the 40s and the 50s, seemingly random but with lots of repeats...


Is this a problem with the kidn of packets BLE actually sends out and receives or maybe how it is encrypted? Am I using uint8_t wrong? Or int wrong? or writing or reading to Bleuart wrong? I can't find a reference for the Bleuart library so I'm not sure where to start with this.

Thank you!
Tom

TKWEAVERARW
 
Posts: 6
Joined: Tue Oct 13, 2020 5:07 pm

Re: Two nRF52 boards having trouble sending data

by TKWEAVERARW on Mon Oct 26, 2020 4:03 pm

So -- I solved this... kinda. At least, I got it to work for my project.

When I use pure data to send one byte of data straight from the comport through bleuart -- it comes through the other side OK if I convert it immediatley to an integer.

it's still kinda weird about multiple data points failing to come through if they come at the same time, etc.

Basically, I don't understand WHY it works (badly) but it's good enough... for now.

That said, any insight would be much appreciated.

TKWEAVERARW
 
Posts: 6
Joined: Tue Oct 13, 2020 5:07 pm

Please be positive and constructive with your questions and comments.