Same return value for every sensor after Setup()
This commit is contained in:
parent
ff4f72e1f7
commit
786fedc74f
@ -5,9 +5,6 @@
|
||||
|
||||
// Get Current altitude with http://fr.mygeoposition.com/
|
||||
#define ALTITUDE 130
|
||||
SFE_BMP180 bmp180;
|
||||
int bmp180Connected = 0;
|
||||
|
||||
int BMP180GetTemperature(double &t);
|
||||
int BMP180GetTempAndPressure(double &t, double &p);
|
||||
int BMP180Setup(int sda, int scl);
|
||||
|
@ -1,12 +1,18 @@
|
||||
#ifdef CONFIG_ENABLE_BMP180
|
||||
#include "BMP180.h"
|
||||
SFE_BMP180 bmp180;
|
||||
int bmp180Connected = 0;
|
||||
|
||||
int BMP180Setup(int sda, int scl) {
|
||||
//Use BMP fork at https://github.com/mmaret/BMP180_Breakout_Arduino_Library/archive/master.zip
|
||||
bmp180Connected = bmp180.begin(sda, scl);
|
||||
if (!bmp180Connected){
|
||||
SKETCH_DEBUG_PRINTLN("Cannot connect to BMP180");
|
||||
goto err;
|
||||
}
|
||||
return bmp180Connected;
|
||||
return 0;
|
||||
err:
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool BMP180IsConnected() {
|
||||
|
@ -228,10 +228,10 @@ void setup() {
|
||||
if (mode == BOOTMODE_OTA) {
|
||||
OTASetup();
|
||||
} else {
|
||||
if (BMP180Setup(CONFIG_BMP180_SDA, CONFIG_BMP180_SCL)){
|
||||
if (!BMP180Setup(CONFIG_BMP180_SDA, CONFIG_BMP180_SCL)){
|
||||
SKETCH_DEBUG_PRINTLN("BMP180 init success");
|
||||
}
|
||||
if (DHTSetup(CONFIG_DHT_PIN)){
|
||||
if (!DHTSetup(CONFIG_DHT_PIN)){
|
||||
SKETCH_DEBUG_PRINTLN("DHT init success");
|
||||
}
|
||||
WebSetupServer(mode);
|
||||
@ -252,14 +252,14 @@ void loop() {
|
||||
|
||||
nbCycle++;
|
||||
if (nbCycle > CONFIG_SAMPLING_PERIODE_MS / CONFIG_WEB_DELAY_MS) {
|
||||
if (BMP180GetTempAndPressure(temp, pressure) == 0) {
|
||||
if (!BMP180GetTempAndPressure(temp, pressure)) {
|
||||
SKETCH_DEBUG_PRINT("Current T°C ");
|
||||
SKETCH_DEBUG_PRINT(temp);
|
||||
SKETCH_DEBUG_PRINT(" Pressure mB ");
|
||||
SKETCH_DEBUG_PRINTLN(pressure);
|
||||
MqttPublish(temp, pressure);
|
||||
}
|
||||
if (DHTGetTempAndHumidity(dhtTemp, dhtHumidity) == 0) {
|
||||
if (!DHTGetTempAndHumidity(dhtTemp, dhtHumidity)) {
|
||||
SKETCH_DEBUG_PRINT("Current T°C ");
|
||||
SKETCH_DEBUG_PRINT(dhtTemp);
|
||||
SKETCH_DEBUG_PRINT(" Humidity ");
|
||||
|
@ -8,7 +8,7 @@ int DHTGetTempAndHumidity(float &t, float &h);
|
||||
bool DHTIsConnected();
|
||||
|
||||
#else //CONFIG_ENABLE_DHT
|
||||
int DHTSetup(int pin){SKETCH_DEBUG_PRINTLN("DHT is disabled at build time"); return 0};
|
||||
int DHTSetup(int pin){SKETCH_DEBUG_PRINTLN("DHT is disabled at build time"); return -1};
|
||||
int DHTGetTempAndHumidity(float &t, float &h){return -1;};
|
||||
bool DHTIsConnected(){return false;};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user