Issue with Bluz/Particle serial debugging


#1

I followed the instructions on this page http://docs.bluz.io/tutorials/serial/ to hook my Core and my Bluz together to enable serial debugging but none of my Bluz messages come through. They are connected exactly as pictured, 3v3 to 3v3, Gnd to Gnd, RX to TX, and TX to RX.

To rule out issues with the Core to PC side of things I updated the code to send something every 10sec which I am seeing in my terminal window:

long lastPublish=0;
long publishFrequency=10;

void setup() {
    Serial.begin(38400);
    Serial1.begin(38400);
    Serial.println("Welcome to the bluz serial transverter!");
    Particle.publish("startup", "Serial Transverter Online", 60, PRIVATE);
}

void loop() {
    long nowSec=millis()/1000;
    if (lastPublish+publishFrequency <= nowSec)
    {
        Serial.println("host uptime: " + String(nowSec));
        lastPublish = nowSec;
    }
    while (Serial.available() > 0) {
        Serial1.write(Serial.read());
    }
    while (Serial1.available() > 0) {
        Serial.write(Serial1.read());
    }
}

On the Bluz side I’m using this and can see in the Particle Dashboard the publish statements as expected:

long lastPublish=0;
long publishFrequency=10;

void setup() {
    Serial.begin(38400);
    Serial.println("bluz online");
}

void loop() {
    long nowSec=millis()/1000;
    if (lastPublish+publishFrequency <= nowSec)
    {
        Serial.println("bluz uptime: " + String(nowSec));
        if (Particle.connected())
            Particle.publish("heartbeat", "bluz uptime: " + String(nowSec), 60, PRIVATE);
        lastPublish = nowSec;
    }
    System.sleep(SLEEP_MODE_CPU);
}

I tried slowing things down from 38400 to 9600 baud but that didn’t help. I tested the connection with a multi-meter between each set of RX and TX pins to rule out issues with my breadboard and wires. FYI, just got this Bluz and it’s Gateway last week, so I’m assuming it’s up to date and doesn’t need the upgrade that the original batch needed.

Any ideas?


#2

As explained here: Porting from Photon (with SPI)

One thing that is a bit confusing, bluz doesn’t support Serial, you need to use Serial1. This was done with the mindset of keeping true to the definitions. Serial in the Arduino/Particle world always refers to UART over USB while Serial1 refers to physical pins labeled TX/RX.

So you would need to change all Serial instances to Serial1 in the bluz app.


#3

Wow, not sure how I missed that; was at the top of the page I linked to :sweat_smile:. It works now after fixing that. Thanks for the quick response; now back to debugging my real issue ;).