Keep bmp180 status information
This commit is contained in:
parent
9ca3c49aa2
commit
e99f63ef41
@ -1,3 +1,15 @@
|
||||
SFE_BMP180 bmp180;
|
||||
int bmp180Connected = 0;
|
||||
|
||||
int setupBMP180() {
|
||||
bmp180Connected = bmp180.begin(SDA, SCL);
|
||||
return bmp180Connected;
|
||||
}
|
||||
|
||||
bool isBMPConnected() {
|
||||
return bmp180Connected != 0;
|
||||
}
|
||||
|
||||
int getTemperature(double &t) {
|
||||
char status;
|
||||
status = bmp180.startTemperature();
|
||||
|
@ -5,6 +5,7 @@ void handleRoot() {
|
||||
"Current temperature " + String(temp, 2) + "C<br/>"
|
||||
"Current pressure " + String(pressure, 2) + "mB<br/>"
|
||||
"MQTT Status: " + (MQTT_isConnected() ? "Connected" : "Disconnected") + "<br/>"
|
||||
"BMP 180 (Temp+Pression) Status: " + (isBMPConnected() ? "Connected" : "Disconnected") + "<br/>"
|
||||
"Free space: "+ ESP.getFreeSketchSpace() +"<br/>"
|
||||
"Free heap: "+ ESP.getFreeHeap() +"<br/>"
|
||||
"<a href=\"/setup\">Setup</a><br/>"
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
//#define ENABLE_EXTRA_GPIO
|
||||
|
||||
#define EEPROM_SIZE 512
|
||||
#define EEPROM_SIZE 256
|
||||
char eeprom[EEPROM_SIZE];
|
||||
|
||||
#define WEB_DELAY_MS 100
|
||||
@ -49,7 +49,6 @@ uint8_t mode;
|
||||
const char *ssid = "ESPConfigurator";
|
||||
|
||||
ESP8266WebServer server(80);
|
||||
SFE_BMP180 bmp180;
|
||||
|
||||
/* WebServer decl*/
|
||||
void handleRoot();
|
||||
@ -68,6 +67,9 @@ void readEEPROM(uint8_t &bootMode, char **ssid, char **password, char **host, ch
|
||||
/* BMP180 decl */
|
||||
int getTemperature(double &t);
|
||||
int getTempAndPressure(double &t, double &p);
|
||||
int setupBMP180();
|
||||
bool isBMPConnected();
|
||||
|
||||
|
||||
/* MQTT decl */
|
||||
int MQTT_connect();
|
||||
@ -195,7 +197,7 @@ void setup() {
|
||||
if (mode == BOOTMODE_OTA) {
|
||||
setupOTA();
|
||||
} else {
|
||||
if (bmp180.begin(SDA, SCL))
|
||||
if (setupBMP180())
|
||||
Serial.println("BMP180 init success");
|
||||
setupWebServer(mode);
|
||||
}
|
||||
@ -210,7 +212,7 @@ void loop() {
|
||||
delay(WEB_DELAY_MS);
|
||||
nbCycle++;
|
||||
if (nbCycle > SAMPLING_PERIODE_MS / WEB_DELAY_MS) {
|
||||
if (getTempAndPressure(temp, pressure) == 0) {
|
||||
if (isBMPConnected() && getTempAndPressure(temp, pressure) == 0) {
|
||||
Serial.print("Current T°C ");
|
||||
Serial.print(temp);
|
||||
Serial.print( " Pressure mB ");
|
||||
|
Loading…
Reference in New Issue
Block a user