Я новичок в Arduino. В коде, который я написал в своем проекте, есть проблема. Проблема заключается в том, что датчик GPS (Adafruit Ultimate gps breakout v3) обнаруживает, что спутник, время GPS и значения координат не меняются. Другие значения работают, но нет только GPS. (Вы можете увидеть результат и код ниже.)
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include "DFRobot_BNO055.h"
#include "Wire.h"
#include <SFE_BMP180.h>
SoftwareSerial mySerial(51, 50);
Adafruit_GPS GPS(&mySerial);
typedef DFRobot_BNO055_IIC BNO;
BNO bno(&Wire, 0x28);
SFE_BMP180 pressure;
double baseline; // baseline pressure
#define GPSECHO true
#define ALTITUDE 820 // Altitude of My Home, in meters
void printLastOperateStatus(BNO::eStatus_t eStatus);
double getPressure();
void setup()
{
Serial.begin(115200);
bno.reset();
while (bno.begin() != BNO::eStatusOK)
{
Serial.println("bno begin faild");
printLastOperateStatus(bno.lastOperateStatus);
delay(500);
}
Serial.println("bno begin success");
delay(500);
GPS.begin(9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
GPS.sendCommand(PGCMD_ANTENNA);
if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
Serial.println("BMP180 init fail\n\n");
while (1)
; // Pause forever.
}
delay(1000);
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
// Get the baseline pressure:
baseline = getPressure();
Serial.print("baseline pressure: ");
Serial.print(baseline);
Serial.println(" mb");
}
uint32_t timer = millis();
void loop()
{
char status;
double T, P, p0, a, Pv;
char c = GPS.read();
BNO::sEulAnalog_t sEul;
sEul = bno.getEul();
if ((c) && (GPSECHO))
// if a sentence is received, we can check the checksum, parse it...
if (GPS.newNMEAreceived())
{
if (!GPS.parse(GPS.lastNMEA()))
return;
}
if (millis() - timer > 2000)
{
timer = millis(); // reset the timer
Serial.print("<");
Serial.print("TeamID");
Serial.print(">");
//Saati if gpsfix in bi üstüne koy
Serial.print("<");
Serial.print(sEul.pitch, 3);
Serial.print(">");
Serial.print("<");
Serial.print(sEul.roll, 3);
Serial.print(">");
Serial.print("<");
Serial.print(sEul.head, 3);
Serial.print(">");
if (GPS.fix)
{
Serial.print("<");
Serial.print(GPS.hour+3, DEC);
Serial.print(':');
if (GPS.minute < 10)
{
Serial.print('0');
}
Serial.print(GPS.minute, DEC);
Serial.print(':');
if (GPS.seconds < 10)
{
Serial.print('0');
}
Serial.print(GPS.seconds, DEC);
Serial.print(">");
//buraya
Serial.print("<");
Serial.print(GPS.latitudeDegrees, 6);
Serial.print(">");
Serial.print("<");
Serial.print(GPS.longitudeDegrees, 6);
Serial.print(">");
}
// Get a new pressure reading:
Pv = getPressure();
// Show the relative altitude difference between
// the new reading and the baseline reading:
a = pressure.altitude(Pv, baseline);
//bmp180
status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Function returns 1 if successful, 0 if failure.
status = pressure.getTemperature(T);
if (status != 0)
{
// Print out the measurement:
Serial.print("<");
Serial.print(T, 2);
Serial.print(">");
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = pressure.getPressure(P, T);
if (status != 0)
{
// Print out the measurement:
Serial.print("<");
Serial.print(P, 2);
Serial.print(">");
p0 = pressure.sealevel(P, ALTITUDE); // we're at 1655 meters (Boulder, CO)
Serial.print("<");
Serial.print(p0, 2);
Serial.print(">");
// On the other hand, if you want to determine your altitude from the pressure reading,
// use the altitude function along with a baseline pressure (sea-level or other).
// Parameters: P = absolute pressure in mb, p0 = baseline pressure in mb.
// Result: a = altitude in m.
}
else
Serial.println("error retrieving pressure measurement\n");
}
else
Serial.println("error starting pressure measurement\n");
}
else
Serial.println("error retrieving temperature measurement\n");
}
else
Serial.println("error starting temperature measurement\n");
Serial.print("<");
Serial.print(a,1);
Serial.print(">");
Serial.println();
}
}
void printLastOperateStatus(BNO::eStatus_t eStatus)
{
switch (eStatus)
{
case BNO::eStatusOK:
Serial.println("everything ok");
break;
case BNO::eStatusErr:
Serial.println("unknow error");
break;
case BNO::eStatusErrDeviceNotDetect:
Serial.println("device not detected");
break;
case BNO::eStatusErrDeviceReadyTimeOut:
Serial.println("device ready time out");
break;
case BNO::eStatusErrDeviceStatus:
Serial.println("device internal status error");
break;
default:
Serial.println("unknow status");
break;
}
}
double getPressure()
{
char status;
double T,P,p0,a;
// You must first get a temperature measurement to perform a pressure reading.
// Start a temperature measurement:
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Use '&T' to provide the address of T to the function.
// Function returns 1 if successful, 0 if failure.
status = pressure.getTemperature(T);
if (status != 0)
{
// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Use '&P' to provide the address of P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.
status = pressure.getPressure(P,T);
if (status != 0)
{
return(P);
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}
else Serial.println("error retrieving temperature measurement\n");
}
else Serial.println("error starting temperature measurement\n");
}
Вывод:
<TeamID><17:07:58><0.500><62.562><279.312><39.980690><32.662307><27.37><885.40><976.68><304.3>
<TeamID><17:07:58><0.500><62.562><279.312><39.980690><32.662307><27.48><885.44><976.72><305.1>
<TeamID><17:07:58><0.500><62.562><279.312><39.980690><32.662307><27.62><885.65><976.95><303.5>
<TeamID><17:07:58><0.500><62.500><279.312><39.980690><32.662307><27.71><885.61><976.91><304.7>
<TeamID><17:07:58><0.500><62.437><279.312><39.980690><32.662307><27.79><885.60><976.89><303.8>
<TeamID><17:07:58><0.500><62.437><279.250><39.980690><32.662307><27.76><885.65><976.95><302.6>
<TeamID><17:07:58><0.375><62.437><279.187><39.980690><32.662307><27.68><885.61><976.91><302.7>
<TeamID><17:07:58><0.375><62.437><279.187><39.980690><32.662307><27.80><885.65><976.96><303.3>
OutputPicture