Update to read two analog sensors

Update to read two analog sensors

--- src/Sensors/sketch_feb18a.ino
+++ src/Sensors/sketch_feb18a.ino
@@ -38,6 +38,7 @@
 float sensorReading5 = 0.00;
 float sensorReading6 = 0.00;
 float sensorReading7 = 0.00;
+float sensorReading8 = 0.00;
 File sensorData;

 void setup()
@@ -116,9 +117,15 @@
 }

 void loop(){
+  //These two reads are just raw voltage as a float from A0 and A1.
   int A0 = analogRead(0);
   sensorReading1 = A0;
   sensorReading1 = (sensorReading1 * 5.0) / 1023.0;
+
+  int A1 = analogRead(1);
+  sensorReading2 = A1;
+  sensorReading2 = (sensorReading2 * 5.0) / 1023.0;
+
     //Begin IMU data collection
     // Update the sensor values whenever new data is available
   if ( imu.gyroAvailable() )
@@ -145,19 +152,19 @@

   if ((lastPrint + PRINT_SPEED) < millis())
   {
-    sensorReading2 = imu.calcGyro(imu.gx);
-    sensorReading3 = imu.calcGyro(imu.gy);
-    sensorReading4 = imu.calcGyro(imu.gz);
+    sensorReading3 = imu.calcGyro(imu.gx);
+    sensorReading4 = imu.calcGyro(imu.gy);
+    sensorReading5 = imu.calcGyro(imu.gz);
     //accel readings
-    sensorReading5 = imu.calcAccel(imu.ax);
-    sensorReading6 = imu.calcAccel(imu.ay);
-    sensorReading7 = imu.calcAccel(imu.az);
+    sensorReading6 = imu.calcAccel(imu.ax);
+    sensorReading7 = imu.calcAccel(imu.ay);
+    sensorReading8 = imu.calcAccel(imu.az);

     lastPrint = millis(); // Update lastPrint time
   }
   // build the data string
-  dataString = String(sensorReading1) + "," + String(sensorReading2) + "," + String(sensorReading3) + "," + String(sensorReading4) + "," + String(sensorReading5) + "," + String(sensorReading6) + "," + String(sensorReading7) + ","; // convert to CSV
+  dataString = String(sensorReading1) + "," + String(sensorReading2) + "," + String(sensorReading3) + "," + String(sensorReading4) + "," + String(sensorReading5) + "," + String(sensorReading6) + "," + String(sensorReading7) + "," + String(sensorReading8) + ","; // convert to CSV
   saveData(); // save to SD card
   //delay(60000); // delay before next write to SD Card, adjust as required
 }


Neopixel, reminder switch, on and off, brightness all working

Previous reversion successful. Started again with working setup. Decided
to add a 3rd potentiometer for the neopixel brightness (instead of
pulling in the nightlight brightness).

--- jacksclock12/jacksclock12.ino
+++ jacksclock12/jacksclock12.ino
@@ -1,11 +1,9 @@
 /* ================================================================================== //
 //
-//    Jack's 420 Clock
-//
-//    *** TO DO ***
-//    * Clean up both switch functions
-//    * Auto Dim: Debounce / Smoothing
-//    * Fix RGB LED
+//    Jack's 420 Clock - 2014
+//    Written for Arduino Uno Rev. 3
+//    Adafruit Hardware: Real Time Clock: DS1307, Neopixel (40 RGB-LED) Shield,
+//    7-Segment Display, 14-Segment Aphanumeric Display, Backlight Module
 //
 // ================================================================================== */

@@ -18,13 +16,13 @@
 #include <Adafruit_NeoPixel.h>

 // Input/Output Pins
-<<<<<<< HEAD
+int neoLightIn =        A0;      // Neopixel Dimming
 int photoCellIn =       A1;      // Auto Dimming
 int nightLightIn =      A2;      // Backlight
 int clockLightIn =      A3;      // 7-Sebment
+int neoPixel =          3;       // RGB-LED: Green
+int uvLED =             7;       // LEDs: UV
 int reminderSwitchIn =  6;       // Reminder Switch *** NOT WORKING ***
-int NeoPixel =          3;       // RGB-LED: Green
-int uvLED =             7;       // LEDs: UV
 int fourTwentyLED =     9;       // LED: Green
 int piezoOut =          10;      // Speaker
 int nightLightOut =     11;      // Backlight
@@ -38,49 +36,18 @@
 int photoCellRead;               // Photo Cell
 int autoBrightAverage;           // Photo Cell
 long previousMillis;             // For counting of xfade timer
+int counter;                     // Counts notes played
 int fadeAmount = 2;              // 420 LED
-int counter;                     // Counts notes played
 int numReadings = 25;            // Smoothing function: # of Readings
 int neoBrightness = 100;         // Neopixel Shield
 boolean running = false;         // Colon On/Off
-//volatile int state = LOW;        // For Reminder Switch Interrupt
-=======
-int photoCellIn = A1;         // Auto Dimming
-int nightLightIn = A2;        // Backlight
-int clockLightIn = A3;        // 7-Sebment
-int NeoPixel = 6;             // RGB-LED: Green
-int uvLED = 7;                // LEDs: UV
-int reminderSwitchIn = 8;     // Reminder Switch *** NOT WORKING ***
-int fourTwentyLED = 9;        // LED: Green
-int piezoOut = 10;            // Speaker
-int nightLightOut = 11;       // Backlight
-int brightSwitchIn = 12;      // Auto Brightness
-int dstSwitchIn = 13;         // Savings Time Switch
-
-
-// Variables
-int clockKnob;                // Potentiometer 1
-int lightKnob;                // Potentiometer 2
-int clockBrightness;          // 7-Segment & Alphanumeric
-int lightBrightness;          // Backlight
-int dstState;                 // DST
-int reminderState;            // Switch (Reminder)
-int autoBrightState;          // Switch (Auto-Dimmer)
-int photoCellRead;            // Photo Cell
-int autoBrightAverage;        // Photo Cell
-long previousMillis;          // For counting of xfade timer
-int fourTwentyBright = 0;     // 420 LED
-int fadeAmount = 2;           // 420 LED
-boolean running = false;      // Colon On/Off
-int counter = 0;              // Counts notes played
-int numReadings = 25;         // Smoothing function: # of Readings
->>>>>>> parent of 044ddaa... Many fixes + last working version before interrupts

 // Setup Components
 RTC_DS1307 RTC;
 Adafruit_7segment disp = Adafruit_7segment();
 Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, NeoPixel, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, neoPixel, NEO_GRB + NEO_KHZ800);
+

 // ================================================================================== //
 //                                  *** SETUP ***
@@ -91,11 +58,12 @@
   pinMode (dstSwitchIn, INPUT);         // DST Button
   pinMode (nightLightIn, INPUT);        // Nightlight Potentiometer
   pinMode (reminderSwitchIn, INPUT);    // Reminder Switch
+  pinMode (neoLightIn, INPUT);          // Neopixel Potentiometer
   pinMode (brightSwitchIn, INPUT);      // Auto Brightness Switch
   pinMode (fourTwentyLED, OUTPUT);      // Green LED
   pinMode (uvLED, OUTPUT);              // UV LED
-  pinMode (NeoPixel, OUTPUT);           // Neopixel
-
+  pinMode (neoPixel, OUTPUT);           // Neopixel
+
   Serial.begin(9600);
   Wire.begin();
   RTC.begin();                                            // DSC1730 Clock
@@ -104,9 +72,8 @@
   alpha4.begin(0x71);                                     // Start Alphanumeric
   strip.begin();                                          // Start Neopixel
   strip.show();                                           // Initialize all pixels to 'off'
-
-  attachInterrupt(1, rainbowOff, LOW);                      // Interrupt
-}
+}
+

 // ================================================================================== //
 //                                  *** LOOP ***
@@ -119,11 +86,7 @@
   blinkColon();                          // Blink Colon
   adjustBrightness();                    // Check Switch & Adjust brightness
   fourTwentyCheck();                     // Check if 4:20pm & Run Alarm
-<<<<<<< HEAD
-  reminderSwitch();                      // LED / Reminder
-=======
   reminderSwitch();                      // LED / Reminder
->>>>>>> parent of 044ddaa... Many fixes + last working version before interrupts
 }

 // ================================================================================== //
@@ -251,28 +214,21 @@

 void reminderSwitch()                                   // Checks Switch & Activates LED
 {
-  Serial.println(reminderState);                        // Turn back on when ready to test this function
+  disp.drawColon(true);
+
+  //Serial.println(reminderState);                        // Turn back on when ready to test this function
   reminderState = digitalRead(reminderSwitchIn);        // Check Reminder Switch
-<<<<<<< HEAD
-  if (reminderState == HIGH) rainbowCycle(35);             // If On: Run Rainbow Crossfade
-=======
-  if (reminderState == 1)                               // If On: Run Crossfade Part 1 / 3
-  {
-  rainbowCycle(1);
-  }
-  else
-  {
-  strip.show();                                           // Initialize all pixels to 'off'
-  }
->>>>>>> parent of 044ddaa... Many fixes + last working version before interrupts
-}
-
-void rainbowOff()
-{
-   // if (reminderState == LOW)
-    strip.show();                 // Turn pixels off
-}
-
+  if (reminderState == 1)
+  {
+    rainbowCycle(25);
+  }
+  if (reminderState == 0)
+  {
+    strip.setBrightness(0);
+    strip.show();
+  }
+}
+

 void smooth()                                           // Cleans up photocell input
 {
@@ -289,8 +245,7 @@
     total = total + readings[index];                    // add the reading to the total
     index = index + 1;                                  // advance to next position in array

-    if (index >= numReadings)                           // if we're at the end of the array...
-      index = 0;
+    if (index >= numReadings) index = 0;                           // if we're at the end of the array...

     average = total / numReadings;
     autoBrightAverage = average;
@@ -309,7 +264,7 @@
     previousMillis = currentMillis;

     tone(piezoOut, note, duration);                          //Play tone on buzzerPin
-    if (counter % 2 == 0)
+    if (counter % 2 == 0)                                    // Alternate Green then UV LED's
     {
       digitalWrite(fourTwentyLED, HIGH);
       delay(duration);
@@ -322,17 +277,20 @@
       digitalWrite(uvLED, LOW);
     }
     noTone(piezoOut);
-
-    counter++;    //Increment counter
-  }
-}
-
-
-void rainbowCycle(uint8_t wait)                                                               // Makes the rainbow equally distributed throughout
-{
+    counter++;
+  }
+}
+
+
+void rainbowCycle(uint8_t wait)                                                            // Runs rainbow led setup
+{
   uint16_t i, j;
-  for (j = 0; j < 256 * 5; j++)                                                               // 5 cycles of all colors on wheel
-  {
+  int neoKnob = analogRead(neoLightIn);
+  int neoBrightness = map(neoKnob, 0, 1023, 1, 240);
+  strip.setBrightness(neoBrightness);                            // Set Neopixel Brightness
+
+  for (j = 0; j < 256 ; j++)                                                               // *1 cycles of all colors on wheel
+  {
     for (i = 0; i < strip.numPixels(); i++)
     {
       strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
@@ -343,8 +301,7 @@
 }

-// The colours are a transition r - g - b - r - g.... ||  Input value 0 - 255 to get a color value.
-uint32_t Wheel(byte WheelPos)
+uint32_t Wheel(byte WheelPos)                                      // The colours are a transition r - g - b - r - g.... & Input value 0 - 255 to get a color value.
 {
   if (WheelPos < 85)
   {
@@ -371,13 +328,13 @@
 void adjustBrightness()                                          // Brightness Check & Adjust
 {
   smooth();                                                      // Averages photocell readings
-  clockKnob = analogRead(clockLightIn);                          // Check & Map Potentiometers/Photocell
-  clockBrightness = map(clockKnob, 0, 1023, 2, 15);
-  lightKnob = analogRead(nightLightIn);
-  lightBrightness = map(lightKnob, 0, 1023, 50, 255);
+  int clockKnob = analogRead(clockLightIn);                      // Check & Map Potentiometers/Photocell
+  int clockBrightness = map(clockKnob, 0, 1023, 2, 15);
+  int lightKnob = analogRead(nightLightIn);
+  int lightBrightness = map(lightKnob, 0, 1023, 50, 255);        // Backlight
   int autoBright1 = map(autoBrightAverage, 1, 1023, 2, 15);
   int autoBright2 = map(autoBrightAverage, 1, 1023, 50, 255);
-
+
   autoBrightState = digitalRead(brightSwitchIn);                 // Adjust Brightness (if Auto Switch On)
   if (autoBrightState == 1)
   {
@@ -390,9 +347,9 @@
     disp.setBrightness(clockBrightness);                          // Use Potentiometers to Set Brightness
     alpha4.setBrightness(clockBrightness);
     analogWrite(nightLightOut, lightBrightness);
-    strip.setBrightness(lightBrightness);
-  }
-}
+  }
+}
+

 void themeMusic()
 {
@@ -409,11 +366,11 @@
     beep(NOTE_C4, 500);
     beep(NOTE_E4, 250);
     beep(NOTE_F4, 250);
-  }
-  beep(NOTE_G4, 500);
-  beep(NOTE_C4, 250);
-  beep(NOTE_E4, 250);
-  beep(NOTE_F4, 250);
+    beep(NOTE_G4, 500);
+    beep(NOTE_C4, 250);
+    beep(NOTE_E4, 250);
+    beep(NOTE_F4, 250);
+  }
   for (int i = 0; i < 3; i++)
   {
     beep(NOTE_G3, 500);
@@ -423,3 +380,4 @@
   }
 }

+


master "UM" for all slaves

master "UM" for all slaves

sending "UM" to master camera causes it to be sent to all slaves

--- c_I2C.ino
+++ c_I2C.ino
@@ -372,12 +372,22 @@
     previous_sync = millis();
     interrupts();
     break;
+  case SET_CAMERA_USBMODE:
+#ifdef USE_GENLOCK
+    if (1) { // send to Dongle
+      Serial.print(F("UM"));  // Warn: UM is sent to Dongle but Dongle should not send it to Bacpac.
+      printHex(buf[3], true);
+      Serial.println("");
+      Serial.flush();
+    }
+#endif
+    waiting = true;
+    break;
   case GET_CAMERA_INFO:
   case GET_CAMERA_SETTING:
   case SET_CAMERA_SETTING:
   case SET_CAMERA_VIDEO_OUTPUT:
   case SET_CAMERA_AUDIOINPUTMODE:
-  case SET_CAMERA_USBMODE:
   case SET_CAMERA_DATE_TIME:
     waiting = true; // don't read command from the queue until a reply is received.
     break;


Serial API - Date and time can be set through the API.

--- DiveIno.ino
+++ DiveIno.ino
@@ -168,7 +168,6 @@
 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
 	setSyncProvider((unsigned long int (*)())RTC.get);
 #endif
-
     Serial.print(F("Current time: "));
     Serial.println(settings.getCurrentTimeText());

@@ -376,6 +375,61 @@
 		setSettingsToDefault();
 		saveSettings();
 		responseMessage += F("DEFAULT settings were set.");
+		Serial.println(responseMessage);
+	} else if (message.startsWith(F("DATETIME")) || message.startsWith(F("datetime"))) {
+		String dateTime = message.substring(8);
+		dateTime.trim();
+
+		int year = 2016;
+		int month = 0;
+		int day = 0;
+		int hour = 0;
+		int minute = 0;
+		int second = 0;
+
+		year = dateTime.substring(0, 4).toInt();
+		month = dateTime.substring(5, 7).toInt();
+		day = dateTime.substring(8, 10).toInt();
+		hour = dateTime.substring(11, 13).toInt();
+		minute = dateTime.substring(14, 16).toInt();
+
+		responseMessage += F("Year: ");
+		responseMessage += year;
+		responseMessage += F(" Month: ");
+		responseMessage += month;
+		responseMessage += F(" Day: ");
+		responseMessage += day;
+
+		responseMessage += F(" Hour: ");
+		responseMessage += hour;
+		responseMessage += F(" Minute: ");
+		responseMessage += minute;
+		responseMessage += "\n";
+
+		if (year < 2017) {
+			responseMessage += F("ERROR: Invalid argument - Year must be greater than 2017!");
+		} else if (month < 1 || month > 12) {
+			responseMessage += F("ERROR: Invalid argument - Month must be between 1 and 12!");
+		} else if (day < 1 || day > 31) {
+			responseMessage += F("ERROR: Invalid argument - Day must be between 1 and 31!");
+		} else if (hour < 0 || hour > 23) {
+			responseMessage += F("ERROR: Invalid argument - Hour must be between 0 and 23!");
+		} else if (minute < 0 || minute > 59) {
+			responseMessage += F("ERROR: Invalid argument - Minute must be between 0 and 59!");
+		} else {
+			DateTimeSettings* dateTimeSettings = new DateTimeSettings;
+			dateTimeSettings->year = year;
+			dateTimeSettings->month = month;
+			dateTimeSettings->day = day;
+			dateTimeSettings->hour = hour;
+			dateTimeSettings->minute = minute;
+			dateTimeSettings->second = 0;
+
+			settings.setCurrentTime(dateTimeSettings);
+
+			responseMessage += F("DATETIME settings were set to ");
+			responseMessage += settings.getCurrentTimeText();
+		}
 		Serial.println(responseMessage);
 	}


