Hi,
I am new to the Arduino and this is my first cry for help on here. I have read a lot of stuff on here which has helped my learning curve immensely but I have hit a wall that hopefully someone will be able to help with.
I hope this is in the correct forum as I believe it is a programming issue, if not I apologise.
I am trying to find my way through a small project to create a digital dashboard for a classic car I am restoring that will show general stuff like time, engine temperatures and pressures and basic GPS data.
The Arduino is connected to a Nextion display along with a NEO 6M for GPS data (all I am interested in is speed, altitude and number of satellites) and a DS18B20 temperature probe (There will eventually be 3 temperature probes for air temp, water temp and oil temp) along with an RTC unit for time.
For the temperature I am using the onewire and dallas temperatures library, for the GPS softwareserial and TinyGPS++.
Individually all the sensors and GPS appears to work correctly when plugged in on their own but I appear to have a clash between the GPS and temperatures when used together.
When everything is connected together and I start the unit the temperature starts and displays correctly but the GPS just displays zeros and wont update. It's not freezing as everything else displays and updates correctly. If I have the data line from the temperature unit disconnected on start up the GPS starts and works perfectly. I can then plug the data line back into the Arduino and both the temperature and GPS work and update correctly.
Its appears to me that possibly the temperature isn't releasing control to move onto the GPS.
I have tried it on 2 different Nano boards and an UNO and they all do the same thing. Any help or guidance would be appreciated as I am lost.
Many thanks
Ian.
This is my code...
//Pins
//Nextion yellow - TX
// blue - RX
//Temps Data - D9
//RTC SDA - A4
// SCL - A5
//GPS RX - D4
// TX - D3
#include <Wire.h>
#include "RTClib.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include "TinyGPS++.h"
#include "SoftwareSerial.h"
#define ONE_WIRE_BUS 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
SoftwareSerial ss(4,3);
TinyGPSPlus gps;
RTC_DS3231 rtc;
void setup()
{
Serial.begin(9600);
rtc.begin(); //RTC unit
sensors.begin(); // Temp sensors
ss.begin(9600); //GPS unit
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop()
{
//Time
DateTime now = rtc.now();
Serial.print("cl0.val=");
Serial.print(now.hour(), DEC);
endNextion();
Serial.print("cl1.val=");
Serial.print(now.minute(), DEC);
endNextion();
Serial.print("cl2.val=");
Serial.print(now.second(), DEC);
endNextion();
//Temperatures
// Send command to all the sensors for temperature conversion
//sensors.requestTemperatures();
// Get temperature from each sensor
float tempA=sensors.getTempCByIndex(0);
//float tempB=sensors.getTempCByIndex(1);
String commandA=String(tempA);
//String commandB=String(tempB);
Serial.print("air0.txt=\"");
Serial.print(commandA);
Serial.print("\"");
endNextion();
// Serial.print("t1.txt=\"");
// Serial.print(commandB);
// Serial.print("\"");
// endNextion();
//GPS
while(ss.available())//While there are characters to come from the GPS
{
gps.encode(ss.read());//This feeds the serial NMEA data into the library one char at a time
}
Serial.print("sat0.val=");
Serial.print(gps.satellites.value());
endNextion();
Serial.print("spd0.val=");
Serial.print(gps.speed.mph());
endNextion();
int ssalt=(gps.altitude.feet());
String gpsalt = String(ssalt);
Serial.print("alt0.txt=\"");
Serial.print(gpsalt);
Serial.print("\"");
endNextion();
// Serial.print(gps.location.lat(), 6);
// Serial.print(gps.location.lng(), 6);
}
void endNextion()
{
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}