Hi All,
i am trying to use sleep mode function to my code, but seems it doesn’t like my code, it flashing Magenta after sending data instead of going sleep.
i want to make the boron to sleep for 10 min then wake send me the signal then back,
can you please check if i miss something here in the code below? it used to work perfect on particle electron
const uint32_t msSAMPLE_INTERVAL = 2500;
const uint32_t msMETRIC_PUBLISH = 5000;
uint32_t msLastMetric;
uint32_t msLastSample;
void setup() {
// initialize serial communication:
Serial.begin(9600);
Wire.begin();
pinMode(pump_pin, OUTPUT);
}
void loop {
float duration, inches, cm;
// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(10);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
xx= cm;
Serial.print(inches);
Serial.print("in, ");
Serial.print("\t");
Serial.print(cm);
Serial.print("cm");
Serial.println();
/////////////////////////////////////////////////////////////////
samples.add(xx);
float l = samples.getLowest();
float m = samples.getMedian();
float a = samples.getAverage();
float h = samples.getHighest();
// lowest =l;
average = a;
median = m;
//////////////////////////////////////////////////////////////
if (millis() - msLastMetric >= msMETRIC_PUBLISH){
pumpactivator();
System.sleep(SLEEP_MODE_DEEP,600);
}
}