cosmetix and tests, input part still not convincing

--- Flasher.ino
+++ Flasher.ino
@@ -84,7 +84,7 @@
 //
 FLASH_STRING(help_main, "Main menu, options:\n"
         "a    - enter <a>address from where to read\n"
-	      "f    - toggle output <f>ormat\n"
+        "f    - toggle output <f>ormat\n"
         "l    - enter <l>ength of data to read\n"
         "r    - <r>ead length bytes\n"
         "h, ? - display this <h>elp\n"
@@ -126,26 +126,30 @@

       case 'a':  // --- set the base address
       case 'A':
-          Serial.print("\nEnter start address? "); Serial.flush();
-          eepromAddr = readInt(); // readUInt32();
+          Serial.print(F("\nEnter start address? ")); Serial.flush();
+          //eepromAddr = readInt(); // readUInt32();
+          eepromAddr = Serial.parseInt();
+          Serial.println(eepromAddr);
         break;

       case 'f':  // --- toggle output format
       case 'F':
           if ( output_format == 0 ) {
 	          output_format = 1;
-	          Serial.println("Switched to IHEX output format!");
+	          Serial.println(F("Switched to IHEX output format!"));
 	        }
 	        else {
 	          output_format = 0;
-	          Serial.println("Switched to DUMP output format!");
+	          Serial.println(F("Switched to DUMP output format!"));
       	  }
         break;

       case 'l':  // --- set the length
       case 'L':
-        Serial.print("\nEnter block length? "); Serial.flush();
-        total_length = readInt(); // readUInt32();
+        Serial.print(F("\nEnter block length? ")); Serial.flush();
+        //total_length = readInt(); // readUInt32();
+        total_length = Serial.parseInt();
+        Serial.println(total_length);
         break;

       case 'r':  // --- read length bytes starting from address
@@ -170,8 +174,10 @@
       case 's':  // --- show information
       case 'S':
           Serial.println();
-          Serial.print("Start address: "); Serial.println(eepromAddr);
-          Serial.print("Block length:  "); Serial.println(total_length);
+          Serial.print(F("Start address: ")); printHex(eepromAddr, 6);
+          Serial.println();
+          Serial.print(F("Block length:    ")); printHex(total_length, 4);
+          Serial.println();
         break;

       case 'h':
@@ -332,4 +338,4 @@

   delay(2500);
 }
-
+


Update trigger.ino

Update trigger.ino

add more debugging outputs, simplify door-test ifthen

--- esp8266/trigger/trigger.ino
+++ esp8266/trigger/trigger.ino
@@ -38,7 +38,9 @@
 Adafruit_IO_Client aio = Adafruit_IO_Client(client, AIO_KEY);

 void setup() {
-
+  Serial.begin(115200);
+  Serial.println("HUZZAH Trigger Basic");
+
   EEPROM.begin(512);
   pinMode(DOOR, INPUT_PULLUP);

@@ -63,18 +65,18 @@

   // if door isn't open, we don't need to send anything
   if(digitalRead(DOOR) == LOW) {
-    // sleep a bit before checking again
-    ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DISABLED);
-    return;
+    Serial.println("Door closed");
+    // we don't do anything
+  } else {
+    // the door is open if we have reached here,
+    // so we should send a value to Adafruit IO.
+    Serial.println("Door is open!");
+    door_open();
   }

-  // the door is open if we have reached here,
-  // so we should send a value to Adafruit IO.
-  door_open();
-
   // we are done here. go back to sleep.
+  Serial.println("zzzz");
   ESP.deepSleep(SLEEP_LENGTH * 1000000, WAKE_RF_DISABLED);
-
 }

 // noop
@@ -85,13 +87,17 @@
 void wifi_init() {

   // wifi init
+  Serial.println("Starting WiFi");
   WiFi.begin(WLAN_SSID, WLAN_PASS);

   // wait for connection
-  while (WiFi.status() != WL_CONNECTED)
+  while (WiFi.status() != WL_CONNECTED) {
+    Serial.write('.');
     delay(500);
+  }

   // AIO init
+  Serial.println("Connecting to Adafruit.io");
   aio.begin();

 }
@@ -99,12 +105,14 @@
 void door_open() {

   // turn on wifi if we aren't connected
-  if(WiFi.status() != WL_CONNECTED)
+  if(WiFi.status() != WL_CONNECTED) {
     wifi_init();
-
+  }
+
   // grab the door feed
   Adafruit_IO_Feed door = aio.getFeed("door");

+  Serial.println("Sending to Adafruit.io");
   // send door open value to AIO
   door.send("1");

@@ -122,7 +130,7 @@

   // convert battery level to percent
   level = map(level, 580, 774, 0, 100);
-
+  Serial.print("Battery level: "); Serial.print(level); Serial.println("%");
   // turn on wifi if we aren't connected
   if(WiFi.status() != WL_CONNECTED)
     wifi_init();
@@ -132,6 +140,4 @@

   // send battery level to AIO
   battery.send(level);
-
 }
-


change baud rate to 9600

change baud rate to 9600

--- keypad/keypad.ino
+++ keypad/keypad.ino
@@ -210,8 +210,8 @@
   Serial.println("Arduino with HC-06 is ready");

   // HC-06 default baud rate is 9600
-  BTSerial.begin(38400);
-  Serial.println("BTserial started at 38400");
+  BTSerial.begin(9600);
+  Serial.println("BTserial started at 9600");
   ///////////////////////////////////////////////// END BLUETOOTH
 }


Disabled Adafruit code.

Disabled Adafruit code.

--- test/Arduino/Bosch_BNO055/Bosch_BNO055.ino
+++ test/Arduino/Bosch_BNO055/Bosch_BNO055.ino
@@ -1,8 +1,9 @@
 // Sensor stuff
 #include <Wire.h>
-#include <Adafruit_Sensor.h>
-#include <Adafruit_BNO055.h>
-#include <utility/imumaths.h>
+//#include <Adafruit_Sensor.h>
+//#include <Adafruit_BNO055.h>
+//include <utility/imumaths.h>
+#include "bno055.h"

 // MicroView OLED
 #include <MicroView.h>
@@ -45,7 +46,7 @@

-Adafruit_BNO055 bno = Adafruit_BNO055(0X0C);
+// Adafruit_BNO055 bno = Adafruit_BNO055(0X0C);

 /**************************************************************************/
 /*
@@ -55,6 +56,7 @@
 /**************************************************************************/
 void displaySensorDetails(void)
 {
+/*
   sensor_t sensor;
   bno.getSensor(&sensor);

@@ -94,6 +96,7 @@

   // show it
   uView.display();
+ */
 }

@@ -104,12 +107,13 @@
 /**************************************************************************/
 void displaySensorStatus(void)
 {
-  /* Get the system status values (mostly for debugging purposes) */
+ /*
+  // Get the system status values (mostly for debugging purposes)
   uint8_t system_status, self_test_results, system_error;
   system_status = self_test_results = system_error = 0;
   bno.getSystemStatus(&system_status, &self_test_results, &system_error);

-  /* Display the results */
+  // Display the results
   uView.clear(PAGE);

   uView.setCursor(0, 0*fontHeight);
@@ -126,15 +130,16 @@

   // show it
   uView.display();
+  */
 }

 void getCalStatus(void)
 {
-  /* Get the four calibration values (0..3) */
-  /* Any sensor data reporting 0 should be ignored, */
-  /* 3 means 'fully calibrated" */
-  bno.getCalibration(&systemCalib, &gyro, &accel, &mag);
+  // Get the four calibration values (0..3)
+  // Any sensor data reporting 0 should be ignored,
+  // 3 means 'fully calibrated"
+  // bno.getCalibration(&systemCalib, &gyro, &accel, &mag);
 }

@@ -145,11 +150,12 @@
 /**************************************************************************/
 void displayCalStatus(void)
 {
+/*
   // get status
   getCalStatus();

-  /* The data should be ignored until the system calibration is > 0 */
+  // The data should be ignored until the system calibration is > 0
   //Serial.print("\t");
   if (!systemCalib)
   {
@@ -188,6 +194,7 @@

   // show it
   uView.display();
+  */
 }

@@ -215,12 +222,12 @@
   uView.display();

-  /* Initialise the sensor */
-  if(!bno.begin())
+  // Initialise the sensor
+  if( true )
   {
     uView.clear(PAGE);
     uView.setCursor(0,0);
-    /* There was a problem detecting the BNO055 ... check your connections */
+    // There was a problem detecting the BNO055 ... check your connections
     uView.println("Ooops, no    BNO055 detected!");
     uView.print("Please check I2C.");
     uView.display();
@@ -230,23 +237,23 @@

   delay(1000);

-  /* Display some basic information on this sensor */
+  // Display some basic information on this sensor
   displaySensorDetails();
   delay(1000);

-  /* Optional: Display current status */
+  // Optional: Display current status
   displaySensorStatus();
   delay(1000);

-  bno.setExtCrystalUse(true);
+  // bno.setExtCrystalUse(true);
 }

 void loop(void)
 {
-  /* Get a new sensor event */
-  sensors_event_t event;
-  bno.getEvent(&event);
+  // Get a new sensor event
+  // sensors_event_t event;
+  // bno.getEvent(&event);

   /* Optional: Display calibration status * /
@@ -265,27 +272,27 @@

   uView.setCursor(0, 1*fontHeight);
   uView.print("X:");
-  if (event.orientation.x < 99)
-    uView.print(" ");
-  if (event.orientation.x < 9)
-    uView.print(" ");
-  uView.print(event.orientation.x, 4);
+//  if (event.orientation.x < 99)
+//    uView.print(" ");
+//  if (event.orientation.x < 9)
+//    uView.print(" ");
+//  uView.print(event.orientation.x, 4);

   uView.setCursor(0, 2*fontHeight);
   uView.print("Y:");
-  if (event.orientation.y < 99)
-    uView.print(" ");
-  if (event.orientation.y < 9)
-    uView.print(" ");
-  uView.print(event.orientation.y, 4);
+//  if (event.orientation.y < 99)
+//    uView.print(" ");
+//  if (event.orientation.y < 9)
+//    uView.print(" ");
+//  uView.print(event.orientation.y, 4);

   uView.setCursor(0, 3*fontHeight);
   uView.print("Z:");
-  if (event.orientation.z < 99)
-    uView.print(" ");
-  if (event.orientation.z < 9)
-    uView.print(" ");
-  uView.print(event.orientation.z, 4);
+//  if (event.orientation.z < 99)
+//    uView.print(" ");
+//  if (event.orientation.z < 9)
+//    uView.print(" ");
+//  uView.print(event.orientation.z, 4);

   // check callibration
   getCalStatus();
@@ -297,7 +304,7 @@
   uView.display();

-  /* Wait the specified delay before requesting nex data */
+  // Wait the specified delay before requesting nex data
   delay(BNO055_SAMPLERATE_DELAY_MS);
 }


FFT: Moved clear box; was out of bounds

FFT: Moved clear box; was out of bounds

--- examples/AnalogFFT/AnalogFFT.ino
+++ examples/AnalogFFT/AnalogFFT.ino
@@ -121,7 +121,7 @@
   // Increment time position, wipe when fully filled up
   if (++timePos >= (TD_GRAPH_X+TD_GRAPH_W)) {
     timePos = TD_GRAPH_X;
-    display.fillRect(TD_GRAPH_X, TD_GRAPH_Y+1, TD_GRAPH_W+2, TD_GRAPH_H, BLACK);
+    display.fillRect(TD_GRAPH_X, TD_GRAPH_Y, TD_GRAPH_W+2, TD_GRAPH_H+1, BLACK);
   }
 }


