Reset as distance is > 8 meter
This commit is contained in:
parent
66f61a69db
commit
9eb16637dc
@ -13,9 +13,9 @@ VL53L0X tankSensor;
|
|||||||
|
|
||||||
void initializeTanksensor() {
|
void initializeTanksensor() {
|
||||||
Wire.begin(SENSOR_TANK_SDA, SENSOR_TANK_SCL, 100000UL /* 100kHz */);
|
Wire.begin(SENSOR_TANK_SDA, SENSOR_TANK_SCL, 100000UL /* 100kHz */);
|
||||||
tankSensor.setTimeout(500);
|
|
||||||
tankSensor.setBus(&Wire);
|
tankSensor.setBus(&Wire);
|
||||||
delay(20);
|
delay(100);
|
||||||
|
tankSensor.setTimeout(500);
|
||||||
long start = millis();
|
long start = millis();
|
||||||
bool distanceReady = false;
|
bool distanceReady = false;
|
||||||
while (start + 500 > millis())
|
while (start + 500 > millis())
|
||||||
@ -64,11 +64,10 @@ void loop() {
|
|||||||
if (!tankSensor.timeoutOccurred())
|
if (!tankSensor.timeoutOccurred())
|
||||||
{
|
{
|
||||||
uint16_t distance = tankSensor.readRangeSingleMillimeters();
|
uint16_t distance = tankSensor.readRangeSingleMillimeters();
|
||||||
if (distance == 8191) {
|
if (distance > 8000) {
|
||||||
Serial.println("Reset due to 8.191 meter");
|
Serial.println("Reset due invalid distance: 8 meter");
|
||||||
tankSensor.stopContinuous();
|
|
||||||
Wire.end();
|
Wire.end();
|
||||||
delay(100);
|
delay(1000);
|
||||||
initializeTanksensor();
|
initializeTanksensor();
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Distance");
|
Serial.print("Distance");
|
||||||
|
Loading…
Reference in New Issue
Block a user