@@ -115,7 +115,7 @@ bool fifoFull = false;
115
115
int fifoCount = 0 ;
116
116
int STA_len = 32 ; // can change to 125
117
117
int LTA_len = 320 ; // can change to 1250
118
- int QUE_len = LTA_len + STA_len;
118
+ int QUE_len = LTA_len + STA_len;
119
119
120
120
// --------------------------------------------------------------------------------------------
121
121
// Variables to hold accelerometer data
@@ -658,7 +658,7 @@ void NetworkEvent(WiFiEvent_t event) {
658
658
// MQTT SSL requires a relatively accurate time between broker and client
659
659
void SetTimeESP32 () {
660
660
// Set time from NTP servers
661
- configTime (TZ_OFFSET * 3600 , TZ_DST * 60 , " pool.ntp.org " , " 0. pool.ntp.org" );
661
+ configTime (TZ_OFFSET * 3600 , TZ_DST * 60 , " time.nist.gov " , " pool.ntp.org" );
662
662
Serial.println (" \n Waiting for time" );
663
663
while (time (nullptr ) <= 100000 ) {
664
664
NeoPixelStatus ( LED_FIRMWARE_DFU ); // blink yellow
@@ -778,8 +778,8 @@ double stalta[3] = { 0, 0, 0 };
778
778
double sample[3 ] = { 0 , 0 , 0 };
779
779
double sampleSUM[3 ] = { 0 , 0 , 0 };
780
780
double ltSUM[3 ] = { 0 , 0 , 0 };
781
- double sample1[3 ] = { 0 , 0 , 0 };
782
- double LTAsample1[3 ] = { 0 , 0 , 0 };
781
+ double sample1[3 ] = { 0 , 0 , 0 };
782
+ double LTAsample1[3 ] = { 0 , 0 , 0 };
783
783
double offset[3 ] = { 0 , 0 , 0 };
784
784
double sampleABS[3 ] = { 0 , 0 , 0 };
785
785
double sample1ABS = 0 ;
@@ -845,17 +845,17 @@ void loop() {
845
845
// But why are the first two z samples bad ?
846
846
// Serial.printf(".sample[2] = %f ", sample[2]);
847
847
for (int j = 0 ; j < 3 ; j++) {
848
- sampleSUM[j] += sample[j];
849
- }
848
+ sampleSUM[j] += sample[j];
849
+ }
850
850
}
851
851
}
852
852
// Serial.printf(".offset = ");
853
853
for (int j = 0 ; j < 3 ; j++) {
854
- offset[j] = sampleSUM[j] / (QUE_len-2 );
855
- // Serial.printf( " %f ", offset[j]);
854
+ offset[j] = sampleSUM[j] / (QUE_len-2 );
855
+ // Serial.printf( " %f ", offset[j]);
856
856
}
857
857
// Serial.printf("\n");
858
-
858
+
859
859
// // find lta
860
860
sampleSUM[0 ] = 0 ;
861
861
sampleSUM[1 ] = 0 ;
@@ -867,14 +867,14 @@ void loop() {
867
867
sampleABS[1 ] = abs ( AccelRecord.y - offset[1 ] );
868
868
sampleABS[2 ] = abs ( AccelRecord.z - offset[2 ] );
869
869
for (int j = 0 ; j < 3 ; j++) {
870
- sampleSUM[j] += sampleABS[j];
870
+ sampleSUM[j] += sampleABS[j];
871
871
}
872
872
}
873
873
}
874
874
// Serial.printf(".sum32abs = ");
875
875
for (int j = 0 ; j < 3 ; j++) {
876
- ltav[j] = sampleSUM[j] / (LTA_len-2 );
877
- // Serial.printf( " %f ", sampleSUM[j]);
876
+ ltav[j] = sampleSUM[j] / (LTA_len-2 );
877
+ // Serial.printf( " %f ", sampleSUM[j]);
878
878
}
879
879
880
880
// // find sta
@@ -888,22 +888,22 @@ void loop() {
888
888
sampleABS[1 ] = abs ( AccelRecord.y - offset[1 ] );
889
889
sampleABS[2 ] = abs ( AccelRecord.z - offset[2 ] );
890
890
for (int j = 0 ; j < 3 ; j++) {
891
- sampleSUM[j] += sampleABS[j];
891
+ sampleSUM[j] += sampleABS[j];
892
892
}
893
893
}
894
894
}
895
895
for (int j = 0 ; j < 3 ; j++) {
896
- stav[j] = sampleSUM[j] / STA_len;
896
+ stav[j] = sampleSUM[j] / STA_len;
897
897
stalta[j] = stav[j] / ltav[j];
898
- if ( bPossibleEarthQuake==false ) {
898
+ if ( bPossibleEarthQuake==false ) {
899
899
if ( stalta[j] >= thresh ) {
900
900
// Whoa - STA/LTA algorithm detected some anomalous shaking
901
901
Serial.printf (" %f = %f / %f (%i) s0\n " , stalta[j], stav[j], ltav[j], j );
902
902
}
903
- }
904
- }
903
+ }
904
+ }
905
905
906
- // // find sta / lta for the other 31 samples but without doing the summing again
906
+ // // find sta / lta for the other 31 samples but without doing the summing again
907
907
908
908
for (int idx = LTA_len+1 ; idx < QUE_len; idx++) {
909
909
AccelReading AccelRecord;
@@ -920,7 +920,7 @@ void loop() {
920
920
if ( StaLtaQue.peekIdx ( &AccelRecord, idx-LTA_len) ) {
921
921
LTAsample1[0 ] = AccelRecord.x ;
922
922
LTAsample1[1 ] = AccelRecord.y ;
923
- LTAsample1[2 ] = AccelRecord.z ;
923
+ LTAsample1[2 ] = AccelRecord.z ;
924
924
}
925
925
for (int j = 0 ; j < 3 ; j++) {
926
926
sampleABS[j] = abs (sample[j] - offset[j]);
@@ -929,16 +929,16 @@ void loop() {
929
929
stav[j] += ( sampleABS[j] - sample1ABS) / STA_len;
930
930
ltav[j] += ( sampleABS[j] - LTAsample1ABS) / LTA_len;
931
931
stalta[j] = stav[j] / ltav[j];
932
- if ( bPossibleEarthQuake==false ) {
932
+ if ( bPossibleEarthQuake==false ) {
933
933
if ( stalta[j] >= thresh ) {
934
934
// Whoa - STA/LTA algorithm detected some anomalous shaking
935
935
Serial.printf (" %f = %f / %f (%i)\n " , stalta[j], stav[j], ltav[j], j );
936
936
bPossibleEarthQuake = true ;
937
937
}
938
938
}
939
- }
939
+ }
940
940
}
941
- }
941
+ }
942
942
943
943
// If STA/LTA algorithm detected some anomalous shaking
944
944
if ( bPossibleEarthQuake ) {
@@ -1212,7 +1212,7 @@ void NeoPixelStatus( int status ) {
1212
1212
1213
1213
1214
1214
void NeoPixelBreathe () {
1215
- if ( breatheintensity < 0 )
1215
+ if ( breatheintensity < 0 )
1216
1216
breatheintensity = 0 ;
1217
1217
strip.setBrightness ( breatheintensity ); // slow breathe the LED
1218
1218
// Serial.printf("Brightness is %d\n",breatheintensity);
0 commit comments