Arduino Forum

Topics => Science and Measurement => Topic started by: Kattiny1616 on Jan 31, 2020, 07:02 pm

Title: Discrepancy between UART buffer and BLE Buffer
Post by: Kattiny1616 on Jan 31, 2020, 07:02 pm
Hi guys

we are using an Attiny1616 together with an RN4871 BLE chip to send the data. The Board Attiny1616 is part of the Arduino IDE, thus I thought I ask my questions here.

We have a few sensors connected to the attiny1616, like a flex sensor and an IMU. We want to send the gathered data as fast as possible through the RN4871 to our phone.

We connected the hardware serial pins of the attiny1616 and RN4871.

The problem that we run into is that data packages sent from the RN4871 arrive cut off on our phone. (we test the packages with a BLE Scanner). The data is not only cut off but we also lose some of the data. If we set a delay into our code then the sending works.

What is the best way to make sure that the RN4871 sent all the data in the buffer before accepting the next data package from the attny1616?

If some kind of code is requested, I will happily provide something. At the moment, I don't see the need for a code, since it is a fundamental question.

Thanks all!

 
Title: Re: Discrepancy between UART buffer and BLE Buffer
Post by: wvmarle on Feb 01, 2020, 03:30 pm
What is the best way to make sure that the RN4871 sent all the data in the buffer before accepting the next data package from the attny1616?
It seems you have found the solution already: don't try to send data to the RN4871 faster than the RN4871 can send it out.

Consider lowering the baud rate you send your data at, so it's slower than the BLE link itself. Then the Arduino's Serial functions will simply block until the Serial buffer can receive more data.