resets at start with R, sends 0's if no sensor present

pull/58/head
alanbjohnston 5 years ago committed by GitHub
parent 4f0e0ca66e
commit 0f3fe767c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,7 @@ MPU6050 mpu6050(Wire);
int counter = 0; int counter = 0;
int RXLED = 17; // The RX LED has a defined Arduino pin int RXLED = 17; // The RX LED has a defined Arduino pin
long timer = 0; long timer = 0;
bmePresent = 1; int bmePresent;
void setup() { void setup() {
@ -23,14 +23,15 @@ void setup() {
Serial.println("Starting!"); Serial.println("Starting!");
digitalWrite(RXLED, LOW); // set the RX LED ON digitalWrite(RXLED, LOW); // set the RX LED ON
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
delay(50); // wait for a second delay(50); // wait for a second
digitalWrite(RXLED, HIGH); // set the RX LED ON digitalWrite(RXLED, HIGH); // set the RX LED ON
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
if (!bme.begin(0x76)) { if (bme.begin(0x76)) {
bmePresent = 1;
} else {
Serial.println("Could not find a valid BME280 sensor, check wiring!"); Serial.println("Could not find a valid BME280 sensor, check wiring!");
bmePresent = 0; bmePresent = 0;
} }
@ -49,9 +50,13 @@ void loop() {
digitalWrite(RXLED, HIGH); // set the RX LED ON digitalWrite(RXLED, HIGH); // set the RX LED ON
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
char result = Serial.read(); char result = Serial.read();
// Serial1.println(result); // Serial.println(result);
if (result == 'R')
setup(); if (result == 'R') {
Serial.println("OK");
delay(500);
setup();
}
if (bmePresent) { if (bmePresent) {
Serial.print("OK BME280 "); Serial.print("OK BME280 ");
Serial.print(bme.readTemperature()); Serial.print(bme.readTemperature());
@ -85,8 +90,12 @@ void loop() {
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
char result = Serial1.read(); char result = Serial1.read();
// Serial1.println(result); // Serial1.println(result);
if (result == 'R')
setup(); if (result == 'R') {
Serial1.println("OK");
delay(500);
setup();
}
if (bmePresent) { if (bmePresent) {
Serial1.print("OK BME280 "); Serial1.print("OK BME280 ");
Serial1.print(bme.readTemperature()); Serial1.print(bme.readTemperature());
@ -112,6 +121,6 @@ void loop() {
// Serial1.println(counter++); // Serial1.println(counter++);
} }
#endif #endif
delay(100); delay(100);
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.