Changed to the NC relay

Changed to the NC relay

--- MakerspaceOSRFIDAuthentication/MakerspaceOSRFIDAuthentication.ino
+++ MakerspaceOSRFIDAuthentication/MakerspaceOSRFIDAuthentication.ino
@@ -119,7 +119,7 @@
 {

   pinMode(RELAY1, OUTPUT);
-  digitalWrite(RELAY1,HIGH);
+  digitalWrite(RELAY1,LOW);

   #ifdef DEBUG  //Only setup serial if in debug
     Serial.begin(9600);
@@ -248,7 +248,7 @@
       #ifdef USELED

       #endif
-       digitalWrite(RELAY1,HIGH);
+       digitalWrite(RELAY1,LOW);
     }
   }

@@ -316,7 +316,7 @@

           if(serial == storedSerial)
           {
-              digitalWrite(RELAY1,HIGH);
+              digitalWrite(RELAY1,LOW);
               StopTimer();
               SetTimer(0);
               storedSerial = "";
@@ -358,7 +358,7 @@
                #endif

-               digitalWrite(RELAY1,LOW);
+               digitalWrite(RELAY1,HIGH);

                if(accessResponse.TimeLimit != 0)
                {


Clear serial after module init and added comm test.

--- examples/ArduinoUnoNano-basic/ArduinoUnoNano-basic.ino
+++ examples/ArduinoUnoNano-basic/ArduinoUnoNano-basic.ino
@@ -73,8 +73,21 @@
   delay(500);
   digitalWrite(12, HIGH);

+  delay(100); //wait for the RN2xx3's startup message
+  mySerial.flush();
+
   //Autobaud the rn2483 module to 9600. The default would otherwise be 57600.
   myLora.autobaud();
+
+  //check communication with radio
+  String hweui = myLora.hweui();
+  while(hweui.length() != 16)
+  {
+    Serial.println("Communication with RN2xx3 unsuccesful. Power cycle the board.");
+    Serial.println(hweui);
+    delay(10000);
+    hweui = myLora.hweui();
+  }

   //print out the HWEUI so that we can register it via ttnctl
   Serial.println("When using OTAA, register this DevEUI: ");


Delete C_DISCOR-Arduino.ino

Delete C_DISCOR-Arduino.ino

--- BMS_Francais/Examples/C_DISCOR-Arduino/C_DISCOR-Arduino.ino
+++ BMS_Francais/Examples/C_DISCOR-Arduino/C_DISCOR-Arduino.ino
@@ -1,72 +0,0 @@
-/*-------------------------------------------------------------------------------------------------------------------------------------------*
- * SE2R : C_DISCOR - Fonction de détection temporisée de discordance entre deux valeurs ToR ou analogiques                        29/06/2015 *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- *        C_DISCOR(float IN1, float IN2, float DIF, float CPT[], boolean RES[], int CFG)                                          29/06/2015 *
- *                IN1 : Première valeur à comparer                                                                                *
- *                IN2 : Deuxième valeur à comparer                                                                                *
- *                DIF : Différence maximum tolérée entre IN1 et IN2                                                                          *
- *                TPO : [0] Compteur de temporisation                                                                                *
- *                      [1] Tempo de confirmation de la discordance                                                                          *
- *                      [2] Temps de cycle automate calculé par la fonction                                                                  *
- *                      [3] Mémorisation de la variable système Millis pour le calcul du temps de cycle                                      *
- *                RES : [0] Discordance de l'équipement - forcément un tableau de taille au moins 1                                          *
- *                CFG : Commande de forçage.                                                                                *
- *                      <0 : RES maintenu à false donc en discordance                                                                        *
- *                      0  : RES figée dans son dernier état connu                                                                           *
- *                      1  : RES est true sauf si IN1 et IN2 diffèrent de plus de DIF pendant plus de CPT[1] sans discontinuer               *
- *                      2  : RES maintenu à true en permanence                                                                               *
- *                      3  : RES maintenu à true en permanence                                                                               *
- *                      >3 : RES maintenu à false                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * Copyright SE2R under the APACHE Licence                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * Plate-formes testées : Arduino Leonardo, Arduino Uno                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*
- * 29/06/2015 : DD, SE2R : Testée et validée sur banc                                                                                *
- *-------------------------------------------------------------------------------------------------------------------------------------------*/
-
- // Déclaration des bibliothèques nécessaires à l'exécution du programme ---------------------------------------------------------------------*
-#include <BMS.h>                         // Biblio   - SE2R - Fonctions BMS
-BMS BMS;
-
-// Déclaration des variables nécessaires à l'exécution du programme -------------------------------------------------------------------------*
-boolean FCO_XXXX;                        // C_DISCOR - Demande de marche de l'équipement
-boolean ED2_MGL_XXXX;                    // C_DISCOR - Etat de la voie de suivi de marche
-boolean FCO_REAR;                        // C_DISCOR - Demande de réarmement
-boolean FDM_XXXX[1];                     // C_DISCOR - Etat de la commande à transmettre à la sortie
-float VTT_XXXX[4];                       // C_DISCOR - Table de mesure du temps de discordance
-
-void setup() {                           // Initialisation ----------------------------------------------------------------------------------*
-  pinMode(2, INPUT);                     // C_DISCOR - Affectation de la voie 00 en tant qu'entrée de retour de marche
-  pinMode(3, INPUT);                     // C_DISCOR - Affectation de la voie 01 en tant qu'entrée de demande de marche
-  pinMode(4, INPUT);                     // C_DISCOR - Affectation de la voie 04 en tant que BP de réarmement
-  VTT_XXXX[1] = 10;                      // C_DISCOR - Paramétrage de la temporisations de confirmation de discordance
-  Serial.begin(9600);                    // Port COM - Paramétrage du port série
-}
-
-void loop() {                            // Exécution ---------------------------------------------------------------------------------------*
-  if (digitalRead(2) == LOW) { ED2_MGL_XXXX = true; } else { ED2_MGL_XXXX = false; } // Entrée de retour de marche NO (shunt = marche)
-  if (digitalRead(3) == LOW) { FCO_XXXX = true; } else { FCO_XXXX = false; }         // Entrée de demande de marche NO (shunt = demande)
-  if (digitalRead(4) == LOW) { FCO_REAR = true; } else { FCO_REAR = false; }         // Entrée de réarmement NO (shunt = demande)
-  if (FCO_REAR) { FDM_XXXX[0] = true; }
-  BMS.C_DISCOR(FCO_XXXX, ED2_MGL_XXXX, 0.5, VTT_XXXX, FDM_XXXX, 1 - (2 * (FDM_XXXX[0] == false)));
-  Serial.print("Commande : ");
-  Serial.print("\t");
-  Serial.print(FCO_XXXX);
-  Serial.print("\t");
-  Serial.print("Retour : ");
-  Serial.print("\t");
-  Serial.print(ED2_MGL_XXXX);
-  Serial.print("\t");
-  Serial.print("Rearmement : ");
-  Serial.print("\t");
-  Serial.print(FCO_REAR);
-  Serial.print("\t");
-  Serial.print("Compteur T : ");
-  Serial.print("\t");
-  Serial.print(VTT_XXXX[0]);
-  Serial.print("\t");
-  Serial.print("Discordance : ");
-  Serial.print("\t");
-  Serial.println(FDM_XXXX[0]);
-}


Updated to indicate I updated it

Updated to indicate I updated it

--- projects/arduino/emily/emily.ino
+++ projects/arduino/emily/emily.ino
@@ -29,8 +29,9 @@
  * Copyright © 2017 Waren Gonzaga
  */

+// Updated to work with KWM-30881CVB by Ryan Brock
+
 #include <Arduino.h>
-

 // Part # KWM-30881CVB
 // KWM Column: 1   2   3   4   5   6   7   8
@@ -44,12 +45,12 @@

 // 2-dimensional array of column pin numbers:
 const int col[8] = {
-  A5, 7, 6, 4, 5, A3, A6, A7
+  A5, D7, D6, D4, D5, A3, A6, A7
 };

 // 2-dimensional array of row pin numbers:
 const int row[8] = {
-  4, 2, A1, 3, 9, A0, 8, 10
+  D4, D2, A1, D3, D9, A0, D8, D10
 };


Examples: update SD write with autoMic and RevC/D

--- examples/02-Utility/StereoAudioToSD_Fast/StereoAudioToSD_Fast.ino
+++ examples/02-Utility/StereoAudioToSD_Fast/StereoAudioToSD_Fast.ino
@@ -6,13 +6,15 @@
  *    >>> START recording by having potentiometer turned above half-way
  *    >>> STOP recording by having potentiometer turned below half-way
  *
- * Assumes use of Teensy 3.6 and Tympan Rev A or C
+ * Assumes Tympan Rev C or D.  Program in Arduino IDE as a Teensy 3.6.
  *
  * Uses super-fast SD library that is originall from Greiman, but which
  *    has been forked, made compatible with the Teensy Audio library, and
  *    included as part of the Tympan Library.
  *
  * Created: Chip Audette, OpenAudio, March 2018
+ *  Jun 2018: updated for Tympan RevC or RevD
+ *  Jun 2018: updated to adde automatic mic detection
  *
  * License: MIT License, Use At Your Own Risk
  */
@@ -28,12 +30,12 @@

 //set the sample rate and block size
 const float sample_rate_Hz = 44117.0f ; //24000 or 44117 (or other frequencies in the table in AudioOutputI2S_F32)
-//const float sample_rate_Hz = 96000.0f ; //24000 or 44117 (or other frequencies in the table in AudioOutputI2S_F32)
 const int audio_block_samples = 128;     //do not make bigger than AUDIO_BLOCK_SAMPLES from AudioStream.h (which is 128)
 AudioSettings_F32 audio_settings(sample_rate_Hz, audio_block_samples);

 //create audio library objects for handling the audio
-AudioControlTLV320AIC3206 audioHardware;
+TympanPins                tympPins(TYMPAN_REV_C);        //TYMPAN_REV_C or TYMPAN_REV_D
+TympanBase                audioHardware(tympPins);
 AudioInputI2S_F32         i2s_in(audio_settings);     //Digital audio in *from* the Teensy Audio Board ADC.
 AudioRecordQueue_F32      queueLeft(audio_settings);     //gives access to audio data (will use for SD card)
 AudioRecordQueue_F32      queueRight(audio_settings);     //gives access to audio data (will use for SD card)
@@ -46,16 +48,11 @@
 AudioConnection_F32       patchcord3(i2s_in, 0, i2s_out, 0);    //echo audio to output
 AudioConnection_F32       patchcord4(i2s_in, 1, i2s_out, 1);    //echo audio to output

-//The Tympan has a potentiometer and some LEDs
-#define POT_PIN A1  //potentiometer is tied to this pin
-#define RED_LED_PIN A16  //Red LED...shows that system is ready but not trying to write to SD
-#define AMBER_LED_PIN A17 //Amber LED...shows that system thinks that it is writing to SD
-
 // Create variables to decide how long to record to SD
 SDAudioWriter_SdFat my_SD_writer;

 // define the setup() function, the function that is called once when the device is booting
-const float input_gain_dB = 20.0f; //gain on the microphones
+const float input_gain_dB = 15.0f; //gain on the microphones
 float32_t potentiometer_value = 0.0f;  //set in Service Potentiometer
 void setup() {
   //begin the serial comms (for debugging)
@@ -63,15 +60,18 @@
   Serial.println("StereoAudioToSD: Starting setup()...");

   //allocate the audio memory
-  AudioMemory(10); AudioMemory_F32(MAX_F32_BLOCKS,audio_settings); //I can only seem to allocate 400 blocks
+  AudioMemory_F32(MAX_F32_BLOCKS,audio_settings); //I can only seem to allocate 400 blocks
   Serial.println("StereoAudioToSD: memory allocated.");

   //Enable the Tympan to start the audio flowing!
   audioHardware.enable(); // activate AIC
   Serial.print("StereoAudioToSD: runnng at a sample rate of (Hz): ");
   Serial.println(sample_rate_Hz);
-
-  //Choose the desired audio input on the Typman
+
+  //enable the Tympman to detect whether something was plugged inot the pink mic jack
+  audioHardware.enableMicDetect(true);
+
+  //Choose the desired audio input on the Typman...this will be overridden by the serviceMicDetect() in loop()
   audioHardware.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC); // use the on-board microphones
   //audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_MIC); // use the microphone jack - defaults to mic bias 2.5V
   //audioHardware.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF
@@ -79,10 +79,9 @@
   //Set the desired input gain level
   audioHardware.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps

-  // setup any other other features
-  pinMode(POT_PIN, INPUT); //set the potentiometer's input pin as an INPUT
-  pinMode(RED_LED_PIN, OUTPUT);  digitalWrite(RED_LED_PIN,HIGH); //turn on Red LED
-  pinMode(AMBER_LED_PIN, OUTPUT); digitalWrite(AMBER_LED_PIN,LOW); //keep Amber LED off
+  //Set the state of the LEDs
+  audioHardware.setRedLED(HIGH);
+  audioHardware.setAmberLED(LOW);

   // check the volume knob
   servicePotentiometer(millis(),0);  //the "0" is not relevant here.
@@ -103,6 +102,9 @@
   //check the potentiometer
   servicePotentiometer(millis(),100); //service the potentiometer every 100 msec

+  //check the mic_detect signal
+  serviceMicDetect(millis(),500);
+
   //check to see whether to print the CPU and Memory Usage
   //printCPUandMemory(millis(),3000); //print every 3000 msec

@@ -120,16 +122,14 @@
   //has enough time passed to update everything?
   if (curTime_millis < lastUpdate_millis) lastUpdate_millis = 0; //handle wrap-around of the clock
   if ((curTime_millis - lastUpdate_millis) > updatePeriod_millis) { //is it time to update the user interface?
-      potentiometer_value = ((float32_t)analogRead(POT_PIN)) / 1024.0;
-
-      lastUpdate_millis = curTime_millis;
+    potentiometer_value = ((float32_t)(audioHardware.readPotentiometer())) / 1023.0;
+    lastUpdate_millis = curTime_millis;
   } // end if
 } //end servicePotentiometer();

 //This routine prints the current and maximum CPU usage and the current usage of the AudioMemory that has been allocated
 void printCPUandMemory(unsigned long curTime_millis, unsigned long updatePeriod_millis) {
-  //static unsigned long updatePeriod_millis = 3000; //how many milliseconds between updating gain reading?
   static unsigned long lastUpdate_millis = 0;

   //has enough time passed to update everything?
@@ -141,11 +141,6 @@
     Serial.print("%/");
     Serial.print(audio_settings.processorUsageMax());
     Serial.print("%,   ");
-    Serial.print("Dyn MEM Int16 Cur/Peak: ");
-    Serial.print(AudioMemoryUsage());
-    Serial.print("/");
-    Serial.print(AudioMemoryUsageMax());
-    Serial.print(",   ");
     Serial.print("Dyn MEM Float32 Cur/Peak: ");
     Serial.print(AudioMemoryUsage_F32());
     Serial.print("/");
@@ -153,6 +148,29 @@
     Serial.println();

     lastUpdate_millis = curTime_millis; //we will use this value the next time around.
+  }
+}
+
+
+void serviceMicDetect(unsigned long curTime_millis, unsigned long updatePeriod_millis) {
+  static unsigned long lastUpdate_millis = 0;
+  static unsigned int prev_val = 1111; //some sort of weird value
+  unsigned int cur_val = 0;
+
+  //has enough time passed to update everything?
+  if (curTime_millis < lastUpdate_millis) lastUpdate_millis = 0; //handle wrap-around of the clock
+  if ((curTime_millis - lastUpdate_millis) > updatePeriod_millis) { //is it time to update the user interface?
+
+    cur_val = audioHardware.updateInputBasedOnMicDetect(); //if mic is plugged in, defaults to TYMPAN_INPUT_JACK_AS_MIC
+    if (cur_val != prev_val) {
+      if (cur_val) {
+        Serial.println("serviceMicDetect: detected plug-in microphone!  External mic now active.");
+      } else {
+        Serial.println("serviceMicDetect: detected removal of plug-in microphone. On-board PCB mics now active.");
+      }
+    }
+    prev_val = cur_val;
+    lastUpdate_millis = curTime_millis;
   }
 }