Tweaking IR sensor detection

Tweaking IR sensor detection

--- fed-arduino/fed-arduino.ino
+++ fed-arduino/fed-arduino.ino
@@ -29,7 +29,7 @@

 int PIStates[] = { 1, 1 };
 int lastStates[] = { 1, 1 };
-bool justMoved[] = { true, true };
+int lastTime[] = { 0, 0 };
 int pelletCount[] = { 0, 0 };

 #define FILENAME "PelletData.csv"
@@ -154,19 +154,20 @@

     logData();
     updateDisplay();
-    justMoved[inputNum] = false;
+    lastTime[inputNum] = 0;
   }
   else if (PIStates[inputNum] == 1) {
     //need to replace pellet
-    if (!justMoved[inputNum]) {
+    if (lastTime[inputNum] >= 8) {
       Serial.print(F("Replacing pellet #"));
       Serial.print(String(inputNum + 1));
       Serial.println(F("..."));
       moveMotor(inputNum);
-      justMoved[inputNum] = true;
+      lastTime[inputNum] = 6;
+      delay(200);
     }
     else
-    { delay(500); justMoved[inputNum] = false; }
+    { delay(500); lastTime[inputNum] += 1; }
   }

   else if (PIStates[inputNum] == 0 & PIStates[inputNum] != lastStates[inputNum]) {
@@ -174,13 +175,13 @@
     Serial.print(F("Pellet #"));
     Serial.print(String(inputNum + 1));
     Serial.println(F(" replaced"));
-    justMoved[inputNum] = false;
+    lastTime[inputNum] = 0;
   }

   else  { //if PIStates == 0
     //pellet still there, do nothing
     lastStates[inputNum] = PIStates[inputNum];
-    justMoved[inputNum] = false;
+    lastTime[inputNum] = 0;
     return false;
   }
   lastStates[inputNum] = PIStates[inputNum];


updated LED array

updated LED array

--- photoresistors/pcb_photoresistor_led_array_example/pcb_photoresistor_led_array_example.ino
+++ photoresistors/pcb_photoresistor_led_array_example/pcb_photoresistor_led_array_example.ino
@@ -3,57 +3,93 @@
 // Possible values are 0 - 1023 where 0 is the brightest and 1023 is the darkest
 #define SENSOR_ANALONG_PIN 0

-// Digital Pin used to read the digital output (dark = 0, not-dark = 1) from the PCB.
-#define SENSOR_DIGITAL_PIN 8
+// We will drive 5 PWM pins based on the input from the photoresitor. When using the analog
+// output from the PCB, drive the pin as a PWMs so that reflects the brightness of the
+// room.
+#define LED_ARRAY_ELEMENT_0 5
+#define LED_ARRAY_ELEMENT_1 6
+#define LED_ARRAY_ELEMENT_2 9
+#define LED_ARRAY_ELEMENT_3 10
+#define LED_ARRAY_ELEMENT_4 11

-// We will drive pin 9 based on the input from the photoresitor. When using the analog
-// output from the PCB, drive the pin as a PWM so that reflects the brightness of the
-// room. When using the digital output of the PCB, drive pin 9 high or low depending
-// to turn the LED on or off - acts as a 'trip sensor'
-#define LED_PWM_PIN        9
+static int ledArray[5] = {LED_ARRAY_ELEMENT_0, LED_ARRAY_ELEMENT_1, LED_ARRAY_ELEMENT_2, LED_ARRAY_ELEMENT_3, LED_ARRAY_ELEMENT_4};
+static const int ARRAY_SIZE = sizeof(ledArray) / sizeof(int);

 void setup() {
   // Init the serial communications for debugging messages
   Serial.begin(9600);

-  // Make the digital pin an input so we can read the values from the PCB D0 output
-  pinMode(SENSOR_DIGITAL_PIN, INPUT);
-
-  // Make the PWM pin output so we can drive the LED
-  pinMode(LED_PWM_PIN, OUTPUT);
+  // Iterate over the array and set the PWM pins to output
+  for(int i = 0; i < ARRAY_SIZE; i++) {
+    pinMode(ledArray[i], OUTPUT);
+  }
 }

 void loop() {
   // *** Uncomment this line if the data line runs from A0 on the PCB to A0 on the Arduino
-  //analogSensorPin();
+  int brightness = readAnalogSensorPin();

-  // *** Uncomment this line if the data line runs from D0 on the PCB to pin 8 of the Arduino
-  //digitalSensorPin();
+  updateLedArray(brightness);

   // Add this delay so the output is trottled to something reasonable
-  delay(1000);
+  delay(50);
 }

-void analogSensorPin() {
+int readAnalogSensorPin() {
   // Read the value on the Analog pin - represents the value from the photoresistor PCB. Values are
   // 0 (bright) to 1023 (dark)
   int analogVal = analogRead(SENSOR_ANALONG_PIN);

-  // The PWM is 0-255, where 255 is 100% duty cycle and 0 is 0% duty cycle. To dim the LED when the
-  // photoresitor has the highest resistence (brightest) first divide by 4 (1024 scale to 256 scale)
-  // and then subtract that value from 255 (highest value) to convert from the photoresistor scale
-  // to the LED scale (0 is the brightest on the photoresistor, but 255 is brightest for the LED).
-  analogWrite(LED_PWM_PIN, 255 - (analogVal / 4));
+  Serial.println(analogVal);

-  Serial.println(analogVal);
+  return analogVal;
 }

-void digitalSensorPin() {
-  // This pin will either be on or off (1 or 0). You can adjust the screw on the PCB to adjust when the line is driven high or low.
-  int digitalVal = digitalRead(SENSOR_DIGITAL_PIN);
+void updateLedArray(int brightness) {
+  // The PWM is 0-255, where 255 is 100% duty cycle and 0 is 0% duty cycle. The photoresistor is brightest when
+  // it is a analog value of 0, and darkest when it is 1023. There are more clever ways to do this than
+  // a straight up compare of the ranges, but this is clearer. If you want, you can look into bit shifting and
+  // masking to allow for dynamic array size without changing the algorithim, just the array size.
+

-  // Write the respective value to the digital Arudino pin to turn the LED on or off
-  digitalWrite(LED_PWM_PIN, digitalVal);
+  // Brightness values 820 - 1023 light up LED 0 and the others are off
+  // Brightness values 615 - 819 light up LEDs 0 and 1 and the others are off
+  // Brightness values 410 - 614 light up LEDs 0-2 and the others are off
+  // Brightness values 205 - 409 light up LEDs 0-3 and the others are off
+  // Brightness values 0 - 204 light up LEDs 0-4

-  Serial.println(digitalVal);
+  int led0Brightness = 0;
+  int led1Brightness = 0;
+  int led2Brightness = 0;
+  int led3Brightness = 0;
+  int led4Brightness = 0;
+
+  if (brightness >= 820 && brightness <= 1023) {
+    led0Brightness = (int)((float)brightness * 1.25);
+  } else if (brightness >= 615 && brightness <= 819) {
+    led0Brightness = 255;
+    led1Brightness = (int)((float)(brightness - 205) * 1.25);
+  } else if (brightness >= 410 && brightness <= 614) {
+    led0Brightness = led1Brightness = 255;
+    led2Brightness = (int)((float)(brightness - 410) * 1.25);
+  } else if (brightness >= 205 && brightness <= 409) {
+    led0Brightness = led1Brightness = led2Brightness = 255;
+    led3Brightness = (int)((float)(brightness - 615) * 1.25);
+  } else if (brightness <= 204) {
+    led0Brightness = led1Brightness = led2Brightness = led3Brightness = 255;
+    led4Brightness = (int)((float)(brightness - 820) * 1.25);
+  }
+
+
+  Serial.println(led0Brightness);
+  Serial.println(led1Brightness);
+  Serial.println(led2Brightness);
+  Serial.println(led3Brightness);
+  Serial.println(led4Brightness);
+
+  analogWrite(LED_ARRAY_ELEMENT_0, led0Brightness);
+  analogWrite(LED_ARRAY_ELEMENT_1, led1Brightness);
+  analogWrite(LED_ARRAY_ELEMENT_2, led2Brightness);
+  analogWrite(LED_ARRAY_ELEMENT_3, led3Brightness);
+  analogWrite(LED_ARRAY_ELEMENT_4, led4Brightness);
 }


possible workarounds to controller bugs

possible workarounds to controller bugs

--- oven-controller/src/menu_test/menu_test.ino
+++ oven-controller/src/menu_test/menu_test.ino
@@ -132,7 +132,7 @@
 int curtemp = 32;
 int prevtemp = 32;
 int curtempflag = 0;
-int tempThreshold = 3; // determines whether one or two heaters on/off
+int tempThreshold = 5; // determines whether one or two heaters on/off
 int thermStatus[5] = {0};
 int numActiveThermocouples = 0;
 int ADCThreshold = 100;
@@ -233,6 +233,10 @@

   // get active thermocouples
   // disregard values from therm X if therm[X] = 1
+  // It's good to know when a TCP is unplugged, but this seems to be begging
+  // to make a bug... Think about what happens if someone wants to validate
+  // the controller readings and starts up the controller with the TCP in
+  // an ice-water bath, lol.
   if ((int)thermocouple1.readFarenheit() == 32) thermStatus[1] = 1;
   if ((int)thermocouple2.readFarenheit() == 0) thermStatus[2] = 1;
   if ((int)thermocouple3.readFarenheit() == 0) thermStatus[3] = 1;
@@ -280,28 +284,30 @@

   // check thermocouples and get average value
   // TODO: turn on particular heaters based on particular thermocouples
-  curtemp = 0;
-  if (thermStatus[1] == 0)
-    curtemp += thermocouple1.readFarenheit();
-  Serial.print(curtemp);
-  Serial.print(" ");
-  if (thermStatus[2] == 0)
-    curtemp += thermocouple2.readFarenheit();
-  Serial.print(curtemp);
-  Serial.print(" ");
-  if (thermStatus[3] == 0)
-    curtemp += thermocouple3.readFarenheit();
-  Serial.print(curtemp);
-  Serial.print(" ");
-  if (thermStatus[4] == 0)
-    curtemp += thermocouple4.readFarenheit();
-  Serial.print(curtemp);
-  Serial.print(" ");
-  if (thermStatus[5] == 0)
-    curtemp += thermocouple5.readFarenheit();
-  Serial.print(curtemp);
-  Serial.print(" ");
-  curtemp = curtemp / numActiveThermocouples;
+  // TODO: Figure out proper temperature averaging when some TCPs are unplugged!
+  curtemp = thermocouple2.readFarenheit();
+  // curtemp = 0;
+  // if (thermStatus[1] == 0)
+  //   curtemp += thermocouple1.readFarenheit();
+  // Serial.print(curtemp);
+  // Serial.print(" ");
+  // if (thermStatus[2] == 0)
+  //   curtemp += thermocouple2.readFarenheit();
+  // Serial.print(curtemp);
+  // Serial.print(" ");
+  // if (thermStatus[3] == 0)
+  //   curtemp += thermocouple3.readFarenheit();
+  // Serial.print(curtemp);
+  // Serial.print(" ");
+  // if (thermStatus[4] == 0)
+  //   curtemp += thermocouple4.readFarenheit();
+  // Serial.print(curtemp);
+  // Serial.print(" ");
+  // if (thermStatus[5] == 0)
+  //   curtemp += thermocouple5.readFarenheit();
+  // Serial.print(curtemp);
+  // Serial.print(" ");
+  // curtemp = curtemp / numActiveThermocouples;
   Serial.println(curtemp);

   // if the temp has incremented, update temp
@@ -323,12 +329,16 @@
 }

 void updateHeaters() {
+  // Previously, this activated only one relay if within +1 threshold of
+  // the target temp. However, the oven is only set up for one relay, so it
+  // would just keep heating until one threshold above the target temp.
+  // What's worse, there's a delay between the input of heat and the rise
+  // of the voltage on the thermocouple, so the oven consistently overshot
+  // its temperature!
   if (curtemp < steplist[curRunStep].temp - tempThreshold)
     setHeaters(ON,ON);
-  else if (curtemp > steplist[curRunStep].temp + tempThreshold)
+  else
     setHeaters(OFF,OFF);
-  else
-    setHeaters(ON,OFF);
 }

 void hackySPIfix() {


Increase responsiveness of gslc-ex04 (Arduino)

--- arduino/gslc_ex04_ard/gslc_ex04_ard.ino
+++ arduino/gslc_ex04_ard/gslc_ex04_ard.ino
@@ -195,7 +195,7 @@
   m_nCount++;

   // Update elements on active page
-  snprintf(acTxt,MAX_STR,"%u",m_nCount);
+  snprintf(acTxt,MAX_STR,"%u",m_nCount/5);
   gslc_ElemSetTxtStr(m_pElemCnt,acTxt);

   gslc_ElemXGaugeUpdate(m_pElemProgress,((m_nCount/1)%100));
@@ -213,7 +213,7 @@
   gslc_Update(&m_gui);

   // Slow down updates
-  delay(100);
+  delay(10);

   // In a real program, we would detect the button press and take an action.
   // For this Arduino demo, we will pretend to exit by emulating it with an
@@ -225,4 +225,4 @@
   }
 }

-
+


Warning fixes

Warning fixes

--- espwifisniff.ino
+++ espwifisniff.ino
@@ -64,7 +64,7 @@
         if ((now - unique_mac[i].last_seen) > expiry) {
             // expired, overwrite it with the last one
             if (--unique_num > i) {
-                sprintf(text, "%10d: ", now);
+                sprintf(text, "%10ld: ", now);
                 Serial.print(text);
                 print_mac(unique_mac[i].mac);
                 sprintf(text, " expired: %d\n", unique_num);
@@ -88,10 +88,11 @@
         buf += 12;

         // read FC and DUR
-        uint16_t fc = buf[0] + buf[1] << 8;
+        uint16_t fc = (buf[1] << 8) + buf[0];
         buf += 2;
-        uint16_t dur = buf[0] + buf[1] << 8;
+        uint16_t dur = (buf[1] << 8) + buf[0];
         buf += 2;
+        (void)dur;

         // get address1, address2, address3
         memcpy(addr1, buf, 6);
@@ -106,7 +107,7 @@
             unsigned long now = millis();
             expire_mac(now, 60000);
             if (add_mac(now, addr2)) {
-                sprintf(text, "%10d: ", now);
+                sprintf(text, "%10ld: ", now);
                 Serial.print(text);
                 print_mac(addr2);
                 sprintf(text, " added: %d\n", unique_num);


update

update

--- ASA/ASA/ASA.ino
+++ ASA/ASA/ASA.ino
@@ -3,7 +3,7 @@
 /*
 Jhonatan da Silva
 Last Updated version :
-Wed Mar 15 14:48:30 2017
+Wed Mar 15 14:49:36 2017
 Number of code lines:
 34
 */


Cleaning arduino us_sensor comments

Cleaning arduino us_sensor comments

--- code/arduino/us_sensors/us_sensors.ino
+++ code/arduino/us_sensors/us_sensors.ino
@@ -91,19 +91,12 @@
                 Wire.write(0);
                 return;
             }
-
-            // split[0] = measures[sensor] & 0xFF;
-            // split[1] = measures[sensor] >> 8;
-            // Wire.write(split, 2);
             Wire.write(measures[sensor]);
             break;

         // Return measurements of all sensors
         case 2:
             for(byte i = 0; i < N_SENSORS; i++) {
-                // split[0] = measures[sensor] & 0xFF;
-                // split[1] = measures[sensor] >> 8;
-                // Wire.write(split, 2);
                 Wire.write(measures[i]);
             }
             break;


Thingspeak demo

Thingspeak demo

--- 01-Thingspeak/demo-MKR1000/demo-MKR1000.ino
+++ 01-Thingspeak/demo-MKR1000/demo-MKR1000.ino
@@ -30,7 +30,7 @@
 DHT sondaT(DHT22_PIN, DHTTYPE);

 unsigned long myChannelNumber = 251351;
-const char * myWriteAPIKey = "MIKEY";
+const char * myWriteAPIKey = "MIAPI";

 void setup() {

@@ -53,16 +53,14 @@
     Serial.println(ssid);
     // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
     status = WiFi.begin(ssid, pass);
+  }
+  // wait 10 seconds for connection:
+  delay(10000);

-    // wait 10 seconds for connection:
-    delay(10000);
+  Serial.println("Connected to wifi");
+  printWifiStatus();

-    Serial.println("Connected to wifi");
-    printWifiStatus();
-
-    ThingSpeak.begin(client);
-
-  }
+  ThingSpeak.begin(client);
 }

 void loop() {


updated LCD display

updated LCD display

--- mwsLCD/mwsLCD.ino
+++ mwsLCD/mwsLCD.ino
@@ -59,7 +59,7 @@
 byte seconds_2m; //Keeps track of the "wind speed/dir avg" over last 2 minutes array of data
 byte minutes; //Keeps track of where we are in various arrays of data
 byte minutes_10m; //Keeps track of where we are in wind gust/dir over last 10 minutes array of data
-byte minutes_5m; // Niroshan this is for 5 mnts rain
+//byte minutes_5m; // Niroshan this is for 5 mnts rain

 long lastWindCheck = 0;
 volatile long lastWindIRQ = 0;
@@ -76,7 +76,7 @@
 byte windspdavg[120]; //120 bytes to keep track of 2 minute average
 int winddiravg[120]; //120 ints to keep track of 2 minute average
 //float windgust_10m[10]; //10 floats to keep track of 10 minute max //Yann: to check if OK
-volatile float rain5m[5]; //Niroshan 5 float to keep rain data of 5 mnts  //Yann: added volatile
+//volatile float rain5m[5]; //Niroshan 5 float to keep rain data of 5 mnts  //Yann: added volatile
 //int windgustdirection_10m[10]; //10 ints to keep track of 10 minute max
 volatile float rainHour[60]; //60 floating numbers to keep track of 60 minutes of rain

@@ -126,7 +126,7 @@
   {
     dailyrainin += 0.011*25.4; //Each dump is 0.011" of water
     rainHour[minutes] += 0.011*25.4; //Increase this minute's amount of rain
-    rain5m[minutes_5m] +=0.011*25.4; // increase this 5 mnts amout of rain
+    //rain5m[minutes_5m] +=0.011*25.4; // increase this 5 mnts amout of rain
     rainlast = raintime; // set up for next event
   }
   //Removed for dynamic memory reduction
@@ -191,7 +191,7 @@

   smartdelay(60000); //Wait 60 seconds, and gather GPS data
   minutes = gps.time.minute();
-  minutes_5m = gps.time.minute();
+  //minutes_5m = gps.time.minute();
   minutes_10m = gps.time.minute();
   seconds = gps.time.second();
   lastSecond = millis();
@@ -254,11 +254,11 @@

       if(++minutes % 60 == 0) minutes = 0;
       //if(++minutes_5m % 5 == 0) Rainindi = 0;
-      if(minutes_5m % 5 == 0) minutes_5m = 0;
+      //if(minutes_5m % 5 == 0) minutes_5m = 0;
       if(++minutes_10m % 10 == 0) minutes_10m = 0;

       rainHour[minutes] = 0; //Zero out this minute's rainfall amount
-      rain5m[minutes_5m] = 0; //Zero out this 5 minutes' rain Niroshan
+      //rain5m[minutes_5m] = 0; //Zero out this 5 minutes' rain Niroshan
 //      windgust_10m[minutes_10m] = 0; //Zero out this minute's gust
     }

@@ -357,7 +357,8 @@
 //I don't like the way this function is written but Arduino doesn't support floats under sprintf
 void printWeather()
 {
-      digitalWrite(STAT2, HIGH); //Turn off stat LED
+      //Turn on orange led during data gathering
+      digitalWrite(STAT2, HIGH); //Turn on stat LED

   //calcWeather(); //Go calc all the various sensors
 //Calculates each of the variables that wunderground is expecting
@@ -422,9 +423,9 @@
   for(int i = 0 ; i < 60 ; i++) //change to 60 mnts
     rainin += rainHour[i];

-  float rainin_5m = 0;
-  for(int i = 0 ; i < 5 ; i++) //change to 5 mnts
-    rainin_5m += rain5m[i];
+  //float rainin_5m = 0;
+  //for(int i = 0 ; i < 5 ; i++) //change to 5 mnts
+  //  rainin_5m += rain5m[i];

   //Calc pressure
@@ -437,7 +438,7 @@

   //Calc battery level
   float batt_lvl = get_battery_level();
-
+  digitalWrite(STAT2, LOW); //Turn off stat LED
 //} //END OF GO CALC WEATHER FUNCTION

@@ -485,7 +486,6 @@
   lcd.setCursor(0, 2);
   lcd.print(sz);
   delay(2000);
-  digitalWrite(STAT2, LOW); //Turn off stat LED

   //Serial.print(",winddir=");
   Serial.print(",");
@@ -565,7 +565,7 @@

   //Serial.print(",rain5mmm=");
   Serial.print(",");
-  Serial.print(rainin_5m, 2);
+  //Serial.print(rainin_5m, 2);
   //Serial.print(",rainindicate=");
   Serial.print(",");
   //Serial.print(Rainindi, 1);


Use safeload for assets

Use safeload for assets

--- selftest.ino
+++ selftest.ino
@@ -162,8 +162,7 @@
 static byte test_SDcard(void)
 {
   for (byte i = 0; i < 2; i++) {
-    if (!GD.load("selftest.gd2"))
-      return 0;
+    GD.safeload("selftest.gd2");
     uint32_t pcrc = GD.cmd_memcrc(0, ASSETS_END);
     GD.finish();
     uint32_t crc = GD.rd32(pcrc);


update tm to ".com"

update tm to ".com"

updated correct legal.

--- examples/GettingStartedProject/GettingStartedProject.ino
+++ examples/GettingStartedProject/GettingStartedProject.ino
@@ -1,6 +1,6 @@

 /*  PulseSensor™ Starter Project and Signal Tester
- *  The Best Way to Get Started  With, or See the Raw Signal of, your PulseSensor™ & Arduino.
+ *  The Best Way to Get Started  With, or See the Raw Signal of, your PulseSensor.com™ & Arduino.
  *
  *  Here is a link to the tutorial
  *  https://pulsesensor.com/pages/code-and-guide


Comment Arduino code

Comment Arduino code

--- sous_vide_arduino/sous_vide_arduino.ino
+++ sous_vide_arduino/sous_vide_arduino.ino
@@ -65,6 +65,7 @@

         digitalWrite(HEATER_PIN, heating);

+        // Turn off LED and sleep until the next sample period
         Bean.setLed(0, 0, 0);
         Bean.sleep(CONTROL_INTERVAL);


Adjust Bridge Sensor to calculate river height instead of distance to

--- Arduino/libraries/UA_Sensors/examples/BridgeSensorGSM/BridgeSensorGSM.ino
+++ Arduino/libraries/UA_Sensors/examples/BridgeSensorGSM/BridgeSensorGSM.ino
@@ -40,8 +40,9 @@

 // Settings
 // -------------------------------
+#define SENSOR_TO_RIVER_BED        2000
 #define SENSOR_TYPE                "d"
-#define SEND_DATA_AFTER_X_READINGS 4
+#define SEND_DATA_AFTER_X_READINGS 10
 #define SLEEP_CYCLES               4
 #define NUM_THERM_READINGS         5
 #define THERM_READING_DELAY        20
@@ -94,13 +95,6 @@
     LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
   }

-
-  // HACK: Turn on GSM MOSFET on wake up each time. Somehow
-  //       fixes bug where RocketScream resets.
-  digitalWrite(MOSFET_GSM_PIN, HIGH);
-  delay(1000);
-
-
   // 2. Turn on thermistor.
   // ----------------------
   digitalWrite(THERM_PIN, HIGH);
@@ -173,7 +167,7 @@

   // 11. Use average temperature to calculate actual distance.
   // ---------------------------------------------------------
-  double adjustedDistance = ( ( 331.1 + .6 * avgTemperature ) / 344.5 ) * avgDistance;
+  double adjustedDistance = SENSOR_TO_RIVER_BED - ( ( 331.1 + .6 * avgTemperature ) / 344.5 ) * avgDistance;

   int roundedDistance = round(adjustedDistance);
   int roundedTemperature = round(avgTemperature);
@@ -233,6 +227,10 @@
       textMessage += String(DATA_DELIM) + String(minutesElapsed) + " " + String(sensorReadings[i].distance) + " " + String(sensorReadings[i].temperature);
     }

+    // Turn on MOSFET GSM
+    digitalWrite(MOSFET_GSM_PIN, HIGH);
+    delay(1500);
+

     // GSM baud rate. Start communication link with GSM shield.
     Serial.begin(19200);
@@ -270,9 +268,9 @@
       //                   Battery will die quickly if power cannot be turned off.
       //                   Send SOS SMS?
     }
-  }
-
-  // Turn off GSM MOSFET.
-  digitalWrite(MOSFET_GSM_PIN, LOW);
-  delay(2000);
+
+    // Turn off GSM MOSFET.
+    digitalWrite(MOSFET_GSM_PIN, LOW);
+    delay(2000);
+  }
 }


scs_update

--- BiotechHardware/scs/scs.ino
+++ BiotechHardware/scs/scs.ino
@@ -6,7 +6,8 @@
 #include <EthernetClient.h>

 const int smoke_pin = A0;
-const int temp_pin =  2;
+const int temp_pin =  6;
+const int Relay = 2;

 byte mac[] = {0x90, 0xA2, 0xDA, 0x0E, 0xF5, 0x30 };
 const char server[] = "192.168.1.3";
@@ -21,14 +22,29 @@
   temp_sensor.begin();
   Ethernet.begin(mac, ip);
   delay(1000);
+  pinMode(Relay, OUTPUT);
 }

 void loop() {
   temp_sensor.requestTemperatures();
-  Serial.println(analogRead(smoke_pin));
-  Serial.println(temp_sensor.getTempCByIndex(0));
-  send_log(temp_sensor.getTempCByIndex(0), analogRead(smoke_pin));
-  delay(5000);
+
+  float temp = temp_sensor.getTempCByIndex(0);
+  float smoke = analogRead(smoke_pin);
+
+
+  if(temp > 30 || smoke > 400){
+    digitalWrite(Relay, LOW);
+  }
+  else{
+    digitalWrite(Relay, HIGH);
+  }
+
+  Serial.println(smoke);
+  Serial.println(temp);
+  send_log(temp, smoke);
+
+
+  delay(1000);
 }

 void send_log(float temp, float smoke){


Fix Progress bar; switch to hours:minutes

--- NTPclock/NTPclock.ino
+++ NTPclock/NTPclock.ino
@@ -41,22 +41,20 @@
 // Main program loop
 void loop() {
   String timeDisplay = NTP.getTimeStr();
-  timeDigits[0] = timeDisplay.charAt(3);
-  timeDigits[1] = timeDisplay.charAt(4);
-  timeDigits[2] = timeDisplay.charAt(6);
-  timeDigits[3] = timeDisplay.charAt(7);
+  timeDigits[0] = timeDisplay.charAt(0);
+  timeDigits[1] = timeDisplay.charAt(1);
+  timeDigits[2] = timeDisplay.charAt(3);
+  timeDigits[3] = timeDisplay.charAt(4);
   for (int i=0; i<4; i++) {
     Serial.print(i);
     lc1.setChar(0, i, timeDigits[i], false);
   }
-  lc1.setChar(0, 4, timeDigits[3], false); //test for progress bar
-  lc1.setRow(0, 5, 31);

   Serial.println(timeDisplay);

-  time_t nowTime = now();            //store the current time in time variable t
-  int portion = second(nowTime) / 6; //get the number of bars that should be lit
-  setBar(portion);                   //and then set them
+  time_t nowTime = now();                  //store the current time in time variable t
+  int portion = (second(nowTime) / 6) + 1; //get the number of bars that should be lit
+  setBar(portion);                         //and then set them

   delay(1000);         //TODO:   REMOVE DELAY FOR A COUNTER..............................PLEASE!!!!......../////////////////////////
 }
@@ -64,14 +62,14 @@
 // Controlls a 10-segment LED bargraph
 // int bars: 0-10 number of bars that should be on
 void setBar(int bars) {
-  boolean segments[10] = {false, false, false, false, false, false, false, false, false, false};
+  bool segment[10] = {false, false, false, false, false, false, false, false, false, false};
   for (int i = 0; i<bars; i++) {   //set true up to the number of bars
-    segments[i] = true;
+    segment[i] = true;
   }

   for (int i=0; i<5; i++) {        //Set the LEDs
-    lc1.setLed(0,4,segments[i]);     //0-4
-    lc1.setLed(0,5,i,segments[i+5]); //5-9
+    lc1.setLed(0,4,i,segment[i]);   //0-4
+    lc1.setLed(0,5,i,segment[i+5]); //5-9
   }
 }


Added setAll

Added setAll

--- software/_proto_DriverFirmware/MainControlFirmware/MainControlFirmware.ino
+++ software/_proto_DriverFirmware/MainControlFirmware/MainControlFirmware.ino
@@ -31,7 +31,7 @@
 //I2cDiscreteIoExpander device(0);
 I2cDiscreteIoExpander device2(1);

-Timer t;  //Instantiate timer
+//Timer t;  //Instantiate timer

 class Display {
 	public:
@@ -42,8 +42,12 @@
 		int writeToDisplay();
 		void setLeft(char * input);
 		void setLeft(char input);
+//		void setLeft(char input, char input2);
 		void setRight(char * input);
 		void setRight(char input);
+//		void setRight(char input, char input2);
+		void setAll(char * input);
+		void setAll(char input);
 	private:
 		I2cDiscreteIoExpander * device;
 		uint16_t current;
@@ -64,7 +68,7 @@

 //Address 1 = 21 in hex

-//Constants for the
+//Constants for the I2C Expander
 const uint8_t dispRight = (1<<7);
 const uint16_t dispLeft = (dispRight<<8);
 const uint8_t charsL [16] = {0b1000000,0b1111001,0b0100100,0b0110000,0b0011001,0b0010010,0b0000010,0b1111000,0b0000000,0b0010000,0b0001000,0b0000011,0b1000110,0b0100001,0b0000110,0b0001110};  //Contains the constants for the 7seg values
@@ -84,7 +88,7 @@
   static Display disp(0);
   static Display disp2(1);

-  static uint16_t timing = 0;
+  static uint16_t timing = 1;
   static uint16_t i = 0;
   uint8_t status = 0;
   uint8_t status2 = 0;
@@ -97,15 +101,15 @@
 	i = ++i%10;
 	char temp[2];

-	disp.setLeft("C5");
-	disp.setRight("89");
-
+	disp.setLeft("B1");
+	disp.setRight('5');
+	//disp.setAll("b15 ");
+
+	//disp2.setAll('5');
 	disp2.setLeft('5');
 	temp[0] = i + 48;
-	temp[1] = 1 + 48;
+	temp[1] = '4'; //4 + 48;
 	disp2.setRight(temp);
-	//configureToWrite(disp2.left, LEFT, 'f' , 'F');
-	//configureToWrite(disp2.right, RIGHT, '3', i + 48);
   }

   switch(CurrentState) {
@@ -198,6 +202,9 @@
 //Display constructor
 Display::Display(int deviceID){
 	device = new I2cDiscreteIoExpander(deviceID);
+	if(deviceID == 0){
+		setAll("b15");
+	}
 	current = 0;
 	left = 0;
 	right = 0;
@@ -230,6 +237,15 @@
 	configureToWrite(left, LEFT, input, ' ');
 }

+/*
+//NOT WORKING
+void Display::setLeft(char input, char input2){
+	input = tolower(input);
+	input2 = tolower(input2);
+	configureToWrite(left, LEFT, input, input2);
+}
+*/
+
 void Display::setRight(char * input){
 	input[0] = tolower(input[0]);
 	input[1] = tolower(input[1]);
@@ -241,6 +257,30 @@
 	configureToWrite(right, RIGHT, input, ' ');
 }

+/*
+//NOT WORKING
+void Display::setRight(char input, char input2){
+	input = tolower(input);
+	input2 = tolower(input2);
+	configureToWrite(right, RIGHT, input, input2);
+}
+*/
+
+void Display::setAll(char * input){
+	char temp[2];
+	temp[0] = input[0];
+	temp[1] = input[1];
+	setLeft(temp);
+	temp[0] = input[2];
+	temp[1] = input[3];
+	setRight(temp);
+}
+
+void Display::setAll(char input){
+	setLeft(input);
+	setRight(' ');
+}
+
 /* * * * * * * * * * * * * *
 END DISPLAY STRUCT FUNCTIONS
 * * * * * * * * * * * * * */


Altera endereço MAC para o atribuído ao IP 10.60.20.12.

--- arduino/casa_inteligente/casa_inteligente.ino
+++ arduino/casa_inteligente/casa_inteligente.ino
@@ -14,7 +14,9 @@

 // Endereco MAC da shield ethernet
 byte mac[] = {
-  0xf8, 0xb1, 0x56, 0xfc, 0x4c, 0xc4
+//  f8:b1:56:fc:4d:d3
+//  0xf8, 0xb1, 0x56, 0xfc, 0x4c, 0xc4
+  0xf8, 0xb1, 0x56, 0xfc, 0x4d, 0xd3
 };

@@ -24,25 +26,10 @@
 #define PORTA_MQTT 18768
 #define USUARIO_MQTT "mdzjtvif"
 #define SENHA_MQTT "snX5gG5TJs8P"
-char MENSAGEM_BROKER[100];
-//#define PORTA_MQTT 1883

-void callback(char* topic, byte* payload, unsigned int length);
+void callback(char* topic, byte* payload, unsigned int length) {}

 PubSubClient client(server, PORTA_MQTT, callback, ethClient);
-void callback(char* topic, byte* payload, unsigned int length) {
-  int i = 0;
-  Serial.println("Menssagem recebida:  " + String(topic));
-
-  for(i=0; i<length; i++)
-  {
-    MENSAGEM_BROKER[i] = payload[i];
-  }
-  MENSAGEM_BROKER[i] = '\0';
-  String msgString = String(MENSAGEM_BROKER);
-
-  Serial.println("Payload: " + msgString);
-}

 // Configurações da funcionalidade 01 - Acionamento automático do ar condicionado


Remove unnecessary #define

Remove unnecessary #define

--- moros/moros.ino
+++ moros/moros.ino
@@ -139,8 +139,7 @@

 class Controller {
 public:
-#define PLAYERS 2
-  Player *players[PLAYERS];
+  Player *players[2];
   static int active_player;

   Controller() {


Fix flag state problems

Fix flag state problems

--- moros/moros.ino
+++ moros/moros.ino
@@ -21,7 +21,9 @@
 #define CHAR_WIDTH_PX 42
 #define DISPLAY_WIDTH_CHAR 4

-#define INITIAL_TIME_MS 300000
+//#define INITIAL_TIME_MS 300000
+#define INITIAL_TIME_MS 300
+

 int active_player = CLOCK_STOP;
 volatile int button_pressed = CLOCK_STOP;
@@ -114,6 +116,7 @@
   if (active_player != CLOCK_STOP) {
     if (players[active_player].time_remaining_ms <= 0) {
       active_player = CLOCK_STOP;
+      button_pressed = CLOCK_STOP;
       return;
     }
     players[active_player].time_remaining_ms -= (millis() - players[active_player].last_update_ms);
@@ -147,12 +150,16 @@
     Serial.print("post active_player: ");
     Serial.println(active_player);
   }
-  /* TODO:
-  * flag
-  * -- don't fuck up the clock states/button press on 0 seconds
-  * reset
-  * right justify text
-  * handle losing seconds]
+  /*
+  * TODO:
+  * case
+  * flag - P0 BLOCKER S0
+  * -- have graphical representation of flag
+  * wiring diagram - P2 S3
+  * reset button (chronos style?) - P1
+  * time setting - P1
+  * OLEDs
+  *
   */

 }


Examples: Earpieces: EarpieceManualMixing: switch serviceLEDs, change i2s channel names

--- examples/09-Earpieces/EarpieceManualMixing_wSD/EarpieceManualMixing_wSD.ino
+++ examples/09-Earpieces/EarpieceManualMixing_wSD/EarpieceManualMixing_wSD.ino
@@ -45,32 +45,29 @@
 EarpieceShield   earpieceShield(TympanRev::E, AICShieldRev::A);  //Note that EarpieceShield is defined in the Tympan_Libarary in AICShield.h

 // Instantiate the audio classes
-AudioInputI2SQuad_F32         i2s_in(audio_settings);         //Digital audio *from* the Tympan AIC.
-AudioMixer4_F32               inputMixerL(audio_settings);    //For mixing (or not) the two mics in the left earpiece
-AudioMixer4_F32               inputMixerR(audio_settings);    //For mixing (or not) the two mics in the left earpiece
-AudioOutputI2SQuad_F32        i2s_out(audio_settings);        //Digital audio *to* the Tympan AIC.  Always list last to minimize latency
-AudioSDWriter_F32             audioSDWriter(audio_settings);  //this is stereo by default
-
-//Connect the front and rear mics (from each earpiece) to input mixers...note the unusual order (1,0,3,2).  Sorry, but it's true.
-const int LEFT_FRONT = 1, LEFT_REAR = 0, RIGHT_FRONT = 3, RIGHT_REAR = 2;
-AudioConnection_F32           patchcord1(i2s_in, LEFT_FRONT,  inputMixerL, 0);    //Left-Front Mic
-AudioConnection_F32           patchcord2(i2s_in, LEFT_REAR,   inputMixerL, 1);    //Left-Rear Mic
-AudioConnection_F32           patchcord3(i2s_in, RIGHT_FRONT, inputMixerR, 0);    //Right-Front Mic
-AudioConnection_F32           patchcord4(i2s_in, RIGHT_REAR,  inputMixerR, 1);    //Right-Rear Mic
-
-//Connect the input mixers to both the Tympan and Shield audio outputs
-//NOTE: The left and right RIC is correct, but the headphone jacks have the left and right swapped.
-const int OUT_LEFT_TYMPAN = 0, OUT_RIGHT_TYMPAN = 1, OUT_LEFT_EARPIECE = 3, OUT_RIGHT_EARPIECE = 2;
-AudioConnection_F32           patchcord11(inputMixerL, 0, i2s_out, OUT_LEFT_TYMPAN);    //Tympan AIC, left output
-AudioConnection_F32           patchcord12(inputMixerR, 0, i2s_out, OUT_RIGHT_TYMPAN);   //Tympan AIC, right output
-AudioConnection_F32           patchcord13(inputMixerL, 0, i2s_out, OUT_LEFT_EARPIECE);  //Shield AIC, left output
-AudioConnection_F32           patchcord14(inputMixerR, 0, i2s_out, OUT_RIGHT_EARPIECE); //Shield AIC, right output
+AudioInputI2SQuad_F32   i2s_in(audio_settings);         //Digital audio *from* the Tympan AIC.
+AudioMixer4_F32         inputMixerL(audio_settings);    //For mixing (or not) the two mics in the left earpiece
+AudioMixer4_F32         inputMixerR(audio_settings);    //For mixing (or not) the two mics in the left earpiece
+AudioOutputI2SQuad_F32  i2s_out(audio_settings);        //Digital audio *to* the Tympan AIC.  Always list last to minimize latency
+AudioSDWriter_F32       audioSDWriter(audio_settings);  //this is stereo by default
+
+//Connect the front and rear mics (from each earpiece) to input mixers...which i2s input is associated with each mic is in EarpieceShield.cpp
+AudioConnection_F32     patchcord1(i2s_in, EarpieceShield::PDM_LEFT_FRONT,  inputMixerL, 0);    //Left-Front Mic
+AudioConnection_F32     patchcord2(i2s_in, EarpieceShield::PDM_LEFT_REAR,   inputMixerL, 1);    //Left-Rear Mic
+AudioConnection_F32     patchcord3(i2s_in, EarpieceShield::PDM_RIGHT_FRONT, inputMixerR, 0);    //Right-Front Mic
+AudioConnection_F32     patchcord4(i2s_in, EarpieceShield::PDM_RIGHT_REAR,  inputMixerR, 1);    //Right-Rear Mic
+
+//Connect the input mixers to both the Tympan and Shield audio outputs...which i2s output is associated with each audio output is in EarpieceShield.cpp
+AudioConnection_F32     patchcord11(inputMixerL, 0, i2s_out, EarpieceShield::OUTPUT_LEFT_TYMPAN);    //Tympan AIC, left output
+AudioConnection_F32     patchcord12(inputMixerR, 0, i2s_out, EarpieceShield::OUTPUT_RIGHT_TYMPAN);   //Tympan AIC, right output
+AudioConnection_F32     patchcord13(inputMixerL, 0, i2s_out, EarpieceShield::OUTPUT_LEFT_EARPIECE);  //Shield AIC, left output
+AudioConnection_F32     patchcord14(inputMixerR, 0, i2s_out, EarpieceShield::OUTPUT_RIGHT_EARPIECE); //Shield AIC, right output

 //Connect the input mixer to the SD card
-AudioConnection_F32           patchcord21(i2s_in, LEFT_FRONT,  audioSDWriter, 0);   //connect Raw audio to SD writer
-AudioConnection_F32           patchcord22(i2s_in, LEFT_REAR,   audioSDWriter, 1);   //connect Raw audio to SD writer
-AudioConnection_F32           patchcord23(i2s_in, RIGHT_FRONT, audioSDWriter, 2);   //connect Raw audio to SD writer
-AudioConnection_F32           patchcord24(i2s_in, RIGHT_REAR,  audioSDWriter, 3);   //connect Raw audio to SD writer
+AudioConnection_F32     patchcord21(i2s_in, EarpieceShield::PDM_LEFT_FRONT,  audioSDWriter, 0);   //connect Raw audio to SD writer
+AudioConnection_F32     patchcord22(i2s_in, EarpieceShield::PDM_LEFT_REAR,   audioSDWriter, 1);   //connect Raw audio to SD writer
+AudioConnection_F32     patchcord23(i2s_in, EarpieceShield::PDM_RIGHT_FRONT, audioSDWriter, 2);   //connect Raw audio to SD writer
+AudioConnection_F32     patchcord24(i2s_in, EarpieceShield::PDM_RIGHT_REAR,  audioSDWriter, 3);   //connect Raw audio to SD writer

 //control display and serial interaction via USB Serial
 #include "State.h"                          //For enums
@@ -212,8 +209,8 @@
   //service the SD recording
   serviceSD();

-  //service the LEDs
-  serviceLEDs(millis());
+  //service the LEDs...blink slow normally, blink fast if recording
+  myTympan.serviceLEDs(millis(),audioSDWriter.getState() == AudioSDWriter::STATE::RECORDING);

   //periodicallly check the potentiometer
   servicePotentiometer(millis(),100); //service the potentiometer every 100 msec
@@ -256,47 +253,6 @@

   } // end if
 } //end servicePotentiometer();
-
-
-//Update the blinking of the LEDs depending upon whether we are (1) running or (2) writing to SD
-void serviceLEDs(unsigned long curTime_millis) {
-  static unsigned long lastUpdate_millis = 0;
-  const unsigned long long_toggle_millis = 1000;
-  const unsigned long short_toggle_millis = 100;
-
-  //handle wrap-around of the clock
-  if (curTime_millis < lastUpdate_millis) lastUpdate_millis = 0;
-
-  //choose how fast or slow to toggle based on recording state
-  unsigned long toggle_millis = long_toggle_millis;
-  if (audioSDWriter.getState() == AudioSDWriter::STATE::RECORDING) {
-    toggle_millis = short_toggle_millis;
-  }
-
-  //has enough time passed to toggle the LEDs
-  if ((curTime_millis - lastUpdate_millis) > toggle_millis) { //is it time to update the user interface?
-    toggleLEDs(); //blink both
-    lastUpdate_millis = curTime_millis;
-  }
-}
-
-
-void toggleLEDs(void) { toggleLEDs(true,true); } //toggle both
-void toggleLEDs(const bool &useAmber, const bool &useRed) {
-  static bool LED = false;
-  LED = !LED;
-  if (LED) {
-    if (useAmber) myTympan.setAmberLED(true);
-    if (useRed) myTympan.setRedLED(false);
-  } else {
-    if (useAmber) myTympan.setAmberLED(false);
-    if (useRed) myTympan.setRedLED(true);
-  }
-
-  if (!useAmber) myTympan.setAmberLED(false);
-  if (!useRed) myTympan.setRedLED(false);
-
-}

 #define PRINT_OVERRUN_WARNING 1   //set to 1 to print a warning that the there's been a hiccup in the writing to the SD.


adding back in the debug information Serial connect

--- experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
+++ experimental/arduino101/science-journal-arduino/science-journal-arduino.ino
@@ -8,6 +8,9 @@
 BLEService whistlepunkService("555a0001-0aaa-467a-9538-01f0652c74e8"); // create service
 // Must be 20 char long to accomodate full-size messages.
 const char *value = "                     ";
+
+String BleLongName = "Sci";
+bool serialConnected = false;

 BLECharacteristic valueCharacteristic("555a0003-0aaa-467a-9538-01f0652c74e8", BLENotify, value);

@@ -62,12 +65,11 @@
   ble_addr_t _local_bda;
   char       _device_name[BLE_MAX_DEVICE_NAME+1];
   ble_client_get_factory_config(&_local_bda, _device_name);
-  String name = "Sci";
-  name += String(_local_bda.addr[4], HEX);
-  name += String(_local_bda.addr[5], HEX);
+  BleLongName += String(_local_bda.addr[4], HEX);
+  BleLongName += String(_local_bda.addr[5], HEX);
   DEBUG_PRINT("Address is: ");
-  DEBUG_PRINTLN(name);
-  blePeripheral.setLocalName(name.c_str());
+  DEBUG_PRINTLN(BleLongName);
+  blePeripheral.setLocalName(BleLongName.c_str());

   // advertise the service
   blePeripheral.begin();
@@ -75,6 +77,17 @@

 void loop() {
+  if (Serial) {
+    if (!serialConnected) {
+        serialConnected = true;
+        DEBUG_PRINT(F("LongName: "));
+        DEBUG_PRINTLN(BleLongName);
+    }
+  } else {
+    if (serialConnected)
+        serialConnected = false;
+  }
+
   // poll peripheral
   blePeripheral.poll();


Got skeleton function for all commands, compiles, not verified yet

--- arduino/brew_kettle_yun/brew_kettle_yun.ino
+++ arduino/brew_kettle_yun/brew_kettle_yun.ino
@@ -98,8 +98,26 @@
   if (command == "pump") {
     pumpCommand(client);
   }
-  if (command == "temperature") {
+  else if (command == "temperature") {
     temperatureCommand(client);
+  }
+  else if (command == "heater") {
+    heaterCommand(client);
+  }
+  else if (command == "pid") {
+    pidCommand(client);
+  }
+  else if (command == "setpoint") {
+    setpointCommand(client);
+  }
+  else if (command == "pvalue") {
+    pvalueCommand(client);
+  }
+  else if (command == "ivalue") {
+    ivalueCommand(client);
+  }
+  else if (command == "fullstatus") {
+    fullstatusCommand(client);
   }
   else {
     int i;
@@ -158,69 +176,86 @@
   Bridge.put("dutycycle", String(value));
 }

-/* void heater_msg() { */
-/*   /\* Serial << STATMSG << "Heater msg received" << ENDMSG; *\/ */
-/*   while (cmdMessenger.available()) { */
-/*     char buf[350] = {'\0'}; */
-/*     cmdMessenger.copyString(buf, 350); */
-/*     // Its of the form int, where int is percent */
-/*     // duty cycle */
-/*     setDutyCycle(atoi(buf)); */
-/*   } */
-/* } */
-
-/* void setPIDonoff_msg() { */
-/*   /\* Serial << STATMSG << "Set PID on off msg received" << ENDMSG; *\/ */
-/*   while (cmdMessenger.available()) { */
-/*     char buf[350] = {'\0'}; */
-/*     cmdMessenger.copyString(buf, 350); */
-/*     if (strncmp(buf, "1", 1) == 0) { */
-/*       temperaturePID.SetMode(AUTOMATIC); */
-/*     } */
-/*     else { */
-/*       temperaturePID.SetMode(MANUAL); */
-/*     } */
-/*   } */
-/* } */
-
-/* void getall_msg() { */
-/*   /\* Serial << STATMSG << "All parameters requested" << ENDMSG; *\/ */
-/*   Serial << GETALLMSG << temperature << "," << dutyCycle << "," \ */
-/* 	 << setpoint << "," << temperaturePID.GetMode() \ */
-/* 	 << "," << pumpIsOn << "," << pValue << "," << iValue << ENDMSG; */
-/*   delay(10); */
-/* } */
-
-/* void changeSET_msg() { */
-/*   /\* Serial << STATMSG << "Change in setpoint requested" << ENDMSG; *\/ */
-/*   while (cmdMessenger.available()) { */
-/*     char buf[350] = {'\0'}; */
-/*     cmdMessenger.copyString(buf, 350); */
-/*     // Its of the form int, where int is percent */
-/*     // duty cycle */
-/*     setSetPoint(atoi(buf)); */
-/*   } */
-/* } */
-
-/* void setP_msg() { */
-/*   while (cmdMessenger.available()) { */
-/*     char buf[350] = {'\0'}; */
-/*     cmdMessenger.copyString(buf, 350); */
-/*     // Its of the form int, where int is percent */
-/*     // duty cycle */
-/*     setPValue(atof(buf)); */
-/*   } */
-/* } */
-
-/* void setI_msg() { */
-/*   while (cmdMessenger.available()) { */
-/*     char buf[350] = {'\0'}; */
-/*     cmdMessenger.copyString(buf, 350); */
-/*     // Its of the form int, where int is percent */
-/*     // duty cycle */
-/*     setIValue(atof(buf)); */
-/*   } */
-/* }     */
+void pidCommand(YunClient client) {
+
+  int value = client.parseInt();
+
+  if (value == 1) {
+    temperaturePID.SetMode(AUTOMATIC);
+  }
+  else {
+    temperaturePID.SetMode(MANUAL);
+  }
+
+  client.println(value);
+  Bridge.put("pid", String(value));
+}
+
+void setpointCommand(YunClient client) {
+
+  int value;
+
+  if (client.peek() != -1) {
+    value = client.parseInt();
+    setSetPoint(value);
+  }
+  else {
+    value = getSetPoint();
+  }
+
+  client.println(value);
+  Bridge.put("setpoint", String(value));
+}
+
+void pvalueCommand(YunClient client) {
+
+  int value;
+
+  if (client.peek() != -1) {
+    value = client.parseInt();
+    setPValue(value);
+  }
+  else {
+    value = pValue;
+  }
+
+  client.println(value);
+  Bridge.put("pvalue", String(value));
+}
+
+void ivalueCommand(YunClient client) {
+
+  int value;
+
+  if (client.peek() != -1) {
+    value = client.parseInt();
+    setIValue(value);
+  }
+  else {
+    value = iValue;
+  }
+
+  client.println(value);
+  Bridge.put("ivalue", String(value));
+}
+
+void fullstatusCommand(YunClient client) {
+
+  client.print(temperature);
+  client.print(',');
+  client.print(dutyCycle);
+  client.print(',');
+  client.print(setpoint);
+  client.print(',');
+  client.print(temperaturePID.GetMode());
+  client.print(',');
+  client.print(pumpIsOn);
+  client.print(',');
+  client.print(pValue);
+  client.print(',');
+  client.println(iValue);
+}
+

 void arduino_ready() {
   // In response to ping. We just send a throw-away ack to say "im alive"
@@ -255,6 +290,10 @@
 void setSetPoint(int value) {
   setpoint = double(value) / 10;
   /* Serial << STATMSG << "Set setpoint to " << setpoint << ENDMSG; */
+}
+
+int getSetPoint() {
+  return int(round(10 * setpoint));
 }

 void setDutyCycle(int value) {


signbug

signbug

--- remap.ino
+++ remap.ino
@@ -80,7 +80,7 @@
     Joystick.hat(dir);
 }

-uint16_t getEllipticalSpeed(const EllipticalData_t* ellipticalP, uint32_t multiplier) {
+uint16_t getEllipticalSpeed(const EllipticalData_t* ellipticalP, int32_t multiplier) {
   if (multiplier == 0) {
     if (ellipticalP->speed == 0)
       return 512;


autodetect dynon type and set aoa % automatically.

--- AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
+++ AOA_TONE_EFIS_SERIAL/AOA_TONE_EFIS_SERIAL.ino
@@ -11,12 +11,10 @@
 // - If no serial data is detected audio tone turns off and LED1 is off
 // - MUTE_AUDIO_UNDER_IAS define is used to only activate audio tones if above a given airspeed
 //
-// 7/9/2018 - 1.5.1 fix for tone PPS between solid tones.  was not calucating the right ratio for the PPS changes.
-// 9/2/2018 - 1.5.2 Atempts to fix hang up issues with skyview data.  Changed start up tones.  added more comments. fix min PPS for low tone.
-// 9/28/2018- 1.6.0 Fixed Skyview lockup issue.
-
-//#define SETUP_DYNON_D100             // if this is defined then use settings (dynon D10 or D100)
-#define SETUP_DYNON_SKYVIEW            // if defined then use settings for dynon skyview
+// 7/9/2018   - 1.5.1 fix for tone PPS between solid tones.  was not calucating the right ratio for the PPS changes.
+// 9/2/2018   - 1.5.2 Atempts to fix hang up issues with skyview data.  Changed start up tones.  added more comments. fix min PPS for low tone.
+// 9/28/2018  - 1.6.0 Fixed Skyview lockup issue.
+// 9/28/2018  - 1.6.1 allow for automatic efis dectection d100 or skyview.

 #include <DueTimer.h>         // timer lib functions for using DUE timers and callbacks.
 #include <stdint.h>
@@ -51,44 +49,27 @@
 #define DYNON_SERIAL_LEN              53
 #define DYNON_SKYVIEW_SERIAL_LEN      74

-#ifdef SETUP_DYNON_SKYVIEW
-  // Dynon Skyview settings.
-  // For skyview export ahrs data out one of the 5 serialports (only needs serial output to AOA box, no serial input needed)
-  // AOA values & Tone Pulse Per Sec (PPS)
-  #define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
-  #define HIGH_TONE_AOA_STALL   80      // % (and above) where stall happens.
-  #define HIGH_TONE_AOA_START   66      // % (and above) where high tone starts
-  #define HIGH_TONE_PPS_MAX     6.5     // 6.5
-  #define HIGH_TONE_PPS_MIN     1.5     // 1.5
-  #define HIGH_TONE_HZ          1600    // freq of high tone
-  //#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
-  #define LOW_TONE_AOA_SOLID    55      // % (and above) where a solid low tone is played.
-  #define LOW_TONE_AOA_START    40      // % (and above) where low
-  #define LOW_TONE_PPS_MAX      6.5
-  #define LOW_TONE_PPS_MIN      0.5
-  #define LOW_TONE_HZ           400     // freq of low tone
-  #define BAUDRATE_EFIS         9600    // set skyview to 9600 (or change this value to what you want)
-#else
-#ifdef SETUP_DYNON_D100
-  // Dynon D100 or D10 settings.
-  // AOA values & Tone Pulse Per Sec (PPS)
-  #define HIGH_TONE_STALL_PPS   20      // how many PPS to play during stall
-  #define HIGH_TONE_AOA_STALL   72      // % (and above) where stall happens.
-  #define HIGH_TONE_AOA_START   32      // % (and above) where high tone starts
-  #define HIGH_TONE_PPS_MAX     6.5     // 6.5
-  #define HIGH_TONE_PPS_MIN     1.5     // 1.5
-  #define HIGH_TONE_HZ          1600    // freq of high tone
-  //#define HIGH_TONE2_HZ         1500    // a 2nd high tone that it will cycle between (if defined)
-  #define LOW_TONE_AOA_SOLID    22      // % (and above) where a solid low tone is played.
-  #define LOW_TONE_AOA_START    0      // % (and above) where low
-  #define LOW_TONE_PPS_MAX      8.5
-  #define LOW_TONE_PPS_MIN      1.5
-  #define LOW_TONE_HZ           400     // freq of low tone
-  #define BAUDRATE_EFIS         115200  // default baud rate for D100/D10
-#endif
-#endif
-
-
+// array postions for aoa values
+#define POS_HIGH_TONE_AOA_STALL   0      // % (and above) where stall happens.
+#define POS_HIGH_TONE_AOA_START   1      // % (and above) where high tone starts
+#define POS_LOW_TONE_AOA_SOLID    2      // % (and above) where a solid low tone is played.
+#define POS_LOW_TONE_AOA_START    3      // % (and above) where low
+#define D100      0
+#define SKYVIEW   1
+int AoaToneMatrix[2][5];          // tone matrix for different efis units.
+unsigned char WhichEFIS = D100;   // detect which efis is being read and set store it here.
+
+// general tone settings. Tone Pulse Per Sec (PPS)  (used for all efis units)
+#define HIGH_TONE_STALL_PPS       20      // how many PPS to play during stall
+#define HIGH_TONE_PPS_MAX         6.5     // 6.5
+#define HIGH_TONE_PPS_MIN         1.5     // 1.5
+#define HIGH_TONE_HZ              1600    // freq of high tone
+#define HIGH_TONE2_HZ             1500    // a 2nd high tone that it will cycle between (if defined)
+#define LOW_TONE_PPS_MAX          8.5
+#define LOW_TONE_PPS_MIN          1.5
+#define LOW_TONE_HZ               400     // freq of low tone
+
+#define BAUDRATE_EFIS         115200  // baud rate for D100/D10 and dynon
 #define TONE_PIN              2     // TIOA0
 #define PIN_LED1              13    // internal LED for showing AOA status.
 #define PIN_LED2              54    // aka A0. external LED for showing serial input.
@@ -109,7 +90,7 @@
 unsigned int ALT = 0;                 // hold ALT (only used for debuging)
 int ASI = 0;                          // live Air Speed Indicated
 unsigned int cyclesWOSerialData = 0;  // keep track if not serial data is recieved.
-unsigned char efisTypeDetected = 0;   // auto detect which efis is being used. 0 no detection. 1 = D series, 2 = Skyview
+//unsigned char efisTypeDetected = 0;   // auto detect which efis is being used. 0 no detection. 1 = D series, 2 = Skyview
 GaussianAverage myAverageAOA = GaussianAverage(AOA_HISTORY_MAX);
 static Tc *chTC = TC0;
 static uint32_t chNo = 0;
@@ -150,6 +131,19 @@
   Timer4.attachInterrupt(tonePlayHandler);
   Timer4.setFrequency(FREQ_OF_FUNCTION);  // set how often we should run the callback function.
   Timer4.start();
+
+  // Dynon Skyview settings.
+  // For skyview export ahrs data out one of the 5 serialports (only needs serial output to AOA box, no serial input needed)
+  AoaToneMatrix[SKYVIEW][POS_HIGH_TONE_AOA_STALL] = 80;      // % (and above) where stall happens.
+  AoaToneMatrix[SKYVIEW][POS_HIGH_TONE_AOA_START] = 66;      // % (and above) where high tone starts
+  AoaToneMatrix[SKYVIEW][POS_LOW_TONE_AOA_SOLID]  = 55;     // % (and above) where a solid low tone is played.
+  AoaToneMatrix[SKYVIEW][POS_LOW_TONE_AOA_START]  = 40;      // % (and above) where low
+
+  // Dynon D100 and D10 settings.
+  AoaToneMatrix[D100][POS_HIGH_TONE_AOA_STALL] =  72;      // % (and above) where stall happens.
+  AoaToneMatrix[D100][POS_HIGH_TONE_AOA_START] =  32;      // % (and above) where high tone starts
+  AoaToneMatrix[D100][POS_LOW_TONE_AOA_SOLID]  =  22;      // % (and above) where a solid low tone is played.
+  AoaToneMatrix[D100][POS_LOW_TONE_AOA_START]  =   0;      // % (and above) where low

 }

@@ -221,32 +215,32 @@
   }

   // check AOA value and set tone and pauses between tones according to
-  if(AOA >= HIGH_TONE_AOA_STALL) {
+  if(AOA >= AoaToneMatrix[WhichEFIS][POS_HIGH_TONE_AOA_STALL]) {
     // play 20 pps HIGH tone
     highTone = true;
     setPPSTone(HIGH_TONE_STALL_PPS);
     toneMode = PULSE_TONE;
-  } else if(AOA >= HIGH_TONE_AOA_START) {
+  } else if(AOA >= AoaToneMatrix[WhichEFIS][POS_HIGH_TONE_AOA_START]) {
     // play HIGH tone at Pulse Rate 1.5 PPS to 6.2 PPS (depending on AOA value)
     highTone = true;
-    OldValue = AOA-(HIGH_TONE_AOA_START-1);
+    OldValue = AOA-(AoaToneMatrix[WhichEFIS][POS_HIGH_TONE_AOA_START]-1);
     toneMode = PULSE_TONE;
     // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
-    OldRange = HIGH_TONE_AOA_STALL - HIGH_TONE_AOA_START; //20 - 1;  //(OldMax - OldMin)
+    OldRange = AoaToneMatrix[WhichEFIS][POS_HIGH_TONE_AOA_STALL] - AoaToneMatrix[WhichEFIS][POS_HIGH_TONE_AOA_START]; //20 - 1;  //(OldMax - OldMin)
     NewRange = HIGH_TONE_PPS_MAX - HIGH_TONE_PPS_MIN; // (NewMax - NewMin)
     NewValue = (((OldValue - 1) * NewRange) / OldRange) + HIGH_TONE_PPS_MIN; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
     setPPSTone(NewValue);
-  } else if(AOA >= LOW_TONE_AOA_SOLID) {
+  } else if(AOA >= AoaToneMatrix[WhichEFIS][POS_LOW_TONE_AOA_SOLID]) {
     // play a steady LOW tone
     highTone = false;
     toneMode = SOLID_TONE;
-  } else if(AOA > LOW_TONE_AOA_START) {
+  } else if(AOA > AoaToneMatrix[WhichEFIS][POS_LOW_TONE_AOA_START]) {
     toneMode = PULSE_TONE;
     highTone = false;
     // play LOW tone at Pulse Rate 1.5 PPS to 8.2 PPS (depending on AOA value)
     // scale number using this. http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
-    OldValue = AOA-LOW_TONE_AOA_START;
-    OldRange = LOW_TONE_AOA_SOLID - LOW_TONE_AOA_START; //40 - 1;  //(OldMax - OldMin)
+    OldValue = AOA - AoaToneMatrix[WhichEFIS][POS_LOW_TONE_AOA_START];
+    OldRange = AoaToneMatrix[WhichEFIS][POS_LOW_TONE_AOA_SOLID] - AoaToneMatrix[WhichEFIS][POS_LOW_TONE_AOA_START]; //40 - 1;  //(OldMax - OldMin)
     NewRange = LOW_TONE_PPS_MAX - LOW_TONE_PPS_MIN; // (NewMax - NewMin)
     NewValue = (((OldValue - 1) * NewRange) / OldRange) + LOW_TONE_PPS_MIN; //(((OldValue - OldMin) * NewRange) / OldRange) + NewMin
     setPPSTone(NewValue);
@@ -281,7 +275,7 @@

         // check for dynon skyview data. based on length of string and if the 1st 2 chars match
         if (inChar == '\n' && inputPos == DYNON_SKYVIEW_SERIAL_LEN && input[0]=='!' && input[1]=='1') {
-          efisTypeDetected = 2;  // set skyview efis detected.
+          WhichEFIS = SKYVIEW;  // set skyview efis detected.
           // skyview data starts with a '!1'... the D series efis has no line prefix.
           tempBuf[0] = input[43]; // get the 2 bytes for aoa on skyview.
           tempBuf[1] = input[44]; //
@@ -312,9 +306,10 @@
 #endif
           validAOADataFound();  // run function to process tone.  because we found a valid AOA value.

-        } else if (inChar == '\n' && inputPos == DYNON_SERIAL_LEN && efisTypeDetected != 2) {  // is EOL?
+        } else if (inChar == '\n' && inputPos == DYNON_SERIAL_LEN) {  // is EOL?
+          WhichEFIS = D100;  // set D100 efis detected
           // else check for dynon d series data.
-          // efisTypeDetected != 2 has been added to make sure we don't confused skyview data for d10 data and try to process..
+          // efisTypeDetected != SKYVIEW has been added to make sure we don't confused skyview data for d10 data and try to process..
           // get AOA from dynon efis string.  details of format can be found from dynon pdf manual.
           tempBuf[0] = input[39]; //
           tempBuf[1] = input[40]; //


Changed baudrate

Changed baudrate

--- gcn_controller_v5/gcn_controller_v5.ino
+++ gcn_controller_v5/gcn_controller_v5.ino
@@ -178,7 +178,7 @@
 uint32_t previousInputDelay = 0;
 //uint32_t currentMillis = 0;

-uint32_t baudRate = 500000;
+uint32_t baudRate = 2000000;

 uint8_t serial_rx_buffer[12];
 uint8_t current_macro_input[12];
@@ -782,9 +782,21 @@
               Serial.write(0x00);
               Serial.write(endingMacroIndex);
             }
-            for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
-              // Send only data back if it has changed, I don't know how to do this without having two loops
-              Serial.write(current_macro_input[currentByteIndex]);;
+            if (loopMacro <= 0) {
+              if (currentMacroIndexRunning == macroInputsToRun) {
+                for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+                  // Send only data back if it has changed, I don't know how to do this without having two loops
+                  Serial.write(current_macro_input[currentByteIndex]);
+                }
+              }
+            }
+            if (loopMacro > 0) {
+              if (loopCounter > timesToLoop) {
+                for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+                  // Send only data back if it has changed, I don't know how to do this without having two loops
+                  Serial.write(current_macro_input[currentByteIndex]);
+                }
+              }
             }
           }
           Serial.flush();


Internal Vcc reads for Load cells

Internal Vcc reads for Load cells

--- Arduino/_firmware3/_firmware3.ino
+++ Arduino/_firmware3/_firmware3.ino
@@ -22,7 +22,8 @@
 // 9. Software Serial to FFT
 //10. Node Metadata
 #include <SoftwareSerial.h>
-
+#include "EmonLib.h"                   // Include Emon Library
+EnergyMonitor emon1;                   // Create an instance

 //Analog sensors
 //+5V Position Sensor
@@ -30,14 +31,24 @@
 //+3.3V Fluid Leve
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////
 //                                            Analog smoothing
-const int number_of_readings = 40;
+const int number_of_readings = 30; //Increases the size of global variables big time. Can be be managed in case we run into memory issues
 int analog_index = 0;

 float smoothing(const int* numb_readings, float* total_sum,
-  float* array_item, int* analog_pin){
+                float* array_item, int* analog_pin){

   *total_sum -= *array_item;
   *array_item = analogRead(*analog_pin);
+  *total_sum += *array_item;
+  float result = *total_sum / *numb_readings;
+  return result;
+}
+
+float smoothing_Vin(const int* numb_readings, float* total_sum,
+                float* array_item){
+
+  *total_sum -= *array_item;
+  *array_item = emon1.readVcc()*0.001;
   *total_sum += *array_item;
   float result = *total_sum / *numb_readings;
   return result;
@@ -440,6 +451,9 @@
 float load2_total = 0.0;

 float v_in = 5.04;// Measure and correct the V in.
+float v_in_total = 0.0;
+float v_in_array[number_of_readings];
+
 float load1_v_out = 0.0;
 float load2_v_out = 0.0;
 float res_1 = 50350.0; // Measure the value of R1 in voltage divider circuit.
@@ -457,12 +471,13 @@
                             &load1_array[analog_index], &load1_pin);
   load2_average = smoothing(&number_of_readings, &load2_total,
                             &load2_array[analog_index], &load2_pin);
-
+  v_in = smoothing_Vin(&number_of_readings, &v_in_total, &v_in_array[analog_index]);
   //////////////////// For debugging
   // Serial.println(analogRead(load1_pin));
   // Serial.println(analogRead(load2_pin));
   // Serial.println(load2_average);
   // Serial.println(load2_average);
+  //Serial.println(v_in);

   //Convert analog signal to voltage
   load1_v_out = load1_average / 1023 * v_in;
@@ -485,8 +500,7 @@

 ///////////////////////////////////////////////////////////////////////////////////////////////////
 //                                            11. Current sensor
-#include "EmonLib.h"                   // Include Emon Library
-EnergyMonitor emon1;                   // Create an instance
+
 float Irms = 0.0;

 ////////////////////////////////////////////END of Sensors


Report OTAA parameters recovered from memory to BLE

--- MapTheThings-Arduino/MapTheThings-Arduino.ino
+++ MapTheThings-Arduino/MapTheThings-Arduino.ino
@@ -228,6 +228,24 @@
   "AT+GATTADDCHAR=UUID=0x2AD4,PROPERTIES=0x0A,MIN_LEN=16,MAX_LEN=16,DATATYPE=2,DESCRIPTION=AppSKey",
   assignAppSKeyCallback
 },
+#define GattAppKey (charConfigs[5])
+{
+  UNINITIALIZED,
+  "AT+GATTADDCHAR=UUID=0x2AD7,PROPERTIES=0x0A,MIN_LEN=16,MAX_LEN=16,DATATYPE=2,DESCRIPTION=AppKey",
+  assignAppKeyCallback
+},
+#define GattAppEUI (charConfigs[6])
+{
+  UNINITIALIZED,
+  "AT+GATTADDCHAR=UUID=0x2AD8,PROPERTIES=0x0A,MIN_LEN=8,MAX_LEN=8,DATATYPE=2,DESCRIPTION=AppEUI",
+  assignAppEUICallback
+},
+#define GattDevEUI (charConfigs[7])
+{
+  UNINITIALIZED,
+  "AT+GATTADDCHAR=UUID=0x2AD9,PROPERTIES=0x0A,MIN_LEN=8,MAX_LEN=8,DATATYPE=2,DESCRIPTION=DevEUI",
+  assignDevEUICallback
+},
 #define GattSF (charConfigs[8])
 {
   UNINITIALIZED,
@@ -370,6 +388,15 @@
     debugPrint("Join keys set - initializing lora join");
     loraJoin(settings.seq_no, settings.AppKey, settings.AppEUI, settings.DevEUI, onJoin);
   }
+  if (settings.flags & FLAG_APP_KEY_SET) {
+    setBluetoothCharData(GattAppKey.charId, settings.AppKey, sizeof(settings.AppKey));
+  }
+  if (settings.flags & FLAG_APP_EUI_SET) {
+    setBluetoothCharData(GattAppEUI.charId, settings.AppEUI, sizeof(settings.AppEUI));
+  }
+  if (settings.flags & FLAG_DEV_EUI_SET) {
+    setBluetoothCharData(GattDevEUI.charId, settings.DevEUI, sizeof(settings.DevEUI));
+  }
 }

 void setup() {


pir-motion-led-dimmer.ino: calibrate

pir-motion-led-dimmer.ino: calibrate

Give the PIR motion sensor some time to calibrate.

Signed-off-by: Leon Anavi <be92910ae7bb6f58bb9b7c6f845bc30640119592@anavi.org>

--- anavi-led-dimmer/pir-motion-led-dimmer/pir-motion-led-dimmer.ino
+++ anavi-led-dimmer/pir-motion-led-dimmer/pir-motion-led-dimmer.ino
@@ -23,10 +23,20 @@
 void setup()
 {
 	pinMode(PWM, OUTPUT);
-	analogWrite(PWM, 0);
 	pinMode(BUT, INPUT_PULLUP);
 	currentButtonState = digitalRead(BUT);
 	pinMode(PIR, INPUT_PULLUP);
+  digitalWrite(PIR, LOW);
+
+  //give the sensor some time to calibrate
+  for(int iter = 0; iter < 30; iter++)
+  {
+    analogWrite(PWM, (iter*4));
+    delay(1000);
+  }
+  // Turn off the lights at startup
+  analogWrite(PWM, 0);
+  delay(50);
 }

 void loop()


Update Firmware.ino

Update Firmware.ino

--- src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
+++ src/piggy_back_loggers/SD_prototype_Firmware/Firmware/Firmware.ino
@@ -88,6 +88,9 @@
   digitalWrite(4, HIGH);
   pinMode(5, INPUT);

+  rtcTransfer(reg_Tmr_CLKOUT_ctrl, WRITE, 0x3A);                  // Setup RTC Timer
+  rtcTransfer(reg_Tmr_A_freq_ctrl, WRITE, 0x02);
+  rtcTransfer(reg_Tmr_A_reg, WRITE, 0x04);
   rtcTransfer(reg_Control_2, WRITE, 0x02);

   attachInterrupt(digitalPinToInterrupt(2), INT0_ISR, FALLING);   // Setup Interrupts


Update NeoPixel.ino

Update NeoPixel.ino

--- examples/More/NeoPixel/NeoPixel.ino
+++ examples/More/NeoPixel/NeoPixel.ino
@@ -47,7 +47,7 @@

 BLYNK_WRITE(1)
 {
-  int shift = param[0].asInt();
+  int shift = param.asInt();
   for(int i=0; i< strip.numPixels(); i++)
   {
     strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + shift) & 255));


Update Send_SMS.ino

Update Send_SMS.ino

--- examples/Send_SMS/Send_SMS.ino
+++ examples/Send_SMS/Send_SMS.ino
@@ -2,7 +2,7 @@

 unsigned long bauds = 19200;
 char code[] = "0000";
-char addr[] = "\"+37255582814\"";
+char addr[] = "\"+000000000\"";
 char msg[] = "Hello World!";

 void setup() {
@@ -18,4 +18,4 @@
   SIM.smsSend(addr, msg);
 }

-void loop() {}+void loop() {}


Fixed 'const' placement. Comments now match the code; presumably both are equally correct now.

--- examples/XYMatrix/XYMatrix.ino
+++ examples/XYMatrix/XYMatrix.ino
@@ -121,7 +121,7 @@
 // it, "leds_plus_safety_pixel".  Then declare "leds" as a pointer to
 // that array, but starting with the 2nd element (id=1) of that array:
 //    CRGB leds_with_safety_pixel[41];
-//    const CRGB* leds( leds_plus_safety_pixel + 1);
+//    CRGB* const leds( leds_plus_safety_pixel + 1);
 // Then you use the "leds" array as you normally would.
 // Now "leds[0..N]" are aliases for "leds_plus_safety_pixel[1..(N+1)]",
 // AND leds[-1] is now a legitimate and safe alias for leds_plus_safety_pixel[0].
@@ -150,7 +150,7 @@

 #define NUM_LEDS (kMatrixWidth * kMatrixHeight)
 CRGB leds_plus_safety_pixel[ NUM_LEDS + 1];
-CRGB* leds( leds_plus_safety_pixel + 1);
+CRGB* const leds( leds_plus_safety_pixel + 1);

 uint16_t XYsafe( uint8_t x, uint8_t y)
 {
@@ -194,4 +194,3 @@
   FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
   FastLED.setBrightness( BRIGHTNESS );
 }
-


minor update to display

minor update to display

--- src/main.ino
+++ src/main.ino
@@ -123,6 +123,10 @@
   ssd1306_setpos(5, 4);
   ssd1306_string_font6x8("TAPS: ");
   ssd1306_numdec_font6x8(consecutiveButtonTaps);
+  // ssd1306_setpos(5, 6);
+  // ssd1306_numdec_font6x8(tick);
+  // ssd1306_string_font6x8(" - ");
+  // ssd1306_numdec_font6x8(millis());
 }


Set up irrigation; fiddled with watering times (to 15 seconds every 12 hours). Rewrote output for pretty (again). Minor fixes.

--- plantstation.ino
+++ plantstation.ino
@@ -1,4 +1,4 @@
-//===== General deployment defs =================
+  //===== General deployment defs =================
 String appId = "Plant01";
 //String location = "Dinning Room Window";
 String location = "Living Room Side Table";
@@ -73,21 +73,22 @@
 //===== For water pump ===========================
 const byte waterPumpPin = A5;
 // todo - find right value for this
-const int waterLevelThreshold = 20; // <- made this up
+const int waterLevelThreshold = 5;
+const int waterMaxVal = 280; // was at 271 full when i got here. its at 263 with 2 cups off.
+const int waterMinVal = 10;
 boolean waterPumpIsOn = false;
-unsigned long wateringSeconds = 30000;
+unsigned long wateringSeconds = 15000;
 unsigned long prevWatering = 0;
-int waterMaxVal = 450;
-int waterMinVal = 325;

 //===== For timed events =========================
-// todo - timed events use regule marers for 1 min 1 hour etc and divide blah
 unsigned long prevMinOneMillis = 0;
-unsigned long minOneInterval = 60000;
+unsigned long minOneInterval = 1*60000;
+
 unsigned long prevMinFiveMillis = 0;
-unsigned long minFiveInterval = 300000;
+unsigned long minFiveInterval = 5*60000;
+
 unsigned long prevHourTwelveMillis = 0;
-unsigned long hourTwelveInterval = 43200000;
+unsigned long hourTwelveInterval = 12*60*60000;

 void setup() {
   pinMode(lightSwitchPin, OUTPUT);
@@ -102,7 +103,7 @@
   Console.begin();

   while (!Console);
-  Console.print("\nPlantStation is warming up.\nYun Console is warming up.\nKeen is warming up.\n\n");
+  Console.print("\n PlantStation is warming up.\n\n 60 seconds to first event recording.\n\n");

   // Because we need initial moisture and water level readings
   digitalWrite(hygroPower, HIGH);
@@ -279,7 +280,7 @@
 }

 void sendToKeen() {
-  Console.print("\n Sending data to Keen.io");
+  Console.print("| Sending data to Keen.io\t\t\t|");
   String my_output = "{";
   // strings
   my_output += "\"AppId\":\"";                      my_output += appId;             my_output += "\"";
@@ -310,48 +311,54 @@
   myKeen.addEvent("arduino_board_test", my_output);
   myKeen.printRequest();

-  Console.println();
+  Console.println("");

   while (myKeen.available()) {
     char c = myKeen.read();
     Console.print(c);
   }

-  Console.println();
-  Console.flush();
+  Console.print("\t\t\t\t|");
+//  Console.flush();
+  Console.print("\n-------------------------------------------------\n");
 }

 void outputEvent() {
-  String my_output = "\n";
-
-  my_output += " App Id\t\t\t";        my_output += appId;               my_output +="\n";
-  my_output += " Location\t\t";        my_output += location;            my_output +="\n";
-
-  my_output += " Temp Air, C\t\t";      my_output += am.tempAirC;         my_output +="\n";
-  my_output += " Temp Soil, C\t\t";    my_output += sm.tempSoilC;        my_output +="\n";
-  my_output += " Temp Air, F\t\t";      my_output += am.tempAirF;         my_output +="\n";
-  my_output += " Temp Soil, F\t\t";    my_output += sm.tempSoilF;        my_output +="\n";
-
-  my_output += " Heat Index\t\t";      my_output += am.heatIndex;        my_output +="\n";
-  my_output += " Humidity %\t\t";      my_output += am.humidityAir;      my_output +="\n";
-
-  my_output += " Light %\t\t";        my_output += lightPercent;        my_output +="\n";
-  my_output += " Light Val\t\t";       my_output += lightResistorVal;    my_output +="\n";
-  my_output += " Light Is On\t\t";     my_output += lightIsOn;           my_output +="\n";
-
-  my_output += " Moisture\t\t";         my_output += moistureStatus;      my_output +="\n";
-  my_output += " Moisture %\t\t";      my_output += moisturePercent;     my_output +="\n";
-  my_output += " Moisture\t\t";        my_output += moistureSensorVal;   my_output +="\n";
-
-  my_output += " Water Level\t\t";     my_output += waterLevelStatus;    my_output +="\n";
-  my_output += " Water Level %\t\t";   my_output += waterLevelPercent;   my_output +="\n";
-  my_output += " Water Level Val\t";   my_output += waterLevelVal;       my_output +="\n";
-  my_output += " Water Pump Is On\t";  my_output += waterPumpIsOn;       my_output +="\n";
+
+  String newLine = "|\t\t\t\t\t\t|\n";
+  String endline = "\t\t\t|\n";
+
+  String my_output = "\n ";
+  my_output += millis();
+//  my_output += "\t\t\t\t\t|";
+  my_output += "\n-------------------------------------------------\n";
+//  my_output += "\n";
+  my_output += "| App Id\t\t";          my_output += appId;               my_output += endline;
+  my_output += "| Location\t\t";        my_output += location;            my_output += "\t|\n";
+  my_output += newLine;
+  my_output += "| Temp Air, C\t\t";     my_output += am.tempAirC;         my_output += endline;
+  my_output += "| Temp Soil, C\t\t";    my_output += sm.tempSoilC;        my_output += endline;
+  my_output += "| Temp Air, F\t\t";     my_output += am.tempAirF;         my_output += endline;
+  my_output += "| Temp Soil, F\t\t";    my_output += sm.tempSoilF;        my_output += endline;
+  my_output += newLine;
+  my_output += "| Heat Index\t\t";      my_output += am.heatIndex;        my_output += endline;
+  my_output += "| Humidity %\t\t";      my_output += am.humidityAir;      my_output += endline;
+  my_output += newLine;
+  my_output += "| Light %\t\t";         my_output += lightPercent;        my_output += endline;
+  my_output += "| Light Val\t\t";       my_output += lightResistorVal;    my_output += endline;
+  my_output += "| Light Is On\t\t";     my_output += lightIsOn;           my_output += endline;
+  my_output += newLine;
+  my_output += "| Moisture\t\t";        my_output += moistureStatus;      my_output += endline;
+  my_output += "| Moisture %\t\t";      my_output += moisturePercent;     my_output += endline;
+  my_output += "| Moisture\t\t";        my_output += moistureSensorVal;   my_output += endline;
+  my_output += newLine;
+  my_output += "| Water Level\t\t";     my_output += waterLevelStatus;    my_output += endline;
+  my_output += "| Water Level %\t\t";   my_output += waterLevelPercent;   my_output += endline;
+  my_output += "| Water Level Val\t";   my_output += waterLevelVal;       my_output += endline;
+  my_output += "| Water Pump Is On\t";  my_output += waterPumpIsOn;       my_output += endline;
+  my_output += newLine;

   Console.println();
-  Console.println();
-  Console.println(millis());
-  Console.print("--------------------------------------------------");
   Console.print(my_output);
 }

@@ -359,6 +366,16 @@
 {
   return (in_min - x) * out_max / (in_min - in_max);
 }
+
+/*
+Watering Details
+Watering time                  15 seconds
+Estimated amount per watering   6 oz
+Water tank capacity            64 oz
+Watering Frequency             Every twelve hours (twice daily)
+Estimated watering for         About 5 days
+*/
+

 /*
 const int moistureMaxVal = 453;


Comment update

Comment update

--- examples/cvseq_test/cvseq_test.ino
+++ examples/cvseq_test/cvseq_test.ino
@@ -134,8 +134,10 @@
     );
     */

-    // Write
+    // Write Pin1 Scale tone
     analogWrite(OUT_PIN_1, val);
+
+    // Write Pin2
     analogWrite(OUT_PIN_2, val2 * 5);

     // Quant Tempo off Analog input


add wifiscan interface

add wifiscan interface

--- src/neurite.ino
+++ src/neurite.ino
@@ -895,21 +895,38 @@
 	server->on("/edit", HTTP_PUT, handleFileCreate);
 	server->on("/edit", HTTP_DELETE, handleFileDelete);
 	server->on("/edit", HTTP_POST, []() {
-			server->send(200, "text/plain", "");
-			}, handleFileUpload);
+		server->send(200, "text/plain", "");
+	}, handleFileUpload);
 	server->on("/save", HTTP_POST, handleSave);
-
 	server->onNotFound(handleNotFound);

 	server->on("/all", HTTP_GET, []() {
-			String json = "{";
-			json += "\"heap\":"+String(ESP.getFreeHeap());
-			json += ", \"analog\":"+String(analogRead(A0));
-			json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
-			json += "}";
-			server->send(200, "text/json", json);
-			json = String();
-			});
+		String json = "{";
+		json += "\"heap\":"+String(ESP.getFreeHeap());
+		json += ", \"analog\":"+String(analogRead(A0));
+		json += ", \"gpio\":"+String((uint32_t)(((GPI | GPO) & 0xFFFF) | ((GP16I & 0x01) << 16)));
+		json += "}";
+		server->send(200, "text/json", json);
+		json = String();
+	});
+	server->on("/wifiscan", HTTP_GET, []() {
+		server->send(200, "text/plain", "scan triggered");
+		log_dbg("scan start\r\n");
+		int n = WiFi.scanNetworks();
+		log_dbg("scan done\r\n");
+		if (n > 0) {
+			for (int i = 0; i < n; i++) {
+				log_dbg("");
+				LOG_SERIAL.print(WiFi.SSID(i));
+				LOG_SERIAL.print(" (");
+				LOG_SERIAL.print(WiFi.RSSI(i));
+				LOG_SERIAL.println(")");
+			}
+		} else {
+			log_dbg("No WLAN found\r\n");
+		}
+	});
+
 	server->on("/", handleRoot);
 }