[SOLVED] Problems with Serial1


#1

Hi, i have connected an external device via RX/TX pins of my bluzdk device and, apperently, the serial1 interface of my bluzdk device is not working ok … The only way i can debug what’s happening is by using the bluz gateway, isnt it? thanks


#2

Can you provide more details about the issue with Serial1? What is not working?

Is the device connected properly? That is, the TX of your sensor is connected to RX of bluz and the RX of your sensor is on TX of bluz? And the GND of the two devices are connected?

What is the code you are using to try and read the data?


#3

HI @eric, thanks again. your continuos support is highly appreciated. i verified the same code, but with a photon device by printing the read vales, and everything was ok, so connections between RX/TX pines are right. the GND is also connected between bluzdk and the external device connected serially. The code is the following:

#include "Brain.h"

#include "application.h"

boolean modeDebug = false;
boolean modeRaw = false;  // false = 9.6kbaud, normal mode - true = 57.6kbaud, normal + 16bits raw mode
uint8_t *buffer;
uint8_t resp_buffer[20];

// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial1, modeRaw, modeDebug);

SYSTEM_MODE(MANUAL);



void setup() {
    pinMode(D7, OUTPUT);
    digitalWrite(D7, LOW);
    for (int i=0; i<6; i++)
        resp_buffer[i]=i;    
        
    // Start the hardware serial.
    if (modeRaw) {
        Serial1.begin(57600);
//        Serial.begin(57600);
    }
    else {
        Serial1.begin(9600);
//        Serial.begin(9600);
    }
}

void loop() {
    System.sleep(SLEEP_MODE_CPU);
    if (brain.update())
    {
        buffer = brain.readCSV();
        BLE.sendData(buffer, 6);
//        for (int i=0; i<6; i++)
//            Serial.println(buffer[i]);
        digitalWrite(D7, HIGH);
    }
    else
    {
        digitalWrite(D7, LOW);
        BLE.sendData(resp_buffer, 6);
    }    
}

and the brain.update(); function (partial code) is the following:

boolean Brain::update() {
    while (brainStream->available()) {
        latestByte = brainStream->read();
...

if (freshPacket) {
    freshPacket = false;
    return true;
}
else {
    return false;
}

}


#4

Bluz only supports Serial1, not Serial. This was done to maintain support with existing terminology.

Does the Brain library use Serial or Serial1? I see in the main loop() there is still a call to Serial. This needs to be changed to Serial1 in all places, including the Brain library


#5

Hi @eric … yes, i only used Serial1 (the lines with Serial commands ar commented, because the code was used on other devices supporting both Serial and Serial1), and as you can see on the sentence Brain brain(Serial1, modeRaw, modeDebug); the Brain library is set up to use Serial1.


#6

Which version of firmware are you using? You may want to try 2.0.50-beta.5 as there have been a few bug fixes to UART over the last few months


#7

Hi @eric, the problem with Serial1 was solved updating the firmware to 2.0.50-beta.5 . Thanks