@@ -201,7 +219,7 @@
       Serial.println("Closing SD File...");
       my_SD_writer.close();
       queueLeft.end();  queueRight.end();
-      digitalWrite(RED_LED_PIN,HIGH); digitalWrite(AMBER_LED_PIN,LOW); //turn on red LED
+      audioHardware.setRedLED(HIGH); audioHardware.setAmberLED(LOW); //Turn OFF the Amber LED
     }
   } else {
     //no SD recording currently, so no SD action
@@ -213,7 +231,7 @@
       if (my_SD_writer.open(fname)) {
         Serial.print("Opened "); Serial.print(fname); Serial.println(" on SD for writing.");
         queueLeft.begin(); queueRight.begin();
-        digitalWrite(RED_LED_PIN,LOW); digitalWrite(AMBER_LED_PIN,HIGH); //turn on Amber LED
+        audioHardware.setRedLED(LOW); audioHardware.setAmberLED(HIGH); //Turn ON the Amber LED
       } else {
         Serial.print("Failed to open "); Serial.print(fname); Serial.println(" on SD for writing.");
       }


Replace A2 with A0 ADXL3xx.ino to support all platforms

--- build/shared/examples/07.Sensors/ADXL3xx/ADXL3xx.ino
+++ build/shared/examples/07.Sensors/ADXL3xx/ADXL3xx.ino
@@ -30,7 +30,7 @@
 const int groundpin = 18;             // analog input pin 4 -- ground
 const int powerpin = 19;              // analog input pin 5 -- voltage
 const int xpin = A3;                  // x-axis of the accelerometer
-const int ypin = A2;                  // y-axis
+const int ypin = A0;                  // y-axis
 const int zpin = A1;                  // z-axis (only on 3-axis models)

 void setup()


Changed to use D3, as D4 has the LED connected to it.

--- OpenDoorSensor/Arduino/ESP_Door_Monitor/ESP_Door_Monitor.ino
+++ OpenDoorSensor/Arduino/ESP_Door_Monitor/ESP_Door_Monitor.ino
@@ -33,7 +33,7 @@
 // identify this specific sensor with a unique ID (for the server to tell them apart)
 String doorID = "1";

-byte SWITCH = D4;
+byte SWITCH = D3;
 byte ledPin = BUILTIN_LED; // built in LED is D4
 bool door_open = false;
 unsigned long starttime;


Forgot to comment out debug lines

Forgot to comment out debug lines

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -188,15 +188,15 @@
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);
@@ -205,25 +205,23 @@
     delay(powerRelayDelay);
     digitalWrite(relayPin, HIGH);
   }
