Forum >Using Bluno Nano as a Serial to BLE transceiver
General

Using Bluno Nano as a Serial to BLE transceiver

userHead alan.down 2015-03-18 00:46:09 2821 Views3 Replies
Hello,

I've had some fun getting this working and thought I'd post my code for comments / thoughts.

I am trying to use a Bluno Nano as a Serial to BLE transceiver running at 115200 baud. Just using the TX/RX pins on the built in UART has proved unsuccessful. For some reason data transmitted from BLE does not appear on the TX pin - it appears to go to the RX pin!!!! Very strange. Anyway, the following code worked best for me using AltSoftSerial with the serial lines connected to pins 8 and 9. I've also avoided using Strings as they seemed to take too much CPU and upset the software serial comms.

Note: My protocol delimits messages using character 10 (\n), so I am batching transmissions to try to get them into one BLE packet:

Code: Select all
//#include <SoftwareSerial.h>
//SoftwareSerial portOne(8,9);

#define delim '\n'

#include <AltSoftSerial.h>
AltSoftSerial portOne;

char in[255];
char out[255];
char *inpos=in;
char *outpos=out;

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);

// Start each software serial port
portOne.begin(115200);
}

void loop()
{
char inchar;

if (portOne.available())
{
*inpos=(char)portOne.read();
if (*inpos==delim)
{
*++inpos=0;
Serial.write(in);
inpos=in;
}
else
inpos++;
}

if (Serial.available())
{
*outpos=(char)Serial.read();
if (*outpos==delim)
{
*++outpos=0;
portOne.write(out);
delay(10);
outpos=out;
}
else
outpos++;
}
}
2015-03-26 02:46:23 "For some reason data transmitted from BLE does not appear on the TX pin - it appears to go to the RX pin!!!! "

should it not be in this way, i mean.
userHeadPic Leff
2015-03-26 00:00:20 leff, I don't understand? userHeadPic alan.down
2015-03-24 20:26:32 one BLE sends data through TX, another BLE read by RX. ;) userHeadPic Leff