30
30
#define DATA_PIN 7 /* !< The pin of the SDI-12 data bus */
31
31
#define POWER_PIN 22 /* !< The sensor power pin (or -1 if not switching power) */
32
32
#define FIRST_ADDRESS 0
33
- #define LAST_ADDRESS 1 // 62
33
+ #define LAST_ADDRESS 6 // 62
34
34
#define WAKE_DELAY 0 /* !< The extra time needed for the board to wake. */
35
35
#define COMMANDS_TO_TEST \
36
- 10 /* !< The number of measurement commands to test, between 1 and 10 . */
36
+ 2 /* !< The number of measurement commands to test, between 1 and 11 . */
37
37
38
38
/* * Define the SDI-12 bus */
39
39
SDI12 mySDI12 (DATA_PIN);
40
40
41
41
// / variable that alternates output type back and forth between parsed and raw
42
42
boolean flip = 0 ;
43
43
44
- String commands[] = {" 2 " , " 2 " , " 2 " , " 2" , " 2 " , " 2 " , " 2 " , " 2 " , " " , " 1 " , " 3" , " 4" , " 5" , " 6" , " 7" , " 8" , " 9" };
44
+ String commands[] = {" " , " 0 " , " 1 " , " 2" , " 3" , " 4" , " 5" , " 6" , " 7" , " 8" , " 9" };
45
45
46
46
// keeps track of active addresses
47
47
bool isActive[LAST_ADDRESS - FIRST_ADDRESS] = {
@@ -425,7 +425,7 @@ String takeMeasurement(char i, String meas_type = "", bool printCommands = true)
425
425
mySDI12.clearBuffer ();
426
426
427
427
// return getResults(i, numResults,printCommands);
428
- String res= getStringResults (i, numResults, printCommands);
428
+ String res = getStringResults (i, numResults, printCommands);
429
429
Serial.print (" Result: " );
430
430
Serial.println (res);
431
431
return res;
@@ -529,9 +529,9 @@ void setup() {
529
529
}
530
530
531
531
void loop () {
532
- flip = !flip; // flip the switch between concurrent and not
532
+ // flip = !flip; // flip the switch between concurrent and not
533
533
// flip = 1;
534
- // flip = 0;
534
+ flip = 0 ;
535
535
uint32_t start = millis ();
536
536
Serial.print (" Flip: " );
537
537
Serial.println (flip);
@@ -559,8 +559,11 @@ void loop() {
559
559
if (isActive[i]) {
560
560
for (uint8_t a = 0 ; a < COMMANDS_TO_TEST; a++) {
561
561
Serial.print (" Command " );
562
- Serial.println (commands[a]);
563
- this_result[i] = takeMeasurement (addr, commands[a], false );
562
+ Serial.print (i);
563
+ Serial.print (" M" );
564
+ Serial.print (commands[a]);
565
+ Serial.println (' !' );
566
+ this_result[i] = takeMeasurement (addr, commands[a], true );
564
567
}
565
568
// getContinuousResults(addr, 3);
566
569
Serial.println ();
@@ -570,19 +573,24 @@ void loop() {
570
573
Serial.println (millis () - start);
571
574
} else {
572
575
for (uint8_t a = 0 ; a < COMMANDS_TO_TEST; a++) {
573
- Serial.print (" Command " );
574
- Serial.println (commands[a]);
575
- uint8_t min_wait = 127 ;
576
- uint8_t max_wait = 0 ;
576
+ uint8_t min_wait = 127 ;
577
+ uint8_t max_wait = 0 ;
577
578
uint32_t for_start = millis ();
578
579
// start all sensors measuring concurrently
579
580
for (byte i = FIRST_ADDRESS; i < LAST_ADDRESS; i++) {
580
581
char addr = decToChar (i);
581
- if (isActive[i]) { startConcurrentMeasurement (addr, commands[a], false ); }
582
+ if (isActive[i]) {
583
+ Serial.print (" Command " );
584
+ Serial.print (i);
585
+ Serial.print (" C" );
586
+ Serial.print (commands[a]);
587
+ Serial.println (' !' );
588
+ startConcurrentMeasurement (addr, commands[a], true );
589
+ }
582
590
if (waitTime[i] < min_wait) { min_wait = waitTime[i]; }
583
591
if (waitTime[i] > max_wait) { max_wait = waitTime[i]; }
584
592
}
585
- min_wait = max (0 , (min_wait - 1 ) / 2 );
593
+ min_wait = max (1 , (min_wait - 1 ) / 2 );
586
594
max_wait = max (1 , max_wait + 1 );
587
595
// Serial.print("minimum expected wait: ");
588
596
// Serial.println(min_wait);
@@ -604,7 +612,7 @@ void loop() {
604
612
// if (millis() > millisReady[i]) {
605
613
// if (millis() > millisStarted[i] + a) {
606
614
if (returnedResults[i] > 0 ) {
607
- this_result[i] = getStringResults (addr, returnedResults[i], false );
615
+ this_result[i] = getStringResults (addr, returnedResults[i], true );
608
616
// if (this_result[i] != "") {
609
617
// Serial.print("timeWaited: ");
610
618
// Serial.print(timeWaited);
0 commit comments