-  /*
   digitalWrite(buttonAnalog, HIGH);
   delay(powerRelayDelay);
   digitalWrite(buttonAnalog, LOW);
   delay(powerRelayDelay);
   digitalWrite(buttonAnalog, HIGH);
-  */
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);
@@ -591,15 +589,15 @@
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);
@@ -609,24 +607,24 @@
     digitalWrite(relayPin, HIGH);
   }
   /*
-  digitalWrite(buttonAnalog, HIGH);
-  delay(powerRelayDelay);
-  digitalWrite(buttonAnalog, LOW);
-  delay(powerRelayDelay);
-  digitalWrite(buttonAnalog, HIGH);
+    digitalWrite(buttonAnalog, HIGH);
+    delay(powerRelayDelay);
+    digitalWrite(buttonAnalog, LOW);
+    delay(powerRelayDelay);
+    digitalWrite(buttonAnalog, HIGH);
   */
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);
@@ -671,15 +669,15 @@
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);
@@ -689,24 +687,24 @@
     digitalWrite(relayPin, HIGH);
   }
   /*
-  digitalWrite(buttonAnalog, HIGH);
-  delay(powerRelayDelay);
-  digitalWrite(buttonAnalog, LOW);
-  delay(powerRelayDelay);
-  digitalWrite(buttonAnalog, HIGH);
+    digitalWrite(buttonAnalog, HIGH);
+    delay(powerRelayDelay);
+    digitalWrite(buttonAnalog, LOW);
+    delay(powerRelayDelay);
+    digitalWrite(buttonAnalog, HIGH);
   */
   readMotors();
   if (analogLedVal > 108)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if (analogLedVal < 80)
   {
-    Serial.println("Analog is OFF");
+    //Serial.println("Analog is OFF");
   }
   if ((analogLedVal >= 80) && (analogLedVal <= 87))
   {
-    Serial.println("Analog is ON");
+    //Serial.println("Analog is ON");
     delay(powerRelayDelay);
     digitalWrite(buttonAnalog, LOW);
     delay(powerRelayDelay);


Add a note about ATmega32U4 incompatibility to SerialEvent example

serialEvent() does not work on the ATmega32U4 boards.

Reference: https://github.com/arduino/Arduino/issues/1031

--- build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino
+++ build/shared/examples/04.Communication/SerialEvent/SerialEvent.ino
@@ -8,6 +8,9 @@
  A good test for this is to try it with a GPS receiver
  that sends out NMEA 0183 sentences.

+ NOTE: The serialEvent() feature is not available on the
+ Leonardo, Micro, or other ATmega32U4 based boards.
+
  Created 9 May 2011
  by Tom Igoe


working with average

working with average

--- motor_pump/motor_pump.ino
+++ motor_pump/motor_pump.ino
@@ -1,34 +1,55 @@
+#include <Average.h>
+
+// Reserve space for 10 entries in the average bucket.
+// Change the type between < and > to change the entire way the library works.
+Average<int> moistoure(12);
+
 const int switchPin =2;
-const int motorPin =9;
+const int motorPin =10;
 int switchstate = 0;
-const int Input = 12;
-int moistoure = 0;
+const int Input = A5;
+//float moistoure[]{0,0,0,0,0,0,0,0,0,0,0,0};
 //int ByteRecieved;
+int death =0;
+int average =  0;
+
+
+

 void setup() {
   pinMode(motorPin, OUTPUT);
   pinMode(switchPin, INPUT);
   pinMode (Input, INPUT);
-//  Serial.begin(9600);
-//  Serial.println(digitalRead(Input));
+  Serial.begin(9600);
+  Serial.println(analogRead(Input));
+
 }

 void loop(){
-moistoure = digitalRead(Input);
+  moistoure.push(analogRead(Input));
 switchstate = digitalRead(switchPin);
-
-  if (moistoure >85) {
+average = moistoure.mean();
+ delay(1000);
+ //Serial.println(switchstate);
+ death++;
+ if (death >11){
+   death = 0;
+ }
+  if (switchstate == HIGH | average < 200) {
     digitalWrite(motorPin, HIGH);
+
   }
   else{
     digitalWrite(motorPin,LOW);
+
   }

-
-//  if(Serial.available()>0){
+  if(death==11){
     //ByteRecieved = Serial.read();
-//    Serial.println(moistoure);
-//  }
+    Serial.write('Average:::');
+    Serial.println(average);
+
+  }

 }


write LED

write LED

--- sketches/foobar/foobar.ino
+++ sketches/foobar/foobar.ino
@@ -3,11 +3,14 @@

 void setup() {
   Serial.begin(BAUD);
+  pinMode(13, OUTPUT);
 }

 void loop() {
+  digitalWrite(13, HIGH);
   if (Serial.available() > 0) {
     Serial.read();
     Serial.println(MESSAGE);
   }
+  digitalWrite(13, LOW);
 }


hardware serial bug fix

hardware serial bug fix

--- Software/src/centauri_hardware/arduino/MainBoard/Serial.ino
+++ Software/src/centauri_hardware/arduino/MainBoard/Serial.ino
@@ -15,6 +15,7 @@

   // Distance
   if (part1.equalsIgnoreCase("1")) {
+    piSerial.print("1!");
     piSerial.print(front_distance);
     piSerial.print("-");
     piSerial.println(back_distance);
@@ -22,6 +23,7 @@
   // Voltage
   else if (part1.equalsIgnoreCase("2")) {
     int volt = bat_voltage * 10;
+    piSerial.print("2!");
     piSerial.println(volt);
   }


Enhance ws2812fx_patterns_web example (for ArduinoJson v6) (#167)

* Fixed random16() bug that caused it to fail on Arduino

* Enhance ws2812fx_patterns_web example (for ArduinoJson v6)

--- examples/ws2812fx_patterns_web/ws2812fx_patterns_web.ino
+++ examples/ws2812fx_patterns_web/ws2812fx_patterns_web.ino
@@ -43,7 +43,7 @@
 #include <EEPROM.h>
 #include <ArduinoOTA.h>

-#define VERSION "2.0.8"
+#define VERSION "2.1.0"

 uint8_t  dataPin = D1; // default digital pin used to drive the LED strip
 uint16_t numLeds = 30; // default number of LEDs on the strip
@@ -124,7 +124,7 @@

   // if not rebooting due to catastrophic error, restore pattern data from eeprom
   struct  rst_info  *rstInfo = system_get_rst_info();
-  Serial.print("rstInfo->reason:"); Serial.println(rstInfo->reason);
+  //Serial.print("rstInfo->reason:"); Serial.println(rstInfo->reason);
   if (rstInfo->reason !=  REASON_EXCEPTION_RST) { // not reason 2
     restoreFromEEPROM();
   }
@@ -215,7 +215,7 @@
     String data = server.arg("plain");
     Serial.println(data);

-    bool isParseOk = json2patterns(data.c_str());
+    bool isParseOk = json2patterns(data);

     if (isParseOk && numPatterns > 0) {
       ws2812fx.stop();
@@ -276,7 +276,7 @@

 #if ARDUINOJSON_VERSION_MAJOR == 5
 //#pragma message("Compiling for ArduinoJson v5")
-bool json2patterns(const char* json) {
+bool json2patterns(String &json) {
   DynamicJsonBuffer jsonBuffer(2000);
   JsonObject& deviceJson = jsonBuffer.parseObject(json);
   if (deviceJson.success()) {
@@ -355,8 +355,13 @@

 #if ARDUINOJSON_VERSION_MAJOR == 6
 //#pragma message("Compiling for ArduinoJson v6")
-bool json2patterns(const char* json) {
-  DynamicJsonDocument doc(2000);
+bool json2patterns(String &json) {
+  // in ArduinoJson v6 a DynamicJsonDocument does not expand as needed
+  // like it did in ArduinoJson v5. So rather then try to compute the
+  // optimum heap size, we'll just allocated a bunch of space on the
+  // heap and hope it's enough.
+  int freeHeap = ESP.getFreeHeap();
+  DynamicJsonDocument doc(freeHeap - 3096); // allocate all of the available heap except 3kB
   DeserializationError error = deserializeJson(doc, json);
   if (!error) {
     JsonObject deviceJson = doc.as<JsonObject>();


Update IMU.ino

Update IMU.ino

--- Firmware/IMU.ino
+++ Firmware/IMU.ino
@@ -1,56 +1,50 @@
-MPU6050 mpu;
-uint8_t mpuIntStatus;
-uint16_t packetSize;
-uint16_t fifoCount;
-uint8_t fifoBuffer[64];
-Quaternion q;
-VectorFloat gravity;
-float ypr[3];
-
-
-void mpu_initialisation() {
-
-
-  Wire.begin();
-  TWBR = 24;
-  mpu.initialize();
-  mpu.dmpInitialize();
-  mpu.setXAccelOffset(-1343);
-  mpu.setYAccelOffset(-1155);
-  mpu.setZAccelOffset(1033);
-  mpu.setXGyroOffset(19);
-  mpu.setYGyroOffset(-27);
-  mpu.setZGyroOffset(16);
-  mpu.setDMPEnabled(true);
-  packetSize = mpu.dmpGetFIFOPacketSize();
-}
-
-
-void mpu_get_values() {
-  while (fifoCount < packetSize) {
-    fifoCount = mpu.getFIFOCount();
-  }
-
-  if (fifoCount == 1024) mpu.resetFIFO();
-
-  else {
-    fifoCount = mpu.getFIFOCount();
-
-    mpu.getFIFOBytes(fifoBuffer, packetSize);
-
-
-    mpu.resetFIFO();
-
-    fifoCount -= packetSize;
-
-
-    mpu.dmpGetQuaternion(&q, fifoBuffer);
-    mpu.dmpGetGravity(&gravity, &q);
-    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
-    roll_angle = ypr[2] * 180 / PI;
-
-  }
-
-
-}
+MPU6050 mpu;
+uint8_t mpuIntStatus;
+uint16_t packetSize;
+uint16_t fifoCount;
+uint8_t fifoBuffer[64];
+Quaternion q;
+VectorFloat gravity;
+float ypr[3];

+void mpu_initialisation() {
+
+  Wire.begin();
+  TWBR = 24;
+  mpu.initialize();
+  mpu.dmpInitialize();
+  mpu.setXAccelOffset(-1343);
+  mpu.setYAccelOffset(-1155);
+  mpu.setZAccelOffset(1033);
+  mpu.setXGyroOffset(19);
+  mpu.setYGyroOffset(-27);
+  mpu.setZGyroOffset(16);
+  mpu.setDMPEnabled(true);
+  packetSize = mpu.dmpGetFIFOPacketSize();
+}
+
+
+void mpu_get_values() {
+  while (fifoCount < packetSize) {
+    fifoCount = mpu.getFIFOCount();
+  }
+
+  if (fifoCount == 1024) mpu.resetFIFO();
+
+  else {
+    fifoCount = mpu.getFIFOCount();
+
+    mpu.getFIFOBytes(fifoBuffer, packetSize);
+
+    mpu.resetFIFO();
+
+    fifoCount -= packetSize;
+
+    mpu.dmpGetQuaternion(&q, fifoBuffer);
+    mpu.dmpGetGravity(&gravity, &q);
+    mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
+    roll_angle = ypr[2] * 180 / PI;
+
+  }
+}
+


[LED7Segment/ShiftDriveSPI] tidy the code


new color calibration

new color calibration

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -9,8 +9,8 @@
 //Game ID
 #define GAME_ID 0x01 //tictactoe
 //Board ID
-#define BOARD_ID 0x01 //TODO: Change it for each board
-#define PLAYER__ID "1000"
+#define BOARD_ID 0x08 //TODO: Change it for each board
+#define PLAYER__ID "8000"

 // Hardware addresses
 #define DISPLAY_ADDRESS  0x51
@@ -541,6 +541,18 @@

 // The calibration changes from sensor to sensor
 // The values are unique for each board and sensor
+
+// New painted pieces
+void calibrateSensors(){
+  // int maxGreen, int minGreen, int maxRed, int minRed
+  for(int i = 0; i < 9; i++){
+    squares[i]->calibrateCNY70(450, 0, 830, 460);
+    delay(10);
+  }
+}
+
+/*
+// Old pieces with the colors that the 3D printer uses
 void calibrateSensors(){
   // int maxGreen, int minGreen, int maxRed, int minRed
   squares[0]->calibrateCNY70(310, 270, 350, 320);
@@ -553,6 +565,7 @@
   squares[7]->calibrateCNY70(240, 190, 310, 250);
   squares[8]->calibrateCNY70(220, 170, 270, 245);
 }
+*/

 /**********************************************


changed the protocol in the arduino side also

--- tictactoe/tictactoe.ino
+++ tictactoe/tictactoe.ino
@@ -23,7 +23,8 @@
 String MSG_DO_MOVE =  "DO_MOVE"; // id movement(0..8)
 String MSG_GET_MOVE = "GET_MOVE"; // id
 String END_CHAR = "\0d";
-String SEP_CHAR = ",";
+String SEP_CHAR_COMMANDS = " ";
+String SEP_CHAR_PARAMETERS = ",";
 // Server commands
 String CMD_WAITING_PLAYERS = "WAITING_FOR_PLAYERS";
 String CMD_RIVAL = "RIVAL"; // rival_id turn(0/1)
@@ -285,14 +286,14 @@

 void registerPlayer(){
   Serial.println("Registering player...");
-  sendMsg(MSG_REGISTER + SEP_CHAR + player_id + END_CHAR);
+  sendMsg(MSG_REGISTER + SEP_CHAR_COMMANDS + player_id + END_CHAR);
 }

 void findPlayer(){
   Serial.println("Finding other player...");
   boolean notFound = true;
   while(notFound){
-    String res = sendAndWait(MSG_FIND_GAME + SEP_CHAR  + player_id + END_CHAR);
+    String res = sendAndWait(MSG_FIND_GAME + SEP_CHAR_COMMANDS  + player_id + END_CHAR);
     String command = getCommand(res);

     // if waiting_for_player -> delay 100
@@ -320,7 +321,7 @@
   int rivalMove = -1;

   while(notMove){
-    String res = sendAndWait(MSG_GET_MOVE + SEP_CHAR + player_id + END_CHAR);
+    String res = sendAndWait(MSG_GET_MOVE + SEP_CHAR_COMMANDS + player_id + END_CHAR);
     String command = getCommand(res);

     //if wait_for_move -> delay 1000
@@ -346,7 +347,7 @@
   //If ack -> notReceived = false
   //If wait_for_rival -> delay 1000
   while(notReceived){}
-    String res = sendAndWait(MSG_DO_MOVE + SEP_CHAR + player_id + SEP_CHAR  + player_move +  END_CHAR);
+    String res = sendAndWait(MSG_DO_MOVE + SEP_CHAR_COMMANDS + player_id + SEP_CHAR_PARAMETERS  + player_move +  END_CHAR);
     String command = getCommand(res);
     if (command = CMD_ACK){
       Serial.println("Sent");


No esp calls inside interrupt function

No esp calls inside interrupt function

--- wcci/wcci.ino
+++ wcci/wcci.ino
@@ -11,13 +11,14 @@
 #define BLINK_COUNT 1
 #define BLINK_DURATION 500

-#define ESP_ACTIVE false
+#define ESP_ACTIVE true

 String commandLock = "GET /log_visit_state/0 HTTP/1.0\r\n\r\n";
 String commandUnlock = "GET /log_visit_state/1 HTTP/1.0\r\n\r\n";

 int gCount;
 int gLastState;
+bool gStateChanged = false;
 int gCourtesyDelay = 6;
 long gLastStateTimestamp;

@@ -40,11 +41,13 @@

   digitalWrite(GREEN, HIGH);

-  if (!ESP_ACTIVE)
+  if (!ESP_ACTIVE) {
     return; // bail to loop
+  }

   // setup serial with esp-01
   digitalWrite(LED, HIGH);
+  digitalWrite(GREEN, LOW);
   Serial.begin(115200);
   Serial.setTimeout(10000);

@@ -68,7 +71,18 @@
   if (!sendATJoinNetwork()) blinkLEDForever();
   blink(BLINK_COUNT, BLINK_DURATION, 1, 1, 1);
 }
+
 void loop() {
+  bool success = true;
+  if (gStateChanged) {
+    if (gLastState == LOW) {
+      success = sendLock();
+    } else {
+      success = sendUnlock();
+    }
+    gStateChanged = false;
+  }
+
   if (gLastState == LOW) {
     gCount++;
   } else if (gCount > 0) {
@@ -82,7 +96,11 @@
       digitalWrite(YELLOW, LOW);
       digitalWrite(GREEN, HIGH);
   }
+

+  if (success == false) {
+    blinkLEDForever();
+  }
   delay(500);
 }

@@ -103,14 +121,11 @@
 void onLockStateChange() {
   long now = millis();
   int state = digitalRead(SWITCH);
+
   if (state != gLastState && now - gLastStateTimestamp > 50) {
     gLastStateTimestamp = millis();
+    gStateChanged = true;
     gLastState = state;
-    if (gLastState == LOW) {
-      sendLock();
-    } else {
-      sendUnlock();
-    }
   }
 }


mirror of Slave1 (with different I2C address)

--- Testbench/Motor_Shield_Testbench/MotorShieldTestBench_Slave2/MotorShieldTestBench_Slave2.ino
+++ Testbench/Motor_Shield_Testbench/MotorShieldTestBench_Slave2/MotorShieldTestBench_Slave2.ino
@@ -1,6 +1,6 @@
 #include "TinyWireS.h"

-const int addr = 7;
+const int addr = 8;

 const int output = 6;


tx: only about once every 10 seconds

tx: only about once every 10 seconds

Signed-off-by: Robert Nelson <d6c41255011d14bfa93d8562b946ca186cfa0c7b@gmail.com>

--- ws_bm_rtc.ino
+++ ws_bm_rtc.ino
@@ -152,4 +152,10 @@
 	delay(ws_one_second);
 	delay(ws_one_second);
 	delay(ws_one_second);
+
+	delay(ws_one_second);
+	delay(ws_one_second);
+	delay(ws_one_second);
+	delay(ws_one_second);
+	delay(ws_one_second);
 }


[Important] Added line in the beginning, to the autocomplete detect changes in the position of 'setup'

--- build/shared/examples/01.Basics/BareMinimum/BareMinimum.ino
+++ build/shared/examples/01.Basics/BareMinimum/BareMinimum.ino
@@ -1,3 +1,4 @@
+
 void setup() {
   // put your setup code here, to run once:


Delete pms7003.ino

Delete pms7003.ino

--- pms7003.ino
+++ pms7003.ino
@@ -1,23 +0,0 @@
-#include <pms7003.h>
-
-pms7003 pms(1);// initialize on uart 1
-
-void setup() {
-  Serial.begin(9600);
-}
-
-
-unsigned long timer;
-uint16_t PM1_0, PM2_5, PM10;
-void loop() {
-
-
-  if ( millis() - t > 1000) {// print every 1 second
-    t = millis();
-    pms.read(PM1_0, PM2_5, PM10);
-    Serial.println("PM1.0 concentration in ug/M^3: " + String(PM1_0)) + "   PM2.5.0 concentration in ug/M^3: " + String(PM2_5) + " PM10 concentration in ug/M^3: " + String(PM10));
-  }
-
-}
-
-


Update getTouchNumber.ino

Update getTouchNumber.ino

--- Seeed_QTouch/examples/getTouchNumber/getTouchNumber.ino
+++ Seeed_QTouch/examples/getTouchNumber/getTouchNumber.ino
@@ -10,6 +10,7 @@

 void setup()
 {
+    Wire.begin();
     Serial.begin(9600);
 }

@@ -25,4 +26,4 @@
     }

     delay(10);
-}+}


Avoid compiler warning in filename declaration.

This reduces the number of `warning: deprecated conversion from string
constant to 'char*'` warnings by 1.  It has a nice side effect of
reducing the sketch size from 30,098 to 30,080 under Arduino 1.0.1.

--- printer.ino
+++ printer.ino
@@ -151,7 +151,7 @@
 // -- Check for new data and download if found

 boolean downloadWaiting = false;
-char* cacheFilename = "TMP";
+char cacheFilename[] = "TMP";
 unsigned long content_length = 0;
 boolean statusOk = false;


Don't return from terminalError

Don't return from terminalError

This makes the sketch slightly smaller (saving 16 bytes under Arduino
1.0.1) and is consistent with how we currently terminate when
encountering a DHCP error.  It'll also make it easier to use
`terminalError` in the setup function.  Without this change, we would've
had to check the systemOK boolean to see whether we could continue with
setup.

--- printer.ino
+++ printer.ino
@@ -145,10 +145,6 @@
   initNetwork();
   initPrinter();
 }
-
-// -- Flag to indicate whether we've encountered an irrecoverable error
-
-boolean systemOK = true;

 // -- Check for new data and download if found

@@ -269,8 +265,8 @@

 inline void terminalError(unsigned int times) {
   flashErrorLEDs(times, 500);
-  systemOK = false;
   digitalWrite(errorLED, HIGH);
+  while(true);
 }

 // -- Print send any data from the cache to the printer
@@ -293,17 +289,15 @@
 Bounce bouncer = Bounce(buttonPin, 5); // 5 millisecond debounce

 void loop() {
-  if (systemOK) {
-    if (downloadWaiting) {
-      bouncer.update();
-      if (bouncer.read() == HIGH) {
-        printFromDownload();
-      }
-    } else {
-      checkForDownload();
-      if (!downloadWaiting) {
-        delay(pollingDelay);
-      }
-    }
-  }
-}
+  if (downloadWaiting) {
+    bouncer.update();
+    if (bouncer.read() == HIGH) {
+      printFromDownload();
+    }
+  } else {
+    checkForDownload();
+    if (!downloadWaiting) {
+      delay(pollingDelay);
+    }
+  }
+}


Cleanup

Cleanup


UDP版の作成

UDP版の作成

--- rohm_sensors/iot_exp_sensorShield_udp/iot_exp_sensorShield_udp.ino
+++ rohm_sensors/iot_exp_sensorShield_udp/iot_exp_sensorShield_udp.ino
@@ -9,14 +9,10 @@

 乾電池などで動作するIoTセンサです

-※フラッシュを約1.5MB消費しますので、アプリ用に2MB程度を割り当ててください
-
                                           Copyright (c) 2016-2019 Wataru KUNINO
 *******************************************************************************/
 #include <WiFi.h>                           // ESP32用WiFiライブラリ
 #include <WiFiUdp.h>                        // UDP通信を行うライブラリ
-#include <BLEDevice.h>
-#include <BLEServer.h>
 #include "esp_sleep.h"                      // ESP32用Deep Sleep ライブラリ
 #define PIN_EN 2                            // GPIO 2 にLEDを接続
 #define PIN_BUZZER 12                       // GPIO 12 にスピーカを接続
@@ -26,7 +22,6 @@
 #define PORT 1024                           // 送信のポート番号
 #define SLEEP_P 50*1000000ul                // スリープ時間 50秒(uint32_t)
 #define DEVICE "rohme_1,"                   // デバイス名(5文字+"_"+番号+",")
-#define BLE_DEVICE "esp_"                   // BLE用デバイス名

 #include <Wire.h>
 #include "BM1383AGLV.h"
@@ -43,13 +38,7 @@
 IPAddress IP;                               // 本機IPアドレス
 IPAddress IP_BC;                            // ブロードキャストIPアドレス

-BLEAdvertising *pAdvertising;
-boolean wifi_enable = true;
-
-#define VAL_N 8                             // 送信データ項目数
-#define DAT_N 32                            // 送信バイト数
-
-RTC_DATA_ATTR byte SEQ_N = 0;               // 送信番号
+#define VAL_N 14                            // 送信データ項目数

 void setup(){                               // 起動時に一度だけ実行する関数
     int waiting=0;                          // アクセスポイント接続待ち用
@@ -59,7 +48,6 @@
     Serial.begin(115200);                   // 動作確認のためのシリアル出力開始
     Serial.println("IoT SensorShield EVK"); // 「IoT SensorShield EVK」を表示
     int wake = TimerWakeUp_init();
-    BLEDevice::init(BLE_DEVICE);            // Create the BLE Device
     Wire.begin();
     bm1383aglv.init();                      // 気圧センサの初期化
     kx224.init();                           // 加速度センサの初期化
@@ -76,10 +64,7 @@
         ledcWrite(0, 0);
         delay(450);                         // 待ち時間処理
         waiting++;                          // 待ち時間カウンタを1加算する
-        if(waiting > 30){
-            wifi_enable = false;
-            return;                          // 30回(15秒)を過ぎたら抜ける
-        }
+        if(waiting > 60) return;            // 60回(30秒)を過ぎたら抜ける
     }
     IP = WiFi.localIP();
     IP_BC = (uint32_t)IP | ~(uint32_t)(WiFi.subnetMask());
@@ -87,95 +72,75 @@
     if(wake<3) morseIp0(PIN_BUZZER,50,IP);  // IPアドレス終値をモールス信号出力
 }

-int d_append(byte *array,int i, byte d){
-    array[i]=d;
-    return i+1;
-}
-
-int d_append_int16(byte *array,int i, int16_t d){
-    array[i] = (byte)(d & 0xFF);
-    array[i+1] = (byte)(d >> 8);
-    return i+2;
-}
-
-int d_append_int24(byte *array,int i, int32_t d){
-    array[i] = (byte)(d & 0xFF);
-    array[i+1] = (byte)((d >>8)&0xFF);
-    array[i+2] = (byte)((d >>16)&0xFF);
-    return i+3;
-}
-
 void sensors_log(float *val){
     Serial.print("Temperature    =  ");
     Serial.print(val[0]);
     Serial.println(" [degrees Celsius]");
     Serial.print("Pressure        = ");
-    Serial.print(val[1]);
-    Serial.println(" [hPa]");
-    Serial.write("Accelerometer X = ");
+    Serial.println(val[1]);
+
+    Serial.print("Illuminance     = ");
     Serial.print(val[2]);
+    Serial.println(" [lx]");
+    Serial.print("Proximity       = ");
+    Serial.print(val[3],0);
+    Serial.println(" [count]");
+    Serial.print("Color (RED)     = ");
+    Serial.println(val[4],1);
+    Serial.print("Color (GREEN)   = ");
+    Serial.println(val[5],1);
+    Serial.print("Color (BLUE)    = ");
+    Serial.println(val[6],1);
+    Serial.print("Color (IR)      = ");
+    Serial.println(val[7],1);
+    Serial.print("Accelerometer X = ");
+    Serial.print(val[8]);
     Serial.println(" [g]");
-    Serial.write("Accelerometer Y = ");
-    Serial.print(val[3]);
+    Serial.print("Accelerometer Y = ");
+    Serial.print(val[9]);
     Serial.println(" [g]");
-    Serial.write("Accelerometer Z = ");
-    Serial.print(val[4]);
+    Serial.print("Accelerometer Z = ");
+    Serial.print(val[10]);
     Serial.println(" [g]");
+
     Serial.print("Geomagnetic X   = ");
-    Serial.print(val[5], 3);
+    Serial.print(val[11], 3);
     Serial.println("[uT]");
     Serial.print("Geomagnetic Y   = ");
-    Serial.print(val[6], 3);
+    Serial.print(val[12], 3);
     Serial.println("[uT]");
     Serial.print("Geomagnetic Z   = ");
-    Serial.print(val[7], 3);
+    Serial.print(val[13], 3);
     Serial.println("[uT]");
 }

 void loop() {
     WiFiUDP udp;                            // UDP通信用のインスタンスを定義
-    byte d[DAT_N];
     float val[VAL_N];                       // センサ用の浮動小数点数型変数
     long v;
     int l=0;

     bm1383aglv.get_val(&val[1],val);        // 気圧と温度を取得
-    v=(long)((val[0] + 45.) * 374.5);       // 温度
-    l=d_append_int16(d,l,v);
-    v=(long)(val[1] * 2048);
-    l=d_append_int24(d,l,v);                // 気圧
-
-    l=d_append(d,l,SEQ_N);                  // 送信番号
-
-    kx224.get_val(&val[2]);                 // 加速度を取得
-    for(int i=0;i<3;i++){
-        v=(long)(val[2+i] * 4096);
-        l=d_append_int16(d,l,v);
-    }
-
-    bm1422agmv.get_val(&val[5]);            // 地磁気を取得
-    for(int i=0;i<3;i++){
-        v=(long)(val[5+i] * 10);
-        l=d_append_int16(d,l,v);
-    }
-
+    unsigned short ps;
+    rpr0521rs.get_psalsval(&ps,&val[2]);    // 距離、照度を取得
+    val[3] = (float)ps;
+    unsigned short color[5];
+    long color_n = 0;
+    bh1749nuc.get_val(color);
+    for(int i=0;i<4;i++) color_n += color[i];
+    for(int i=0;i<4;i++) val[4+i] = (float)color[i] / (float)color_n * 100.;
+    kx224.get_val(&val[8]);                 // 加速度を取得
+    bm1422agmv.get_val(&val[11]);           // 地磁気を取得
+
     sensors_log(val);

-    // UDP
-    if(wifi_enable){
-        udp.beginPacket(IP_BC, PORT);       // UDP送信先を設定
-        udp.print(DEVICE);                  // デバイス名を送信
-        for(int i=0; i<VAL_N; i++){
-            udp.print(val[i],0);            // 変数tempの値を送信
-            if(i < VAL_N-1)udp.print(", "); // 「,」カンマを送信
-        }
-        udp.endPacket();                    // UDP送信の終了(実際に送信する)
+    udp.beginPacket(IP_BC, PORT);           // UDP送信先を設定
+    udp.print(DEVICE);                      // デバイス名を送信
+    for(int i=0; i<VAL_N; i++){
+        udp.print(val[i],0);                // 変数tempの値を送信
+        if(i < VAL_N-1)udp.print(", ");     // 「,」カンマを送信
     }
-    // BLE Advertizing
-    pAdvertising = BLEDevice::getAdvertising();
-    setBleAdvData(d,l);
-    pAdvertising->start();                  // Start advertising
-    SEQ_N++;
+    udp.endPacket();                        // UDP送信の終了(実際に送信する)
     sleep();
 }

@@ -183,32 +148,5 @@
     ledcWriteNote(0,NOTE_D,8);              // 送信中の音
     delay(200);                             // 送信待ち時間
     ledcWrite(0, 0);
-    pAdvertising->stop();
     esp_deep_sleep(SLEEP_P);                // Deep Sleepモードへ移行
 }
-
-void setBleAdvData(byte *data, int data_n){
-    BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
-    BLEAdvertisementData oScanResponseData = BLEAdvertisementData();
-    oAdvertisementData.setName(BLE_DEVICE);
-    oAdvertisementData.setFlags(0x06);      // LE General Discoverable Mode | BR_EDR_NOT_SUPPORTED
-
-    std::string strServiceData = "";
-    strServiceData += (char)(data_n+3);     // Len
-    strServiceData += (char)0xFF;           // Manufacturer specific data
-    strServiceData += (char)0x01;           // Company Identifier(2 Octet)
-    strServiceData += (char)0x00;
-    for(int i=0;i<data_n;i++) strServiceData += (char)(data[i]);
-
-    oAdvertisementData.addData(strServiceData);
-    pAdvertising->setAdvertisementData(oAdvertisementData);
-    pAdvertising->setScanResponseData(oScanResponseData);
-
-    Serial.print("data            = ");
-    int len=strServiceData.size();
-    if(len != (int)(strServiceData[0]) + 1 || len < 2) Serial.println("ERROR: BLE length");
-    for(int i=2;i<len;i++) Serial.printf("%02x ",(char)(strServiceData[i]));
-    Serial.println();
-    Serial.print("data length     = ");
-    Serial.println(len - 2);
-}


Update ArduCAM_Mini_3MP_OV3640_functions.ino

--- ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino
+++ ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino
@@ -45,7 +45,13 @@
 Serial.println(F("ACK CMD ArduCAM Start!"));
 // set the CS as an output:
 pinMode(CS, OUTPUT);
+digitalWrite(CS, HIGH);
 // initialize SPI:
+  //Reset the CPLD
+myCAM.write_reg(0x07, 0x80);
+delay(100);
+myCAM.write_reg(0x07, 0x00);
+delay(100);
 SPI.begin();
 while(1){
   //Check if the ArduCAM SPI bus is OK


Fix for #234

Fix for #234

Fix for #234

--- examples/2.Digital/InterruptOnChange_430/InterruptOnChange_430.ino
+++ examples/2.Digital/InterruptOnChange_430/InterruptOnChange_430.ino
@@ -16,6 +16,7 @@
 void setup() {
   pinMode(RED_LED, OUTPUT);
   digitalWrite(RED_LED, LOW);
+  pinMode(PUSH2, INPUT_PULLUP);

   edge = FALLING;
   attachInterrupt(PUSH2, func, FALLING);


Update Mimic_Serial.ino

Update Mimic_Serial.ino

Changed LED numbering from test to match new ISS PCB, also reverted serial port to be USB to USB, not FTDI

Also you can use emojis in commit messages??  :artificial_satellite:

--- Arduino/Mimic_Serial.ino
+++ Arduino/Mimic_Serial.ino
@@ -1,367 +1,367 @@
-#include <Adafruit_NeoPixel.h>
-#include <string.h>
-//Connect USB port to Pi USB Port
-//For serial debugging - connect to the RX1 and TX1 pins
-Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, 6, NEO_GRB + NEO_KHZ800);
-Adafruit_NeoPixel module_strip = Adafruit_NeoPixel(16, 7, NEO_GRB + NEO_KHZ800);
-const int ledRedPin = 13;
-const int ledBluePin = 52;
-const int ledGreenPin = 53;
-String test;
-
-double Beta1B = 0.0;
-double Beta2B = 0.0;
-double Beta3B = 0.0;
-double Beta4B = 0.0;
-double Beta1A = 0.0;
-double Beta2A = 0.0;
-double Beta3A = 0.0;
-double Beta4A = 0.0;
-double PSARJ = 0.0;
-double SSARJ = 0.0;
-double PTRRJ = 0.0;
-double STRRJ = 0.0;
-double AOS = 0.00;
-double V2A = 0.00;
-double V2B = 0.00;
-double V4A = 0.00;
-double V4B = 0.00;
-String module = "unset module";
-
-void setup()
-{
-  pinMode(ledRedPin, OUTPUT);
-  pinMode(ledBluePin, OUTPUT);
-  pinMode(ledGreenPin, OUTPUT);
-  Serial.begin(9600);
-  Serial1.begin(115200);
-  Serial1.setTimeout(50);
-  strip.begin();
-  module_strip.begin();
-  strip.show();
-  module_strip.show();
-  allSet_module(module_strip.Color(255,0,0),5);
-}
-
-void loop()
-{
-  digitalWrite(ledRedPin, LOW);
-  digitalWrite(ledGreenPin, LOW);
-  digitalWrite(ledBluePin, LOW);
-  Serial.println("-------");
-  if(Serial1.available())
-  {
-    checkSerial();
-  }
-  allSet_module(module_strip.Color(0,0,0),0);
-  //Serial.println(module);
-  if(module == "SM")
-  {
-    module_strip.setPixelColor(0, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("SM");
-  }
-  else if(module == "FGB")
-  {
-    module_strip.setPixelColor(1, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("FGB");
-  }
-  else if(module == "Node1")
-  {
-    module_strip.setPixelColor(2, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("Node1");
-  }
-  else if(module == "Node2")
-  {
-    module_strip.setPixelColor(3, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("Node2");
-  }
-  else if(module == "Node3")
-  {
-    module_strip.setPixelColor(4, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("Node3");
-  }
-  else if(module == "AL")
-  {
-    module_strip.setPixelColor(5, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("AL");
-  }
-  else if(module == "USL")
-  {
-    module_strip.setPixelColor(6, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("USL");
-  }
-  else if(module == "Col")
-  {
-    module_strip.setPixelColor(7, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("Col");
-  }
-  else if(module == "JEM")
-  {
-    module_strip.setPixelColor(8, strip.Color(255,255,255));
-    module_strip.show();
-    //Serial.println("JEM");
-  }
-  else
-  {
-    allSet_module(module_strip.Color(0,255,0),5);
-    module_strip.show();
-  }
-
-
-  if(V2A < 151.5)
-  {
-    strip.setPixelColor(0, strip.Color(255,0,0));
-    strip.setPixelColor(1, strip.Color(255,0,0));
-    strip.setPixelColor(2, strip.Color(255,0,0));
-    strip.setPixelColor(3, strip.Color(255,0,0));
-    strip.setPixelColor(4, strip.Color(255,0,0));
-    strip.setPixelColor(5, strip.Color(255,0,0));
-    strip.show();
-  }
-  else if(V2A > 160)
-  {
-    strip.setPixelColor(0, strip.Color(255,255,255));
-    strip.setPixelColor(1, strip.Color(255,255,255));
-    strip.setPixelColor(2, strip.Color(255,255,255));
-    strip.setPixelColor(3, strip.Color(255,255,255));
-    strip.setPixelColor(4, strip.Color(255,255,255));
-    strip.setPixelColor(5, strip.Color(255,255,255));
-    strip.show();
-  }
-  else
-  {
-    strip.setPixelColor(0, strip.Color(0,0,255));
-    strip.setPixelColor(1, strip.Color(0,0,255));
-    strip.setPixelColor(2, strip.Color(0,0,255));
-    strip.setPixelColor(3, strip.Color(0,0,255));
-    strip.setPixelColor(4, strip.Color(0,0,255));
-    strip.setPixelColor(5, strip.Color(0,0,255));
-    strip.show();
-  }
-
-  if(V4A < 151.5)
-  {
-    strip.setPixelColor(6, strip.Color(255,0,0));
-    strip.setPixelColor(7, strip.Color(255,0,0));
-    strip.setPixelColor(8, strip.Color(255,0,0));
-    strip.setPixelColor(9, strip.Color(255,0,0));
-    strip.setPixelColor(10, strip.Color(255,0,0));
-    strip.setPixelColor(11, strip.Color(255,0,0));
-    strip.show();
-  }
-  else if(V4A > 160)
-  {
-    strip.setPixelColor(6, strip.Color(255,255,255));
-    strip.setPixelColor(7, strip.Color(255,255,255));
-    strip.setPixelColor(8, strip.Color(255,255,255));
-    strip.setPixelColor(9, strip.Color(255,255,255));
-    strip.setPixelColor(10, strip.Color(255,255,255));
-    strip.setPixelColor(11, strip.Color(255,255,255));
-    strip.show();
-  }
-  else
-  {
-    strip.setPixelColor(6, strip.Color(0,0,255));
-    strip.setPixelColor(7, strip.Color(0,0,255));
-    strip.setPixelColor(8, strip.Color(0,0,255));
-    strip.setPixelColor(9, strip.Color(0,0,255));
-    strip.setPixelColor(10, strip.Color(0,0,255));
-    strip.setPixelColor(11, strip.Color(0,0,255));
-    strip.show();
-  }
-
-  if(V4B < 151.5)
-  {
-    strip.setPixelColor(12, strip.Color(255,0,0));
-    strip.setPixelColor(13, strip.Color(255,0,0));
-    strip.setPixelColor(14, strip.Color(255,0,0));
-    strip.setPixelColor(15, strip.Color(255,0,0));
-    strip.setPixelColor(16, strip.Color(255,0,0));
-    strip.setPixelColor(17, strip.Color(255,0,0));
-    strip.show();
-  }
-  else if(V4B > 160)
-  {
-    strip.setPixelColor(12, strip.Color(255,255,255));
-    strip.setPixelColor(13, strip.Color(255,255,255));
-    strip.setPixelColor(14, strip.Color(255,255,255));
-    strip.setPixelColor(15, strip.Color(255,255,255));
-    strip.setPixelColor(16, strip.Color(255,255,255));
-    strip.setPixelColor(17, strip.Color(255,255,255));
-    strip.show();
-  }
-  else
-  {
-    strip.setPixelColor(12, strip.Color(0,0,255));
-    strip.setPixelColor(13, strip.Color(0,0,255));
-    strip.setPixelColor(14, strip.Color(0,0,255));
-    strip.setPixelColor(15, strip.Color(0,0,255));
-    strip.setPixelColor(16, strip.Color(0,0,255));
-    strip.setPixelColor(17, strip.Color(0,0,255));
-    strip.show();
-  }
-
-  if(V2B < 151.5)
-  {
-    strip.setPixelColor(18, strip.Color(255,0,0));
-    strip.setPixelColor(19, strip.Color(255,0,0));
-    strip.setPixelColor(20, strip.Color(255,0,0));
-    strip.setPixelColor(21, strip.Color(255,0,0));
-    strip.setPixelColor(22, strip.Color(255,0,0));
-    strip.setPixelColor(23, strip.Color(255,0,0));
-    strip.show();
-  }
-  else if(V2B > 160)
-  {
-    strip.setPixelColor(18, strip.Color(255,255,255));
-    strip.setPixelColor(19, strip.Color(255,255,255));
-    strip.setPixelColor(20, strip.Color(255,255,255));
-    strip.setPixelColor(21, strip.Color(255,255,255));
-    strip.setPixelColor(22, strip.Color(255,255,255));
-    strip.setPixelColor(23, strip.Color(255,255,255));
-    strip.show();
-  }
-  else
-  {
-    strip.setPixelColor(18, strip.Color(0,0,255));
-    strip.setPixelColor(19, strip.Color(0,0,255));
-    strip.setPixelColor(20, strip.Color(0,0,255));
-    strip.setPixelColor(21, strip.Color(0,0,255));
-    strip.setPixelColor(22, strip.Color(0,0,255));
-    strip.setPixelColor(23, strip.Color(0,0,255));
-    strip.show();
-  }
-}
-void checkSerial()
-{
-  digitalWrite(ledBluePin, HIGH);
-  test = "";
-
-  while(Serial1.available())
-  {
-    test = Serial1.readString();
-  }
-  Serial.println(test);
-  char sz[test.length() + 1];
-  char copy[test.length() + 1];
-  strcpy(sz, test.c_str());
-  char *p = sz;
-  char *str;
-  int delimeter = 0;
-  String test2 = "";
-
-  while((str = strtok_r(p," ",&p))!=NULL)
-  {
-    test2 = String(str);
-    delimeter = test2.indexOf('=');
-    if(test2.substring(0,delimeter)=="PSARJ")
-    {
-      PSARJ = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="SSARJ")
-    {
-      SSARJ = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="PTRRJ")
-    {
-      PTRRJ = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="STRRJ")
-    {
-      STRRJ = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta1B")
-    {
-      Beta1B = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta1A")
-    {
-      Beta1A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta2B")
-    {
-      Beta2B = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta2A")
-    {
-      Beta2A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta3B")
-    {
-      Beta3B = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta3A")
-    {
-      Beta3A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta4B")
-    {
-      Beta4B = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Beta4A")
-    {
-      Beta4A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Voltage2A")
-    {
-      V2A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Voltage2B")
-    {
-      V2B = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Voltage4A")
-    {
-      V4A = (test2.substring(delimeter+1)).toFloat();
-    }
-    else if(test2.substring(0,delimeter)=="Voltage4B")
-    {
-      V4B = (test2.substring(delimeter+1)).toFloat();
-    }
-    //module Selection
-    else if(test2.substring(0,delimeter)=="Module")
-    {
-      //Serial.println("----Module!------");
-      module = (test2.substring(delimeter+1));
-    }
-    else if(test2.substring(0,delimeter)=="AOS")
-    {
-      //Serial1.println(test2);
-      AOS = (test2.substring(delimeter+1)).toFloat();
-      //Serial1.println(AOS);
-      if(AOS == 1.00)
-      {
-        digitalWrite(ledGreenPin, HIGH);
-      }
-      else
-      {
-        digitalWrite(ledRedPin, HIGH);
-      }
-    }
-  }
-  Serial.println();
-}
-void allSet(uint32_t c, uint8_t wait) {
-  for(uint16_t i=0; i<strip.numPixels(); i++)
-  {
-    strip.setPixelColor(i, c);
-    strip.show();
-    delay(wait);
-  }
-}
-void allSet_module(uint32_t c, uint8_t wait) {
-  for(uint16_t i=0; i<module_strip.numPixels(); i++)
-  {
-    module_strip.setPixelColor(i, c);
-    module_strip.show();
-    delay(wait);
-  }
-}
+#include <Adafruit_NeoPixel.h>
+#include <string.h>
+//Connect USB port to Pi USB Port
+//For serial debugging - connect to the RX1 and TX1 pins
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, 6, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel module_strip = Adafruit_NeoPixel(16, 7, NEO_GRB + NEO_KHZ800);
+const int ledRedPin = 13;
+const int ledBluePin = 52;
+const int ledGreenPin = 53;
+String test;
+
+double Beta1B = 0.0;
+double Beta2B = 0.0;
+double Beta3B = 0.0;
+double Beta4B = 0.0;
+double Beta1A = 0.0;
+double Beta2A = 0.0;
+double Beta3A = 0.0;
+double Beta4A = 0.0;
+double PSARJ = 0.0;
+double SSARJ = 0.0;
+double PTRRJ = 0.0;
+double STRRJ = 0.0;
+double AOS = 0.00;
+double V2A = 0.00;
+double V2B = 0.00;
+double V4A = 0.00;
+double V4B = 0.00;
+String module = "unset module";
+
+void setup()
+{
+  pinMode(ledRedPin, OUTPUT);
+  pinMode(ledBluePin, OUTPUT);
+  pinMode(ledGreenPin, OUTPUT);
+  Serial1.begin(9600);
+  Serial.begin(115200);
+  Serial.setTimeout(50);
+  strip.begin();
+  module_strip.begin();
+  strip.show();
+  module_strip.show();
+  allSet_module(module_strip.Color(255,0,0),5);
+}
+
+void loop()
+{
+  digitalWrite(ledRedPin, LOW);
+  digitalWrite(ledGreenPin, LOW);
+  digitalWrite(ledBluePin, LOW);
+  Serial1.println("-------");
+  if(Serial.available())
+  {
+    checkSerial();
+  }
+  allSet_module(module_strip.Color(0,0,0),0);
+  //Serial1.println(module);
+  if(module == "SM")
+  {
+    module_strip.setPixelColor(0, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("SM");
+  }
+  else if(module == "FGB")
+  {
+    module_strip.setPixelColor(1, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("FGB");
+  }
+  else if(module == "Node1")
+  {
+    module_strip.setPixelColor(2, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("Node1");
+  }
+  else if(module == "Node2")
+  {
+    module_strip.setPixelColor(6, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("Node2");
+  }
+  else if(module == "Node3")
+  {
+    module_strip.setPixelColor(4, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("Node3");
+  }
+  else if(module == "AL")
+  {
+    module_strip.setPixelColor(3, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("AL");
+  }
+  else if(module == "USL")
+  {
+    module_strip.setPixelColor(5, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("USL");
+  }
+  else if(module == "Col")
+  {
+    module_strip.setPixelColor(7, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("Col");
+  }
+  else if(module == "JEM")
+  {
+    module_strip.setPixelColor(8, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial1.println("JEM");
+  }
+  else
+  {
+    allSet_module(module_strip.Color(0,0,0),0);
+    module_strip.show();
+  }
+
+
+  if(V2A < 151.5)
+  {
+    strip.setPixelColor(0, strip.Color(255,0,0));
+    strip.setPixelColor(1, strip.Color(255,0,0));
+    strip.setPixelColor(2, strip.Color(255,0,0));
+    strip.setPixelColor(3, strip.Color(255,0,0));
+    strip.setPixelColor(4, strip.Color(255,0,0));
+    strip.setPixelColor(5, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V2A > 160)
+  {
+    strip.setPixelColor(0, strip.Color(255,255,255));
+    strip.setPixelColor(1, strip.Color(255,255,255));
+    strip.setPixelColor(2, strip.Color(255,255,255));
+    strip.setPixelColor(3, strip.Color(255,255,255));
+    strip.setPixelColor(4, strip.Color(255,255,255));
+    strip.setPixelColor(5, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(0, strip.Color(0,0,255));
+    strip.setPixelColor(1, strip.Color(0,0,255));
+    strip.setPixelColor(2, strip.Color(0,0,255));
+    strip.setPixelColor(3, strip.Color(0,0,255));
+    strip.setPixelColor(4, strip.Color(0,0,255));
+    strip.setPixelColor(5, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V4A < 151.5)
+  {
+    strip.setPixelColor(6, strip.Color(255,0,0));
+    strip.setPixelColor(7, strip.Color(255,0,0));
+    strip.setPixelColor(8, strip.Color(255,0,0));
+    strip.setPixelColor(9, strip.Color(255,0,0));
+    strip.setPixelColor(10, strip.Color(255,0,0));
+    strip.setPixelColor(11, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V4A > 160)
+  {
+    strip.setPixelColor(6, strip.Color(255,255,255));
+    strip.setPixelColor(7, strip.Color(255,255,255));
+    strip.setPixelColor(8, strip.Color(255,255,255));
+    strip.setPixelColor(9, strip.Color(255,255,255));
+    strip.setPixelColor(10, strip.Color(255,255,255));
+    strip.setPixelColor(11, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(6, strip.Color(0,0,255));
+    strip.setPixelColor(7, strip.Color(0,0,255));
+    strip.setPixelColor(8, strip.Color(0,0,255));
+    strip.setPixelColor(9, strip.Color(0,0,255));
+    strip.setPixelColor(10, strip.Color(0,0,255));
+    strip.setPixelColor(11, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V4B < 151.5)
+  {
+    strip.setPixelColor(12, strip.Color(255,0,0));
+    strip.setPixelColor(13, strip.Color(255,0,0));
+    strip.setPixelColor(14, strip.Color(255,0,0));
+    strip.setPixelColor(15, strip.Color(255,0,0));
+    strip.setPixelColor(16, strip.Color(255,0,0));
+    strip.setPixelColor(17, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V4B > 160)
+  {
+    strip.setPixelColor(12, strip.Color(255,255,255));
+    strip.setPixelColor(13, strip.Color(255,255,255));
+    strip.setPixelColor(14, strip.Color(255,255,255));
+    strip.setPixelColor(15, strip.Color(255,255,255));
+    strip.setPixelColor(16, strip.Color(255,255,255));
+    strip.setPixelColor(17, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(12, strip.Color(0,0,255));
+    strip.setPixelColor(13, strip.Color(0,0,255));
+    strip.setPixelColor(14, strip.Color(0,0,255));
+    strip.setPixelColor(15, strip.Color(0,0,255));
+    strip.setPixelColor(16, strip.Color(0,0,255));
+    strip.setPixelColor(17, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V2B < 151.5)
+  {
+    strip.setPixelColor(18, strip.Color(255,0,0));
+    strip.setPixelColor(19, strip.Color(255,0,0));
+    strip.setPixelColor(20, strip.Color(255,0,0));
+    strip.setPixelColor(21, strip.Color(255,0,0));
+    strip.setPixelColor(22, strip.Color(255,0,0));
+    strip.setPixelColor(23, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V2B > 160)
+  {
+    strip.setPixelColor(18, strip.Color(255,255,255));
+    strip.setPixelColor(19, strip.Color(255,255,255));
+    strip.setPixelColor(20, strip.Color(255,255,255));
+    strip.setPixelColor(21, strip.Color(255,255,255));
+    strip.setPixelColor(22, strip.Color(255,255,255));
+    strip.setPixelColor(23, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(18, strip.Color(0,0,255));
+    strip.setPixelColor(19, strip.Color(0,0,255));
+    strip.setPixelColor(20, strip.Color(0,0,255));
+    strip.setPixelColor(21, strip.Color(0,0,255));
+    strip.setPixelColor(22, strip.Color(0,0,255));
+    strip.setPixelColor(23, strip.Color(0,0,255));
+    strip.show();
+  }
+}
+void checkSerial()
+{
+  digitalWrite(ledBluePin, HIGH);
+  test = "";
+
+  while(Serial.available())
+  {
+    test = Serial.readString();
+  }
+  Serial1.println(test);
+  char sz[test.length() + 1];
+  char copy[test.length() + 1];
+  strcpy(sz, test.c_str());
+  char *p = sz;
+  char *str;
+  int delimeter = 0;
+  String test2 = "";
+
+  while((str = strtok_r(p," ",&p))!=NULL)
+  {
+    test2 = String(str);
+    delimeter = test2.indexOf('=');
+    if(test2.substring(0,delimeter)=="PSARJ")
+    {
+      PSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="SSARJ")
+    {
+      SSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="PTRRJ")
+    {
+      PTRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="STRRJ")
+    {
+      STRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1B")
+    {
+      Beta1B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1A")
+    {
+      Beta1A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2B")
+    {
+      Beta2B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2A")
+    {
+      Beta2A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3B")
+    {
+      Beta3B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3A")
+    {
+      Beta3A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4B")
+    {
+      Beta4B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4A")
+    {
+      Beta4A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage2A")
+    {
+      V2A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage2B")
+    {
+      V2B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage4A")
+    {
+      V4A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage4B")
+    {
+      V4B = (test2.substring(delimeter+1)).toFloat();
+    }
+    //module Selection
+    else if(test2.substring(0,delimeter)=="Module")
+    {
+      //Serial1.println("----Module!------");
+      module = (test2.substring(delimeter+1));
+    }
+    else if(test2.substring(0,delimeter)=="AOS")
+    {
+      //Serial.println(test2);
+      AOS = (test2.substring(delimeter+1)).toFloat();
+      //Serial.println(AOS);
+      if(AOS == 1.00)
+      {
+        digitalWrite(ledGreenPin, HIGH);
+      }
+      else
+      {
+        digitalWrite(ledRedPin, HIGH);
+      }
+    }
+  }
+  Serial1.println();
+}
+void allSet(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<strip.numPixels(); i++)
+  {
+    strip.setPixelColor(i, c);
+    strip.show();
+    delay(wait);
+  }
+}
+void allSet_module(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<module_strip.numPixels(); i++)
+  {
+    module_strip.setPixelColor(i, c);
+    module_strip.show();
+    delay(wait);
+  }
+}


Updated a mirror bug (stop sending the z location of the device)

--- Positioning/Positioning.ino
+++ Positioning/Positioning.ino
@@ -24,7 +24,7 @@
      case 0x0:
        int32_t* location;
        location =  pozyx.getLocation();
-       Serial.write((uint8_t*)location, 12);
+       Serial.write((uint8_t*)location, 8);
        pozyx.doPositioning();
      break;
      case 0x1:


My prototype.ino

My prototype.ino

--- sketches/prototype/prototype.ino
+++ sketches/prototype/prototype.ino
@@ -23,6 +23,35 @@
     temp = temp.substring(idx+1);
   }
 }
+
+void Version(){
+  Serial.println("version");
+}
+
+void Tone(String data){
+  int idx = data.indexOf('%');
+  int len = Str2int(data.substring(0,idx));
+  String data2 = data.substring(idx+1);
+  int idx2 = data2.indexOf('%');
+  int pin = Str2int(data2.substring(0,idx2));
+  String data3 = data2.substring(idx2+1);
+  String melody[len*2];
+  split(melody,len*2,data3,'%');
+
+  for (int thisNote = 0; thisNote < len; thisNote++) {
+    int noteDuration = 1000/Str2int(melody[thisNote+len]);
+    int note = Str2int(melody[thisNote]);
+    tone(pin, note, noteDuration);
+    int pause = noteDuration * 1.30;
+    delay(pause);
+    noTone(pin);
+  }
+}
+
+void ToneNo(String data){
+  int pin = Str2int(data);
+  noTone(pin);
+}

 void DigitalHandler(int mode, String data){
       int pin = Str2int(data);
@@ -235,7 +264,16 @@
   }
   else if (cmd == "svd") {
       SV_remove(data);
-  }
+  }
+  else if (cmd == "version") {
+      Version();
+  }
+  else if (cmd == "to") {
+      Tone(data);
+  }
+  else if (cmd == "nto") {
+      ToneNo(data);
+  }
 }


doing some major updates to how diversity selection works.

--- src/rx5808-pro-diversity-oled/rx5808-pro-diversity-oled.ino
+++ src/rx5808-pro-diversity-oled/rx5808-pro-diversity-oled.ino
@@ -1232,7 +1232,7 @@
 #ifdef USE_DIVERSITY
     return readRSSI(-1);
 }
-uint16_t readRSSI(uint8_t receiver)
+uint16_t readRSSI(char receiver)
 {
 #endif
     uint16_t rssi = 0;
@@ -1243,16 +1243,57 @@
 #endif
     for (uint8_t i = 0; i < 10; i++)
     {
-        rssiA += analogRead(rssiPinA);
-
-#ifdef USE_DIVERSITY
-        rssiB += analogRead(rssiPinB);
+        rssiA += analogRead(rssiPinA);//random(RSSI_MIN_VAL, RSSI_MAX_VAL);//
+
+#ifdef USE_DIVERSITY
+        rssiB += analogRead(rssiPinB);//random(RSSI_MAX_VAL-100, RSSI_MAX_VAL);//
 #endif
     }
     rssiA = rssiA/10; // average of 10 readings

 #ifdef USE_DIVERSITY
     rssiB = rssiB/10; // average of 10 readings
+#endif
+    // special case for RSSI setup
+    if(state==STATE_RSSI_SETUP)
+    { // RSSI setup
+        if(rssiA < rssi_setup_min_a)
+        {
+            rssi_setup_min_a=rssiA;
+
+            display.setCursor(30,12);
+            display.setTextColor(WHITE,BLACK);
+            display.print( rssi_setup_min_a , DEC);
+        }
+        if(rssiA > rssi_setup_max_a)
+        {
+            rssi_setup_max_a=rssiA;
+
+            display.setCursor(85,12);
+            display.setTextColor(WHITE,BLACK);
+            display.print( rssi_setup_max_a , DEC);
+        }
+
+#ifdef USE_DIVERSITY
+        if(rssiB < rssi_setup_min_b)
+        {
+            rssi_setup_min_b=rssiB;
+        }
+        if(rssiB > rssi_setup_max_b)
+        {
+            rssi_setup_max_b=rssiB;
+        }
+#endif
+    }
+
+
+    rssiA = constrain(rssiA, rssi_min_a, rssi_max_a);    //original 90---250
+    rssiA=rssiA-rssi_min_a; // set zero point (value 0...160)
+    rssiA = map(rssiA, 0, rssi_max_a-rssi_min_a , 1, 100);   // scale from 1..100%
+#ifdef USE_DIVERSITY
+    rssiB = constrain(rssiB, rssi_min_b, rssi_max_b);    //original 90---250
+    rssiB=rssiB-rssi_min_b; // set zero point (value 0...160)
+    rssiB = map(rssiB, 0, rssi_max_a-rssi_min_b , 1, 100);   // scale from 1..100%
     if(receiver == -1) // no receiver was chosen using diversity
     {
         switch(diversity_mode)
@@ -1286,55 +1327,21 @@
             default:
                 receiver=useReceiverA;
         }
+        active_receiver = receiver;
         // set the antenna LED and switch the video
         setReceiver(receiver);
     }
 #endif

-    // special case for RSSI setup
-    if(state==STATE_RSSI_SETUP)
-    { // RSSI setup
-        if(rssiA < rssi_setup_min_a)
-        {
-            rssi_setup_min_a=rssiA;
-
-            display.setCursor(30,12);
-            display.setTextColor(WHITE,BLACK);
-            display.print( rssi_setup_min_a , DEC);
-        }
-        if(rssiA > rssi_setup_max_a)
-        {
-            rssi_setup_max_a=rssiA;
-
-            display.setCursor(85,12);
-            display.setTextColor(WHITE,BLACK);
-            display.print( rssi_setup_max_a , DEC);
-        }
-
-#ifdef USE_DIVERSITY
-        if(rssiB < rssi_setup_min_b)
-        {
-            rssi_setup_min_b=rssiB;
-        }
-        if(rssiB > rssi_setup_max_b)
-        {
-            rssi_setup_max_b=rssiB;
-        }
-#endif
-    }
 #ifdef USE_DIVERSITY
     if(receiver == useReceiverA || state==STATE_RSSI_SETUP)
     {
 #endif
-        rssi = constrain(rssiA, rssi_min_a, rssi_max_a);    //original 90---250
-        rssi=rssi-rssi_min_a; // set zero point (value 0...160)
-        rssi = map(rssi, 0, rssi_max_a-rssi_min_a , 1, 100);   // scale from 1..100%
+        rssi = rssiA;
 #ifdef USE_DIVERSITY
     }
     else {
-        rssi = constrain(rssiB, rssi_min_b, rssi_max_b);    //original 90---250
-        rssi=rssi-rssi_min_b; // set zero point (value 0...160)
-        rssi = map(rssi, 0, rssi_max_a-rssi_min_b , 1, 100);   // scale from 1..100%
+        rssi = rssiB;
     }
 #endif
     return (rssi);


default to change baudrate

default to change baudrate

--- BrewManiac.ino
+++ BrewManiac.ino
@@ -84,7 +84,7 @@
 //debug
 //should be false
 #define SerialDebug false
-#define CHANG_BAUDRATE false
+#define CHANG_BAUDRATE true

 #if UseSoftwareSerial != true
 #define SerialDebug false


Update Receive_test.ino

Update Receive_test.ino

--- FastLED/Receive_test.ino
+++ FastLED/Receive_test.ino
@@ -5,9 +5,13 @@
 int receivedHue = 0;
 int receivedSaturation = 0;
 int receivedValue = 0;
+int baseLightsLit = 0; //This value is the number of light lit in the base

-String receivedID;
 CHSV baseColor;
+
+
+String selfName = "Bonnie"; //The name of this device
+String otherName = "Tim"; //The name of the device you're listening to

 void setup() {
     Particle.subscribe("Beacon Update", ColorUpdate, MY_DEVICES);
@@ -21,7 +25,9 @@

 void ColorUpdate(const char *name, const char *data) {
+    String receivedID;
     if (data) {
+
         char input[64];
         strcpy(input,data);
         char *p;
@@ -36,7 +42,10 @@

     }
     // DEBUG
-    Particle.publish("Color_Recieved", System.deviceID() + "~" + receivedHue + "~" + receivedSaturation + "~" + receivedValue);
+    Particle.publish("Color_Recieved", selfName + "~" + receivedHue + "~" + receivedSaturation + "~" + receivedValue);
     // END DEBUG
-    baseColor = CHSV(receivedHue, receivedSaturation, receivedValue);
+    if(receivedID ==otherName ){
+        baseColor = CHSV(receivedHue, receivedSaturation, receivedValue);
+    }
 }
+


Renamed dave's pattern's variables

Renamed dave's pattern's variables

--- staff/staff.ino
+++ staff/staff.ino
@@ -47,26 +47,26 @@
   }
 }

-uint8_t offset = 0;
-int ms = 0;
+uint8_t daveOffset = 0;
+int daveMilliseconds = 0;

 // Dave's pattern. By Dave Grijalva with love.
 // A gradient background, with rotating bright points and white sparkles.
 void dave() {
   for (int k=0; k<NUM_LEDS-1; k++) {
     uint8_t k8 = k;
-    uint8_t hue = (k/15 * 255) + (offset*5);
-    uint8_t saturation = rand() % 255 > 252 ? 0 : 255; //NUM_LEDS - (k+offset*10);
-    uint8_t value = k8 % 14 == offset % 14 ? 200 : 40; //NUM_LEDS- (k+offset*10);
+    uint8_t hue = (k/15 * 255) + (daveOffset*5);
+    uint8_t saturation = rand() % 255 > 252 ? 0 : 255; //NUM_LEDS - (k+daveOffset*10);
+    uint8_t value = k8 % 14 == daveOffset % 14 ? 200 : 40; //NUM_LEDS- (k+daveOffset*10);
     if(saturation == 0){
       value = 255;
     }
     leds[k] = CHSV(hue, saturation, value);
   }
   EVERY_N_MILLISECONDS(1000/24){
-    ms++;
-    if(ms % 3 == 0){
-      offset++;
+    daveMilliseconds++;
+    if(daveMilliseconds % 3 == 0){
+      daveOffset++;
     }
   }
 }


arduino changes

arduino changes

--- turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
+++ turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
@@ -43,7 +43,7 @@

 #define mouth_open_pos    142
 #define mouth_closed_pos  77
-#define mouth_wait_pos    115
+#define mouth_wait_pos    120

 MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance
 MFRC522::MIFARE_Key key;
@@ -69,8 +69,9 @@
   readloop(100);
   LCDA.initDriverPin(2,3,4);
   LCDA.Initialise(); // INIT SCREEN
-
-  closeMouth();
+  openMouth();
+  delay(500);
+  waitMouth();

   //Serial.println(F("boot completed"));
 }
@@ -78,20 +79,47 @@
 void openMouth(){ //open the mouth
   for(int i = mouthservo.read(); i < mouth_open_pos; i++){
     mouthservo.write(i);
-    delay(15);
+    delay(8);
   }
 }

 void waitMouth(){ //open the mouth
-  mouthservo.write(mouth_wait_pos);
-}
-
-void closeMouth(){ //close the mouth
+
+  for(int i = mouthservo.read(); i < mouth_wait_pos; i++){
+    mouthservo.write(i);
+     delay(15);
+  }
+    for(int i = mouthservo.read(); i > mouth_wait_pos; i--){
+    mouthservo.write(i);
+     delay(15);
+  }
+
+}
+void semiclose(){
+    for(int i = mouthservo.read(); i < mouth_closed_pos+20; i++){
+    mouthservo.write(i);
+     delay(15);
+  }
+    for(int i = mouthservo.read(); i > mouth_closed_pos+20; i--){
+    mouthservo.write(i);
+     delay(15);
+  }
+}
+void fullcloseMouth(){
   delay(750);
   for(int i = mouthservo.read(); i > mouth_closed_pos; i--){
     mouthservo.write(i);
     delay(15);
   }
+
+}
+void closeMouth(){ //close the mouth
+ int repeat= random(1,5);
+for(int i=0;i<repeat;i++){
+    fullcloseMouth();
+    semiclose();
+  }
+  fullcloseMouth();
 }

@@ -118,7 +146,6 @@
 }

 int getAnswer(int firstnumber, int operation , int secondnumber){
-
   switch(operation){
     case 'D':
       answer = firstnumber + secondnumber;
@@ -130,6 +157,7 @@
       answer = firstnumber * secondnumber;
       break;
   }
+  Serial.println();
   return answer;
 }

@@ -144,7 +172,7 @@
     Serial.flush();
   }
   else{
-    erial("w");
+    writeserial("w");
     openMouth();
     delay(2000);
     waitMouth();
@@ -215,12 +243,8 @@
     mfrc522.PCD_StopCrypto1();

 //Best workaround ever
-   if(buffer[0] > 9){
-     input = buffer[0] - 6;
-   }
-   else{
+
      input = buffer[0];
-   }

    checkInput(input, answer);


Using an analog multiplexer to add more sensors!

--- scripts/plants_wireless.ino
+++ scripts/plants_wireless.ino
@@ -16,17 +16,18 @@

 /* Analog */
 const int lightSensorPin = 0;
-const int m1Pin = 1;
-const int m2Pin = 2;
-const int m3Pin = 3;
+const int muxOutPin = 1;

 /* Digital */
 const int tempSensorPin = 2;

-// Setup a oneWire instance to communicate with any OneWire devices
+/* Mux */
+const int muxPins[3] = {4,5,6};
+
+// Setup a oneWire instance to communicate with any OneWire devices
 // (not just Maxim/Dallas temperature ICs)
 OneWire oneWire(tempSensorPin);
-
+
 // Pass our oneWire reference to Dallas Temperature.
 DallasTemperature sensors(&oneWire);

@@ -46,13 +47,31 @@
   pinMode(3,OUTPUT);
   digitalWrite(3,LOW);
   sensors.begin();
-
+
+  // Set up mux
+  for (int i=0; i<3; i++)
+  {
+    pinMode(muxPins[i], OUTPUT);
+    digitalWrite(muxPins[i], LOW);
+  }
+  pinMode(muxOutPin, INPUT);
+
 }

 void sendRadioMessage(String s){
   char msgChar[100];
   s.toCharArray(msgChar,100);
   radio.write(&msgChar,sizeof(msgChar));
+}
+
+void selectMuxPin(byte pin) {
+  if(pin >7){
+    return;
+  }
+
+  digitalWrite(muxPins[0], bitRead(pin,0));
+  digitalWrite(muxPins[1], bitRead(pin,1));
+  digitalWrite(muxPins[2], bitRead(pin,2));
 }

 void loop() {
@@ -62,18 +81,18 @@
   sensors.requestTemperatures();
   temp = sensors.getTempCByIndex(0);

-  m1 = analogRead(m1Pin);
-  m2 = analogRead(m2Pin);
-  m3 = analogRead(m3Pin);
+  String muxMessage = "";
+  for(byte pin=0;pin<8;pin++){
+    selectMuxPin(pin);
+    int pinValue = analogRead(muxOutPin);
+    muxMessage += String(pin+5) + ":" + pinValue + ",";
+  }

   digitalWrite(3,LOW);
   String lightMsg = String(LIGHT_SENSOR_ID) + ":" + lightLevel;
   String tempMsg = String(TEMP_SENSOR_ID) + ":" + temp;
-  String m1Msg = String(MOISTURE_SENSOR_1_ID) + ":" + m1;
-  String m2Msg = String(MOISTURE_SENSOR_2_ID) + ":" + m2;
-  String m3Msg = String(MOISTURE_SENSOR_3_ID) + ":" + m3;
-
-  sendRadioMessage(m1Msg+","+m2Msg+","+m3Msg+","+lightMsg+","+tempMsg);
+
+  sendRadioMessage(muxMessage+lightMsg+","+tempMsg);
   delay(600000);
-
-}
+
+}


fixed bug related to uint8 being too small for activity code elements

--- src/ard/posture/posture.ino
+++ src/ard/posture/posture.ino
@@ -14,7 +14,7 @@
  * one single packet.
  *
  * A sample packet has the form:
- * |3|15|03|00|06|13|14|0a|2e|00|00|01|
+ * |3|015|003|000|006|013|014|00a|02e|000|000|001|
  *
  * size of the array being transmitted depends on the number of regions
  * on the recognition sphere which is calculated based on THETA_REGIONS
@@ -197,7 +197,7 @@
  * @param the array representing posture
  * @param the size of the array
  */
-void reset_posture(uint8_t *posture, uint8_t posture_size)
+void reset_posture(uint16_t *posture, uint8_t posture_size)
 {
 	for (int i = 0; i < posture_size; i++) {
 		posture[i] = 0;
@@ -211,10 +211,13 @@
  * @param num the integer which should be converted to hexa
  * @param ch a pointer to the string being built
  */
-void uint8_to_hexstr(uint8_t num, char *ch)
-{
-	ch[0] = TO_HEX(((num & 0xF0) >> 4));
-	ch[1] = TO_HEX((num & 0x0F));
+void uint16_to_hexstr(uint16_t num, char *ch)
+{
+	// most significant nibble is always 0
+	// ch[0] = TO_HEX(((num & 0xF000) >> 12));
+	ch[0] = TO_HEX(((num & 0x0F00) >> 8));
+	ch[1] = TO_HEX(((num & 0x00F0) >> 4));
+	ch[2] = TO_HEX((num & 0x000F));
 }

 /**
@@ -227,16 +230,16 @@
  * @param posture the array of activity code
  * @param size of the posture array (equal to number of regions in sphere)
  */
-void build_message(char *ch, uint8_t *posture, uint16_t posture_size)
+void build_message(char *ch, uint16_t *posture, uint16_t posture_size)
 {
 	int i;
 	sprintf(ch, "|%d|", MY);
 	while (*ch != '\0')
 		ch++;
 	for (i = 0; i < posture_size; i++) {
-		uint8_to_hexstr(posture[i], ch);
-		ch[2] = '|';
-		ch = ch + 3;
+		uint16_to_hexstr(posture[i], ch);
+		ch[3] = '|';
+		ch = ch + 4;
 	}
 	*ch++ = '\n';
 	*ch = '\0';
@@ -267,7 +270,7 @@
 {
 	unsigned long tic = millis();
 	int16_t raw[ACC_COUNT];
-	uint8_t posture[model.num_region];
+	uint16_t posture[model.num_region];
 	uint8_t region;
 	char message[MSG_LEN];
 	reset_posture(posture, model.num_region);


update

update

--- arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/manager/manager.ino
+++ arduino/opencr_arduino/opencr/libraries/OpenManipulator/example/Arduino/Test/manager/manager.ino
@@ -13,7 +13,6 @@
 #define Y_AXIS makeEigenVector3(0.0, 1.0, 0.0)
 #define Z_AXIS makeEigenVector3(0.0, 0.0, 1.0)

-#define NONE -1
 #define WORLD 0
 #define COMP1 1
 #define COMP2 2
@@ -21,14 +20,17 @@
 #define COMP4 4
 #define TOOL 5

+#define NONE -1
+
 void setup()
 {
   Serial.begin(57600);
-  while (!Serial);
+  while (!Serial)
+    ;

   Manipulator manipulator;
   manipulator.addWorld(WORLD, COMP1);
-  manipulator.addComponent(COMP1, WORLD, COMP2, makeEigenVector3(-0.100, 0.0, 0.0), IDENTITY_MATRIX, 1, Z_AXIS, 0.5, makeEigenMatrix3(1,1,1,1,1,1,3,1,1));
+  manipulator.addComponent(COMP1, WORLD, COMP2, makeEigenVector3(-0.100, 0.0, 0.0), IDENTITY_MATRIX, 1, Z_AXIS, 0.5, makeEigenMatrix3(1, 1, 1, 1, 1, 1, 3, 1, 1));
   manipulator.addComponent(COMP2, COMP1, COMP3, makeEigenVector3(0.0, 0.0, 0.050), IDENTITY_MATRIX, 2, Y_AXIS, 1.5);
   manipulator.addComponentChild(COMP2, COMP4);
   manipulator.addComponent(COMP3, COMP2, COMP4, makeEigenVector3(0.0, 0.050, 0.0), IDENTITY_MATRIX, NONE);


Update dragino_lcd20x4.ino

Update dragino_lcd20x4.ino

--- dragino/dragino_lcd20x4.ino
+++ dragino/dragino_lcd20x4.ino
@@ -4,6 +4,9 @@
 #el display LCD 20*4 Characters - White back utiliza la libreria LiquidCrystal y debe ser conectado al dragino a los
 #pines LCD RS pin to digital pin 10, LCD Enable pin to digital pin 9, LCD D4 pin to digital pin 6,
 #LCD D5 pin to digital pin 4, LCD D6 pin to digital pin 3, LCD D7 pin to digital pin 2
+#la representacion de temperatura y humedad en el display LCD es en 4 filas, las filas que se muestran en este display
+#son los datos que provienen desde el broker en el topico test/temp que en este caso seria el mismo topico donde
+#se publican.

 #include <Process.h>
 #include "MQTTclient.h"
@@ -88,14 +91,14 @@
 if (idsec == ",sensor8")
 {
   lcd.setCursor(0,0);
-String valores =  "S1:" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
+String valores =  "" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
 lcd.print(valores);
 }

 if (idsec == ",sensor7")
 {
   lcd.setCursor(0,1);
-String valores =  "S2:" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
+String valores =  "" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
 lcd.print(valores);
 }

@@ -103,14 +106,14 @@
 if (idsec == ",sensor6")
 {
   lcd.setCursor(0,2);
-String valores =  "S3:" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
+String valores =  "" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
 lcd.print(valores);
 }

 if (idsec == ",sensor5")
 {
   lcd.setCursor(0,3);
-String valores =  "S4:" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
+String valores =  "" + temps1 + "C " + tempa1  + "C " + humi1 + "%";
 lcd.print(valores);
 }


Delete trailing whitespaces

Delete trailing whitespaces

--- rc_steer_servo_controller/rc_steer_servo_controller.ino
+++ rc_steer_servo_controller/rc_steer_servo_controller.ino
@@ -18,7 +18,7 @@
   double cmd = (command.data > 0) ? floor(command.data * 180 / PI) : ceil(command.data * 180 / PI);
   uint16_t angle = clampAngle(cmd) + ANGLE_OFFSET;
   frontSteerServo.write(angle);
-
+
   // publish feedback
   frontSteerServoAngleMsg.data = (static_cast<double>(angle) - ANGLE_OFFSET) / 180 * PI;
   frontSteerServoFeedbackPublisher.publish(&frontSteerServoAngleMsg);
@@ -47,7 +47,7 @@
   int m2 = fabs(motor_battery_voltage * 100) - abs(m1 * 100);
   int p1 = pc_battery_voltage;
   int p2 = fabs(pc_battery_voltage * 100) - abs(p1 * 100);
-
+
   char temp_char_array[50];
   sprintf(temp_char_array, "MOTORS[%02d.%02d]PC[%02d.%02d]",m1, m2, p1, p2);// motor_battery_voltage, pc_battery_voltage);
   batteryVoltagesMsg.data = temp_char_array;
@@ -74,7 +74,7 @@
   nh.advertise(frontSteerServoFeedbackPublisher);
   nh.advertise(rearSteerServoFeedbackPublisher);
   nh.advertise(batteryVoltagesPublisher);
-
+
   frontSteerServo.attach(FRONT_STEER_SERVO_PIN);
   rearSteerServo.attach(REAR_STEER_SERVO_PIN);
 }


updated to original pin (gray count wire is now back to pin 0 from pin 4)

--- MagLabCoinOpAirconditioner/MagLabCoinOpAirconditioner.ino
+++ MagLabCoinOpAirconditioner/MagLabCoinOpAirconditioner.ino
@@ -9,7 +9,7 @@
 #include <LiquidCrystal_I2C.h>

-#define COIN_COUNTER 4 //PIN_INT0
+#define COIN_COUNTER 0 //PIN_INT1

 LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

@@ -39,7 +39,7 @@

   pinMode(COIN_COUNTER, INPUT);
   //attachInterrupt(PIN_INT1, intHandle, CHANGE);
-  attachInterrupt(0, intHandle, FALLING); //interruptNum is num of interrupt, not pin
+  attachInterrupt(1, intHandle, FALLING); //interruptNum is num of interrupt, not pin
 }

 void delay_counter(uint32_t ms)


Fixed indentation

Fixed indentation

    * examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino:

--- examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino
+++ examples/ArduinoUnoNano-downlink/ArduinoUnoNano-downlink.ino
@@ -125,22 +125,22 @@
     switch(myLora.txCnf("!")) //one byte, blocking function
     {
       case TX_FAIL:
-        {
-          Serial.println("TX unsuccessful or not acknowledged");
-        }
+      {
+        Serial.println("TX unsuccessful or not acknowledged");
         break;
+      }
       case TX_SUCCESS:
-        {
-          Serial.println("TX successful and acknowledged");
-        }
+      {
+        Serial.println("TX successful and acknowledged");
         break;
+      }
       case TX_WITH_RX:
-        {
-          String received = myLora.getRx();
-          received = myLora.base16decode(received);
-          Serial.print("Received downlink: " + received);
-        }
+      {
+        String received = myLora.getRx();
+        received = myLora.base16decode(received);
+        Serial.print("Received downlink: " + received);
         break;
+      }
       default:
         Serial.println("Unknown response from TX function");
     }


hash swag 420 sheep it

hash swag 420 sheep it

--- touch/touch.ino
+++ touch/touch.ino
@@ -4,37 +4,27 @@
 #define accel_module (0x53)

 byte values[6];
-char output[512];
 byte base[3];
 byte reading[3];

 void setup() {
   Wire.begin();
-  Serial.begin(9600);
   initAccel();
   cali();
-  sprintf(output, "BASE: %d %d %d\n", base[0], base[1], base[2]);
-  Serial.print(output);
   delay(200);
   pinMode(31, OUTPUT);
   for (int i = 2; i >= 0; i--) {
-    digitalWrite(31, HIGH);
-    delay(100);
-    digitalWrite(31, LOW);
-    delay(100);
+    blinkLed();
   }
 }

 void loop(){
   readAccel();
-  int diff = abs(base[0]-reading[0]) + abs(base[1]-reading[1]) + abs(base[2]-reading[2]);
-  if (diff > 300) {
-    sprintf(output, "%d\n", diff);
-    Serial.print(output);
-    digitalWrite(31, HIGH);
-    delay(100);
-    digitalWrite(31, LOW);
+  int diff = abs(base[2]-reading[2]);
+  if (diff > 5) {
+    blinkLed();
   }
+  delay(25);
 }

 void initAccel() {
@@ -54,42 +44,21 @@
 }

 void cali() {
-  Serial.println("Starting Calibration");
-  byte last[3];
-  int count;
-  last[0] = 0;
-  last[1] = 0;
-  last[2] = 0;
+  unsigned long temp[3] = { 0, 0, 0 };
+  int loops = 1000;
   readAccel();
-
-  while (true) { // Comment your code dylan
-    if (!(reading[0] == 0 || reading[1] == 0 || reading[2] == 0)) { // Comment your code dylan
-      if ((last[0] == reading[0] || last[1] == reading[1] || last[2] == reading[2])) { // Comment your code dylan
-        count++; // Comment your code dylan
-        if (count > 5) { // Comment your code dylan
-          base[0] = last[0]; // Comment your code dylan
-          base[1] = last[1]; // Comment your code dylan
-          base[2] = last[2]; // Comment your code dylan
-          break; // Comment your code dylan
-        } else { // Comment your code dylan
-          readAccel(); // Comment your code dylan
-          delay(200); // Comment your code dylan
-        } // Comment your code dylan
-      } else { // Comment your code dylan
-        last[0] = reading[0]; // Comment your code dylan
-        last[1] = reading[1]; // Comment your code dylan
-        last[2] = reading[2]; // Comment your code dylan
-        count = 0; // Comment your code dylan
-        readAccel(); // Comment your code dylan
-        delay(200); // Comment your code dylan
-      } // Comment your code dylan
-    } else { // Comment your code dylan
-      count = 0; // Comment your code dylan
-      readAccel(); // Comment your code dylan
-      delay(200); // Comment your code dylan
-    } // Comment your code dylan
+  while (!(reading[0] + reading[1] + reading[2])); //wait
+  while (loops) { // read 1000 times and add to temp
+    readAccel();
+    temp[0] = reading[0] + temp[0];
+    temp[1] = reading[1] + temp[1];
+    temp[2] = reading[2] + temp[2];
+    loops--;
   }
-  Serial.println("Done Calibrating");
+  // take an average of the data
+  base[0] = (byte)(temp[0] / 1000);
+  base[1] = (byte)(temp[1] / 1000);
+  base[2] = (byte)(temp[2] / 1000);
 }

 void readAccel() {
@@ -107,6 +76,13 @@
   reading[0] = (((int)values[1]) << 8) | values[0];
   reading[1] = (((int)values[3]) << 8) | values[2];
   reading[2] = (((int)values[5]) << 8) | values[4];
-  sprintf(output, "BASE: %d %d %d\n", reading[0], reading[1], reading[2]);
+}

+void blinkLed() {
+  digitalWrite(31, HIGH);
+  delay(100);
+  digitalWrite(31, LOW);
+  delay(100);
 }
+
+


Increased receiver pitch, roll and yaw sensitivity.

--- drone/drone.ino
+++ drone/drone.ino
@@ -501,19 +501,19 @@
           }
         }

-        motorCommand[0] = recieverThrotttle + pidoutA + pidoutC + (recieverPitch/20.0) + (recieverYaw/10.0);
-        motorCommand[1] = recieverThrotttle + pidoutB - pidoutC + (recieverRoll/20.0)  - (recieverYaw/10.0);
-        motorCommand[2] = recieverThrotttle - pidoutA + pidoutC - (recieverPitch/20.0) + (recieverYaw/10.0);
-        motorCommand[3] = recieverThrotttle - pidoutB - pidoutC - (recieverRoll/20.0)  - (recieverYaw/10.0);
+        motorCommand[0] = recieverThrotttle + pidoutA + pidoutC + (recieverPitch/15.0) + (recieverYaw/10.0);
+        motorCommand[1] = recieverThrotttle + pidoutB - pidoutC + (recieverRoll/15.0)  - (recieverYaw/10.0);
+        motorCommand[2] = recieverThrotttle - pidoutA + pidoutC - (recieverPitch/15.0) + (recieverYaw/10.0);
+        motorCommand[3] = recieverThrotttle - pidoutB - pidoutC - (recieverRoll/15.0)  - (recieverYaw/10.0);
         writeMotors();
       } else {
         digitalWrite(12, LOW);
         clearPID();
         //RAW control.
-        motorCommand[0] = recieverThrotttle + (recieverPitch/20.0) + (recieverYaw/10.0);
-        motorCommand[1] = recieverThrotttle + (recieverRoll/20.0) - (recieverYaw/10.0);
-        motorCommand[2] = recieverThrotttle - (recieverPitch/20.0) + (recieverYaw/10.0);
-        motorCommand[3] = recieverThrotttle - (recieverRoll/20.0) - (recieverYaw/10.0);
+        motorCommand[0] = recieverThrotttle + (recieverPitch/15.0) + (recieverYaw/10.0);
+        motorCommand[1] = recieverThrotttle + (recieverRoll/15.0) - (recieverYaw/10.0);
+        motorCommand[2] = recieverThrotttle - (recieverPitch/15.0) + (recieverYaw/10.0);
+        motorCommand[3] = recieverThrotttle - (recieverRoll/15.0) - (recieverYaw/10.0);
         writeMotors();
     }


Changed Code

Changed Code


Fixed typo

Fixed typo

--- examples/AStarRPiSlave/AStarRPiSlave.ino
+++ examples/AStarRPiSlave/AStarRPiSlave.ino
@@ -134,7 +134,7 @@
   pidLeft.setCmdRange(-motorsMaxCommand, motorsMaxCommand);
   pidRight.setCmdRange(-motorsMaxCommand, motorsMaxCommand);

-  if (btnA.isPresses())
+  if (btnA.isPressed())
   {
     // Center servos
     maestro.setTarget(panServoCh, 6000);


Add serial override mode to example sketch

--- blink_strip/blink_strip.ino
+++ blink_strip/blink_strip.ino
@@ -2,6 +2,8 @@

 void setup()
 {
+  Serial.begin(115200);
+
   DDRB = 0xFF;
   DDRD = 0xFF;
 }
@@ -40,6 +42,15 @@
 uint8_t i = 0;
 void loop()
 {
+  // If'n we get some data, switch to passthrough mode
+  if(Serial.available()) {
+    while(true) {
+      send_single_byte(Serial.read());
+      while(!Serial.available()) {}
+    }
+  }
+
+
   float brightness = random(100,100)/100.0;

   for (uint8_t i = 0; i < LED_COUNT; i++) {


Delete three_moving_pixels_v3.ino

Delete three_moving_pixels_v3.ino

Pretty much a duplicate of three_moving_colors example.  Deleting this one.

--- three_moving_pixels_v3.ino
+++ three_moving_pixels_v3.ino
@@ -1,68 +0,0 @@
-//***************************************************************
-// Three moving pixels example
-//     Uses modulo, %, to make pixel position "loop" around and
-//     stay in valid pixel range.
-//
-// Marc Miller, Feb 2015.  Updated Jan 2016.
-//***************************************************************
-
-
-#include "FastLED.h"
-#define LED_TYPE NEOPIXEL  // Strip type: NEOPIXEL, APA102, LPD8806, etc.
-#define DATA_PIN 6
-//#define CLOCK_PIN 13
-#define NUM_LEDS 12
-//#define COLOR_ORDER BGR
-#define MASTER_BRIGHTNESS 100  // Master brightness (Range is 0-255)
-CRGB leds[NUM_LEDS];
-
-int16_t positionRed = 0;    // Set initial start position of Red pixel
-int16_t positionWhite = 4;  // Set initial start position of White pixel
-int16_t positionBlue = 8;   // Set initial start position of Blue pixel
-int8_t delta = 1;           // Using a negative value will move pixels backwards.
-uint16_t holdTime = 1000;   // Milliseconds to hold position before advancing
-
-
-//---------------------------------------------------------------
-void setup() {
-  Serial.begin(115200);  // Allows serial monitor output (check your baud rate)
-  delay(3000);  // Startup delay
-  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLOCK_PIN>,COLOR_ORDER,(leds, NUM_LEDS);  // ***For strips using Clock.
-  FastLED.addLeds<LED_TYPE,DATA_PIN>(leds, NUM_LEDS);  // ***For Clock-less strips.
-  FastLED.setBrightness(MASTER_BRIGHTNESS);
-}
-
-
-//---------------------------------------------------------------
-void loop() {  // START MAIN LOOP
-
-  EVERY_N_MILLISECONDS(holdTime) {
-
-    // Set pixel color
-    leds[positionRed] = CRGB::Red;
-    leds[positionWhite] = CRGB::White;
-    leds[positionBlue] = CRGB::Blue;
-
-    // Show the pixels
-    FastLED.show();
-
-
-    // Set pixels back to Black for the next loop around.
-    leds[positionRed] = CRGB::Black;
-    leds[positionWhite] = CRGB::Black;
-    leds[positionBlue] = CRGB::Black;
-
-    // Set new position, moving (forward or backward) by delta.
-    // NUM_LEDS is added to the position before doing the modulo
-    // to cover cases where delta is a negative value.
-    positionRed = (positionRed + delta + NUM_LEDS) % NUM_LEDS;
-    positionWhite = (positionWhite + delta + NUM_LEDS) % NUM_LEDS;
-    positionBlue = (positionBlue + delta + NUM_LEDS) % NUM_LEDS;
-
-    // Print out position values to see what's happening.
-    //Serial.print("pos R = "); Serial.print(positionRed);
-    //Serial.print("\t  pos W = "); Serial.print(positionWhite);
-    //Serial.print("\t  pos B = "); Serial.println(positionBlue);
-  }
-
-} // END MAIN LOOP