Arduino sketch - GPS won't work when Cayenne is running


#1

My basic Arduino sketch below is to read the sentence from a gps using Tinygps++ and display the seconds part of the time.
The internet connect works fine.
When I comment out the line cayenne.loop, the gps through the SoftwareSerial read provides the seconds data and prints correctly.
When I uncomment the line cayenne.loop, no gps data appears.
Does cayenne interact somehow with the serial read facility of SoftwareSerial

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

// WiFi network info.
char ssid[] = "*******";
char wifiPassword[] = "************";

static const int RXPin = 12, TXPin = 13;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "*********";
char password[] = "*********";
char clientID[] = "*********";


void setup() {
	Serial.begin(115200);
  ss.begin(GPSBaud);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}


void loop() {
   Cayenne.loop();

  //get the data every time a new sentence is correctly encoded.
 
      while (ss.available() > 0)
      if (gps.encode(ss.read())){
             Serial.println(gps.time.second());
   
  }
}

#2

As far as I know the ESP MQTT library doesn’t do anything with software serial, maybe @rsiegel would know?

Anyway, I noticed you didn’t have any curly brackets for your while statement, maybe give this a try?

#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

// WiFi network info.
char ssid[] = "*******";
char wifiPassword[] = "************";

static const int RXPin = 12, TXPin = 13;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "*********";
char password[] = "*********";
char clientID[] = "*********";


void setup() {
	Serial.begin(115200);
	ss.begin(GPSBaud);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}


void loop() {
   Cayenne.loop();

  //get the data every time a new sentence is correctly encoded.
 
	while (ss.available() > 0){
		if (gps.encode(ss.read())){
			Serial.println(gps.time.second());
		}
	}
}

#3

I believe you’re correct regarding SoftwareSerial.


#4

Thank you for the suggestions. The addition of curly brackets for the while statement solved the problem