Hello,
My BMP180 Barometer recently stopped being as Precise as It had been before. In a matter of 5 or so minutes, Inside, without being moved or touched, The Sensor will begin to get readings of 7-10 feet higher than its zero. This is a problem because there is no wind or airflow around it and it should remain at its zero if its not moving.
This is an example of the data Drift over a time of less than 5 minutes
Pressure, Altitude (feet)
1010.79059, 0.13
1010.79465, 0.53
1010.73731, -0.85
1010.76329, -0.19
1010.74102, 0.88
1010.84560, 1.49
1010.85268, 1.28
1010.81187, 0.72
1010.83076, -1.48
1010.82705, 0.61
1010.83580, 0.27
1010.75912, 0.33
1010.74938, 2.59
1010.78787, 0.51
1010.71099, 1.33
1010.80174, 1.20
1010.71168, 1.41
1010.78184, 1.54
1010.74775, 3.44
1010.73926, 1.33
1010.75541, 1.04
1010.72461, 0.30
1010.69213, 2.61
1010.78077, 2.07
1010.72474, 4.38
1010.72805, 3.06
1010.69467, 3.68
1010.64645, 4.70
1010.64274, 4.13
1010.68520, 2.45
1010.67241, 5.10
1010.66870, 3.82
1010.69506, 3.46
1010.68432, 3.50
1010.63035, 4.31
1010.64391, 7.16
1010.62741, 4.65
1010.62612, 5.45
1010.64708, 5.44
1010.66804, 3.33
1010.67619, 3.05
1010.58989, 6.49
1010.66884, 5.00
1010.50759, 6.51
1010.64556, 4.61
1010.55650, 7.10
1010.59191, 5.06
1010.61249, 5.82
1010.60135, 5.76
1010.51229, 7.70
1010.56626, 7.08
1010.55916, 4.94
1010.59086, 7.02
1010.53689, 7.01
1010.52173, 7.44
1010.57368, 8.17
1010.60845, 4.71
1010.57101, 6.55
1010.58889, 5.75
1010.55144, 7.55
1010.59394, 6.99
1010.55144, 6.37
1010.54571, 5.04
1010.59058, 6.68
1010.58078, 6.48
1010.53220, 8.48
1010.55950, 6.92
1010.59457, 6.05
1010.65225, 4.89
1010.65393, 5.40
1010.62760, 4.29
1010.57733, 6.79
1010.60330, 8.68
1010.54933, 5.61
1010.57530, 7.10
1010.59384, 5.57
1010.55675, 5.00
1010.53820, 6.52
1010.66099, 5.11
1010.61981, 5.72
1010.64207, 4.55
1010.54358, 6.08
1010.64411, 5.82
1010.59384, 5.67
1010.59552, 6.89
1010.64040, 5.00
1010.66135, 4.68
1010.56656, 5.28
1010.60570, 3.46
1010.60234, 6.77
1010.49033, 6.01
1010.52779, 9.41
1010.58211, 5.13
1010.59562, 6.74
1010.66681, 6.27
1010.42576, 10.67
1010.48309, 10.03
1010.35751, 11.96
This is the Code I am Using:
#include <TinyGPS.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include "RH_ASK.h"
#include "RH_RF95.h"
#include "SFE_BMP180.h"
#include "avr/dtostrf.h"
File main_folder; // initialize folder for saving
File dataFile; // initialize sd file
const int chipSelect = 10; // CS pin on sd card module
int prev_file_indx = 0; // used for file naming
String fileName = "000";
float baseline;
SFE_BMP180 bmp;
TinyGPS gps;
#define RFM95_CS 8
#define RFM95_RST 4
#define RFM95_INT 3
//#define Serial SERIAL_PORT_USBVIRTUAL
#define RF95_FREQ 433.0
// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);
void setup()
{
Wire.begin();
Serial.begin(9600);
bool status;
status = bmp.begin();
if (!status) {
while (1);
}
char startTemperature(void);
delay(500);
status = bmp.startPressure(3);
if (status != 0)
{
// this will prevent drift and give a more precise measurement at "3"
}
// Wait for the measurement to complete:
delay(status);
baseline = (bmp.getPressure());
Serial1.begin(9600);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
delay(1000);
if (!SD.begin(chipSelect)) {
Serial.println("SD not found ");
return;
}
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
delay(1000);
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
// manual reset
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
while (!rf95.init()) {
Serial.println("LoRa radio init failed");
Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
while (1);
}
Serial.println("LoRa radio init OK!");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(RF95_FREQ)) {
Serial.println("setFrequency failed");
while (1);
}
Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
rf95.setTxPower(23, false);
//Leave False NO RFO on Feather
rf95.setModemConfig(RH_RF95::Bw31_25Cr48Sf512);
main_folder = SD.open("/");
fileName = sd_saver(main_folder);
}
int16_t packetnum = 0; // packet counter, we increment per xmission
void loop()
{
float flat, flon, alt;
unsigned long age, date, time, chars = 0;
unsigned short sentences = 0, failed = 0;
int year;
byte month, day, hour, minute, second, hundredths;
Serial1.begin(9600);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
delay(1000);
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
gps.f_get_position(&flat, &flon, &age);
char sz[32];
sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d",
month, day, year, hour - 4, minute, second);
Serial.print(sz);
Serial.print(", ");
Serial.print(flat, 6);
Serial.print(", ");
Serial.print(flon, 6);
Serial.print(", ");
Serial.print(bmp.getPressure(), 5);
delay(260);
Serial.print(", ");
Serial.println(bmp.altitude() * 3.28084, 2);//altitude in feet 2 decimal places
smartdelay(2000);
dataFile = SD.open("DATA" + fileName + ".txt", FILE_WRITE);
if (dataFile) {
dataFile.print(sz);
dataFile.print(", ");
dataFile.print(flat, 6);
dataFile.print(", ");
dataFile.print(flon, 6);
dataFile.print(", ");
dataFile.print(bmp.getPressure(), 5);
dataFile.print(", ");
dataFile.println(bmp.altitude() * 3.28084, 2); //altitude in feet 2 decimal places
dataFile.close();
}
else {
Serial.println("Not Writing");
}
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
delay(1000);
char dataPKG [RH_RF95_MAX_MESSAGE_LEN];
sprintf (dataPKG, "%f, %f, %f, %f", flat, flon, (bmp.getPressure()), baseline);
Serial.println (dataPKG);
Serial.println("Transmitting..."); // Send a message to rf95_server
dataPKG[69] = 0;
Serial.println("Sending...");
delay(10);
rf95.waitPacketSent();
rf95.send((uint8_t *)dataPKG, 70);
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
Serial.println("Waiting for reply...");
if (rf95.waitAvailableTimeout(3000))
{
// Should be a reply message for us now
if (rf95.recv(buf, &len))
{
Serial.print("Got reply: ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf95.lastRssi(), DEC);
}
else
{
Serial.println("Receive failed");
}
}
else
{
Serial.println("No reply, is there a listener around?");
}
}
String sd_saver(File dir) {
while (true) {
// iterate all files to ensure no overwrites
File entry = dir.openNextFile();
if (!entry) {
break;
}
// naming routine
String entry_name = entry.name();
if ((entry_name.substring(4, 7)).toInt() >= prev_file_indx) {
prev_file_indx = (entry_name.substring(4, 7)).toInt() + 1;
if (prev_file_indx >= 100) {
fileName = String(prev_file_indx);
} else if (prev_file_indx >= 10) {
fileName = "0" + String(prev_file_indx);
} else {
fileName = "00" + String(prev_file_indx);
}
}
entry.close();
}
return fileName;
}
Any insight as to where I am going wrong is greatly appreciated. Thank you