Problems with getting sketches to work on Arduino DUE

Hey! Im pretty new to arduino and blynk and im working on a Projekt trying to connect the arduino DUE via bluetooth and a HC05 module, trying to send information from the Joystick in the blynk app to my PC serial monitor. I learned that the DUE doesn´t support SoftwareSerial (why are they used in the example for DUE projects?? lol) so im trying to get the code from the Blynk sketch creator to work on my DUE. I took out all the SoftwareSerial commands, since the Serial.print commands should use the standard RX/TX pins right? Yesterday i managed to at least get the compile to work with that and upload it to my DUE, but i can´t connect to the phone and app - just getting the “Waiting for connections…” message. My guess is that removing the BLE commands which stop the compile from working also removes the abillity for my components to communicate via bluetooth?
See the code below


#define BLYNK_PRINT Serial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "notsureifushouldseethiscodehaha";

BLYNK_WRITE(V1) {
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
}

void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  Serial.println("Waiting for connections...");
}

void loop()
{
  Blynk.run();
}

SoftwareSerial is used to create an additional serial port when you’ve run out of available ports.
As the DUE has four serial ports there’s probably no need to create an additional one.

The ports are referenced as Serial, Serial1, Serial2 & Serial3 so you can do:

Serial.begin(baud rate);
Serial1.begin(baud rate);
Serial2.begin(baud rate);
Serial3.begin(baud rate);

These are the pinouts…

Serial:      0 (RX) and  1 (TX)
Serial 1:   19 (RX) and 18 (TX)
Serial 2:   17 (RX) and 16 (TX)
Serial 3:   15 (RX) and 14 (TX)

The programming port is connected to Serial (pins 0 & 1) so that’s the sensible one to use for debug messages to your PC. Serial.print ("debug message"); will print “debug message” on your serial monitor.

You’d connect your HC05 to one of the other serial ports, at the correct baud rate and initialise your Blynk connection accordingly - Blynk.begin(Serial3, auth) for example.

Pete.

1 Like

:rofl: :rofl::rofl:

1 Like

Tyvm pete, i got it :slight_smile: