From 3af60f5fb8c7092bbbe093066bd9fd16ec76acb9 Mon Sep 17 00:00:00 2001 From: Kamaropoulos Date: Wed, 26 Feb 2020 21:34:58 +0200 Subject: [PATCH] fix: Initializing HardwareSerial from library causes baudrate issues --- Aiolos_Drone.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Aiolos_Drone.ino b/Aiolos_Drone.ino index 6efb918..92938cd 100644 --- a/Aiolos_Drone.ino +++ b/Aiolos_Drone.ino @@ -1,4 +1,4 @@ -#include "RYLR896.h" + #include "RYLR896.h" #define DRONE_ID 1 @@ -17,6 +17,8 @@ int MQ135 = A7; RYLR896* lora; void setup() { + Serial.begin(115200); + Serial.println("Starting up..."); pinMode(MQ2, INPUT); pinMode(MQ4, INPUT); pinMode(MQ5, INPUT); @@ -25,11 +27,14 @@ void setup() { pinMode(MQ8, INPUT); pinMode(MQ9, INPUT); pinMode(MQ135, INPUT); + Serial.println("Initializing communications..."); + Serial3.begin(115200); lora = new RYLR896(&LORA_SERIAL, 115200); lora->SetRFParamsLessThan3KM(); lora->SetAESPassword("FABC0002EEDCAA90FABC0002EEDCAA90"); - Serial.begin(115200); + Serial.println("Initializing GPS..."); GPS_SERIAL.begin(9600); + Serial.println("Setup completed!"); } void loop() { @@ -45,7 +50,6 @@ void loop() { if (GPS_SERIAL.available() > 0){ String gpsData = GPS_SERIAL.readStringUntil('\n'); if (gpsData.startsWith("$GPRMC")){ - // |MQ2=100|MQ4=100|MQ5=100|MQ6=100|MQ7=100|MQ8=100|MQ9=100|MQ135=100 String data = String(DRONE_ID) + "|" + gpsData + "|" + "MQ2=" + String(GAS_MQ2) + "|" + "MQ4=" + String(GAS_MQ4) + "|" + "MQ5=" + String(GAS_MQ5) + "|" + "MQ6=" + String(GAS_MQ6) + "|" + "MQ7=" + String(GAS_MQ7) + "|" + "MQ8=" + String(GAS_MQ8) + "|" + "MQ9=" + String(GAS_MQ9) + "|" + "MQ135=" + String(GAS_MQ135); // Serial.print("MQ2: "); // Serial.println(GAS_MQ2); @@ -68,4 +72,4 @@ void loop() { lora->Send(data); } } -} +} \ No newline at end of file