i'm trying gps , pressure readings arduino uno. however, when try pressure/temperature readings off of pressure sensor (code snippet below), gps starts sending malformed packets serial monitor. i'd able gps , pressure readings arduino. (hardware details provided below)
here's full code:
when line pressure commented so...
...my gps gives me proper packets of data:
but when line pressure uncommented...
my gps packets become malformed:
----------
hardware:
arduino board: arduino uno r3
gps: venus gps (made sparkfun)
pressure sensor: ms5803-14ba breakout (made sparkfun)
data logger: openlog (made sparkfun)
here's setup:
what's causing gps send bad packets? evidently, pressure sensor somehow interfering gps, how doing , how can avoid interference?
code: [select]
float temperature_c, temperature_f;
double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;
string datastring = "";
pressure_abs = sensor.getpressure(adc_4096); //if line removed, gps sends data.
}
here's full code:
code: [select]
#include <softwareserial.h>
//pressure sensor libraries
#include <wire.h>
#include <sparkfun_ms5803_i2c.h>
//datalogger library
#include <spi.h>
#include <sd.h>
// set datalogger
const int chipselect = 4;
/*-----------gps-----------*/
softwareserial gpsserial(10, 11); // rx, tx (tx not used)
const int sentencesize = 80;
char sentence[sentencesize];
/*------------pressure sensor-------*/
// begin class selected address
// available addresses (selected jumper on board)
// default address_high
// address_high = 0x76
// address_low = 0x77
ms5803 sensor(address_high);
// create variable store altitude in (m) calculations;
double pressure_baseline;
double base_altitude = 1655.0; // altitude of sparkfun's hq in boulder, co. in (m)
void setup()
{
serial.begin(9600);
gpsserial.begin(9600);
/*----------pressure sensor stuff----------*/
serial.println("\ntemperature (c), temperature (f), pressure (abs), pressure (relative), change in altitude");
//retrieve calibration constants conversion math.
sensor.reset();
sensor.begin();
pressure_baseline = sensor.getpressure(adc_4096);
serial.println(pressure_baseline);
serial.println("\n");
}
void loop()
{
static int = 0;
if (gpsserial.available())
{
// serial.print("gps serial available\n");
char ch = gpsserial.read();
if (ch != '\n' && < sentencesize)
{
sentence[i] = ch;
i++;
}
else
{
sentence[i] = '\0';
= 0;
// serial.println("\n");
serial.println(sentence);
// serial.println("\n");
displaygps();
}
}
/*----------------------pressure sensor-------------------------*/
float temperature_c, temperature_f;
double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;
string datastring = "";
pressure_abs = sensor.getpressure(adc_4096); //if line removed, gps sends data.
}
/*--------------------------pressure sensor methods----------------*/
// mike grusin letting me borrow functions below
// bmp180 example code.
double sealevel(double p, double a)
// given pressure p (mbar) taken @ specific altitude (meters),
// return equivalent pressure (mbar) @ sea level.
// produces pressure readings can used weather measurements.
{
return(p/pow(1-(a/44330.0),5.255));
}
double altitude(double p, double p0)
// given pressure measurement p (mbar) , pressure @ baseline p0 (mbar),
// return altitude (meters) above baseline.
{
return(44330.0*(1-pow(p/p0,1/5.255)));
}
void displaygps()
{
char field[20];
getfield(field, 0);
if (strcmp(field, "$gpgga") == 0)
{
serial.print("lat: ");
getfield(field, 2); // number
serial.print(field);
getfield(field, 3); // n/s
serial.print(field);
serial.print(" long: ");
getfield(field, 4); // number
serial.print(field);
getfield(field, 5); // e/w
serial.println(field);
serial.print("altitude: ");
getfield(field, 9);
serial.println(field);
serial.print("number of satellites: ");
getfield(field, 7);
serial.println(field);
serial.println("-----------------------\n");
}
}
void getfield(char* buffer, int index)
{
int sentencepos = 0;
int fieldpos = 0;
int commacount = 0;
while (sentencepos < sentencesize)
{
if (sentence[sentencepos] == ',')
{
commacount ++;
sentencepos ++;
}
if (commacount == index)
{
buffer[fieldpos] = sentence[sentencepos];
fieldpos ++;
}
sentencepos ++;
}
buffer[fieldpos] = '\0';
}
when line pressure commented so...
code: [select]
float temperature_c, temperature_f;
double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;
string datastring = "";
// pressure_abs = sensor.getpressure(adc_4096); //if line removed, gps sends data.
}
...my gps gives me proper packets of data:
code: [select]
$gpgsa,a,1,,,,,,,,,,,,,0.0,0.0,0.0*30
$gprmc,120208.000,v,24006,,,n*71
$gpvtg,000.0,t,,m,000.0,n,000.0,k,n*02
$gpgga,120209.000,2400.0000,n,12100.0000,e,0,00,0.0,0.0,m,0.0,m,,0000*61
lat: 2400.0000n long: 12100.0000e
altitude: 0.0
number of satellites: 00
-----------------------
$gpgsa,a,1,,,,,,,,,,,,,0.0,0.0,0.0*30
$gprmc,120209.000,v,24006,,,n*70
$gpvtg,000.0,t,,m,000.0,n,000.0,k,n*02
$gpgga,120210.000,2400.0000,n,12100.0000,e,0,00,0.0,0.0,m,0.0,m,,0000*69
lat: 2400.0000n long: 12100.0000e
altitude: 0.0
number of satellites: 00
-----------------------
$gpgsa,a,1,,,,,,,,,,,,,0.0,0.0,0.0*30
$gprmc,120210.000,v,240006,,,n*78
$gpvtg,000.0,t,,m,000.0,n,000.0,k,n*02
$gpgga,120211.000,2400.0000,n,12100.0000,e,0,00,0.0,0.0,m,0.0,m,,0000*68
lat: 2400.0000n long: 12100.0000e
altitude: 0.0
number of satellites: 00
-----------------------
but when line pressure uncommented...
code: [select]
float temperature_c, temperature_f;
double pressure_abs, pressure_relative, altitude_delta, pressure_baseline;
string datastring = "";
pressure_abs = sensor.getpressure(adc_4096); //if line removed, gps sends data.
}
my gps packets become malformed:
code: [select]
$gpgga,120125.000,2400.0000,n,12100.0000,e,0,00,0.0,0.0,m,0.0,m,,$0,0t,$gpgga,12
lat: 2400.0000n long: 12100.0000e
altitude: 0.0
number of satellites: 00
-----------------------
126.000,2400.0000,n,120,00..
$gpgga,120127.000,2400.0000,n,100,$gpgga,120128.000,2400.0000,n,1200,20*0$gpgga,
lat: 2400.0000n long: 100$gpgga
altitude: 1200
number of satellites: 2400.0000
-----------------------
20129.000,2400.0000,n,120g.4,,*$gpgga,120130.000,2400.0000,n,1060$gpgga,120131.0
0,2400.0000,n,12,*..e
0$gpgga,120132.000,2400.0000,n,120a00.0
$gpgga,120133.000,2400.0000,n,1m,
0,,$gpgga,120134.000,2400.0000,n,1200,1070$gpgga,120135.000,2400.0000,n,10,,,0,0
gpgga,120136.000,2400.0000,n,120g0,0v,$gpgga,120137.000,2400.0000,n,1,,30000
$gp
ga,120138.000,2400.0000,n,0g00v0vk$gpgga,120139.000,2400.0000,n1,,vp,6,$gpgga,12
140.000,2400.0000,n,1.,0*.0.
$gpgga,120141.000,2400.0000,n,0a*00*n$gpgga,120142.000,2400.0000,n,.,,110,0$gpgg
lat: 2400.0000n long: 0a*00*n$gpgga120142.000
altitude: ,110
number of satellites: n
-----------------------
,120143.000,2400.0000,n,1,,p$02,$gpgga,120144.000,2400.0000,n,10.0$gpgga,120145.
00,2400.0000,n,10a*00000$gpgga,120146.000,2400.0000,n,0g.020,*$gpgga,120147.000,
400.0000,n0,,20,0$gpgga,120148.000,2400.0000,n,120p,,0p,$gpgga,120149.000,2400.0
00,n,1.s0000*$gpgga,120150.000,2400.0000,n,1.,,,0,0$gpgga,120151.000,2400.0000,n
100,50e,$gpgga,120152.000,2400.0000,n,120s.00,n$gpgga,120153.000,2400.0000,n,1.a
0002$gpgga,120154.000,2400.0000,n,1.,,00n,$gpgga,120155.000,2400.0000,n,1e*..0a0
gpgga,120156.000,2400.0000,n,120s0400n$gpgga,120157.000,2400.0000,n,1.a0.000$gpg
a,120158.000,2400.0000,n,100,2.n.$gpgga,120159.000,2400.0000,n,100,906,$gpgga,12
200.000,2400.0000,n,120,*000*$gpgga,120201.000,2400.0000,n,10,,,.gn$gpgga,120202
000,2400.0000,n,11,,c160$gpgga,120203.000,2400.0000,n,12,6.00
,$gpgga,120204.000
2400.0000,n,100,00*,$gpgga,120205.000,2400.0000,n,120,300.
$gpgga,120206.000,2400.0000,n,1.,r,0m$gpgga,120207.000,2400.0000,n,12,00007n$gpg
lat: 2400.0000n long: 1.r
altitude: n
number of satellites: 120207.000
-----------------------
----------
hardware:
arduino board: arduino uno r3
gps: venus gps (made sparkfun)
pressure sensor: ms5803-14ba breakout (made sparkfun)
data logger: openlog (made sparkfun)
here's setup:
what's causing gps send bad packets? evidently, pressure sensor somehow interfering gps, how doing , how can avoid interference?
code: [select]
string datastring = "";
use of strings leads memory problems, might explain seeing.
avoid use of strings, , use built-in character array processing routines of c/c++.
Arduino Forum > Using Arduino > Sensors > Trouble reading data from Venus GPS and MS5803-14BA Pressure Sensor
arduino
Comments
Post a Comment