Added switch_node_v0_1

Added switch_node_v0_1

error: pathspec 'switch_node_v0_1/switch_node_v0_1.ino' did not match any file(s) known to git

--- switch_node_v0_1/switch_node_v0_1.ino
+++ switch_node_v0_1/switch_node_v0_1.ino
@@ -0,0 +1,247 @@
+/* -----------------------------------------------------------------------------
+   Switch Node
+
+   Provides control and monitoring of an electrical switch.
+
+   Circuit:
+   * RFM12B attached to digital pins 10, 11, 12, 13
+   * Battery voltage monitor attached to analog pin 0
+   * Switch connected to digital pin 3
+   * RF Status LED attached to digital pin 9
+
+   Created 28-MAY-2014 by Jon Brule
+----------------------------------------------------------------------------- */
+
+#include <JeeLib.h>
+#include <avr/sleep.h>
+
+#define VERSION "v0.1"
+
+#define SERIAL     1     // set to 1 to also report readings on the serial port
+#define DEBUG      1     // set to 1 to display each loop() run
+#define BAUD_RATE  57600
+
+#define APIN_BATTERY    0     // data connection for battery
+#define DPIN_CTRL_LED   3     // LED simulating the swtch
+#define DPIN_RF_LED     9     // led indicating rf traffic
+#define LED_DELAY       500
+#define VDD_RATIO       1.622
+
+#define MEASURE_PERIOD  100   // how often to measure, in tenths of seconds
+#define RETRY_PERIOD    10    // how soon to retry if ACK didn't come in
+#define RETRY_LIMIT     5     // maximum number of times to retry
+#define ACK_TIME        10    // number of milliseconds to wait for an ack
+#define REPORT_EVERY    2     // report every N measurement cycles
+#define SMOOTH          3     // smoothing factor used for running averages
+
+#define NODEID          3     // node ID used for this unit
+#define NETWORKID       99
+#define FREQUENCY       RF12_915MHZ
+
+#define RAW_LENGTH      16
+#define SWITCH_ZONE     0x02
+#define CMD_TYPE        0x01
+#define DATA_TYPE       0x02
+
+#define CMD_ON          0x01
+#define CMD_OFF         0x02
+
+// set the sync mode to 2 if the fuses are still the Arduino default
+// mode 3 (full powerdown) can only be used with 258 CK startup fuses
+#define RADIO_SYNC_MODE 2
+
+enum { MEASURE, REPORT, TASK_END };
+
+Scheduler scheduler(TASK_END);
+
+static byte reportCount;    // count up until next report, i.e. packet send
+
+// container for command data
+struct CommandData {
+    union {
+        byte raw[RAW_LENGTH];
+        struct {
+            byte type;   // command
+            byte state;  // swtich state: 0 or 1
+        };
+    };
+};
+CommandData cmdData;
+
+// container for sensor data
+struct SensorData {
+    byte zone;
+    byte type;
+    byte network;
+    byte node;
+    union {
+        byte raw[RAW_LENGTH];
+        struct {
+            byte switchState;   // switch state: 0 or 1
+            int battery;        // battery voltage
+        };
+    };
+};
+SensorData sensorData;
+
+// has to be defined because we're using the watchdog for low-power waiting
+ISR(WDT_vect) { Sleepy::watchdogEvent(); }
+
+byte firstTime = true;
+
+//------------------------------------------------------------------------------
+// setup the arduino board
+//
+void setup() {
+
+    #if SERIAL || DEBUG
+        Serial.begin(BAUD_RATE);
+        Serial.print("\n[switchNode - ");
+        Serial.print(VERSION);
+        Serial.println("]");
+        serialFlush();
+    #endif
+
+    setup_sensors();
+
+    pinMode(DPIN_RF_LED, OUTPUT);
+
+    rf12_initialize(NODEID, FREQUENCY, NETWORKID);
+    rf12_sleep(RF12_SLEEP);
+
+    reportCount = REPORT_EVERY;     // report right away for easy debugging
+    scheduler.timer(MEASURE, 0);    // start the measurement loop going
+
+    sensorData.zone = SWITCH_ZONE;
+    sensorData.type = DATA_TYPE;
+    sensorData.network = NETWORKID;
+    sensorData.node = NODEID;
+    for (int i = 0; i< RAW_LENGTH; i++) {
+        sensorData.raw[i] = 0x00;
+    }
+}
+
+
+//------------------------------------------------------------------------------
+// main processing loop
+//
+void loop() {
+
+    switch (scheduler.pollWaiting()) {
+
+        case MEASURE:
+            // reschedule these measurements periodically
+            scheduler.timer(MEASURE, MEASURE_PERIOD);
+
+            doMeasure();
+
+            // every so often, a report needs to be sent out
+            if (++reportCount >= REPORT_EVERY) {
+                reportCount = 0;
+                scheduler.timer(REPORT, 0);
+            }
+            break;
+
+        case REPORT:
+            doReport();
+            break;
+    }
+
+    if (rf12_recvDone() && rf12_crc == 0) {
+        for (byte i = 0; i < rf12_len; ++i) {
+            if (i < RAW_LENGTH) {
+                cmdData.raw[i] = rf12_data[i];
+            }
+        }
+        handleCommand();
+    }
+
+}
+
+//------------------------------------------------------------------------------
+// blinks the rf led pin
+//
+static void blink_rf_led(byte pin, int delay_ms) {
+    digitalWrite(pin, HIGH);
+    delay(delay_ms);
+    digitalWrite(pin, LOW);
+}
+
+//------------------------------------------------------------------------------
+// flushes the serial port
+//
+static void serialFlush () {
+    #if ARDUINO >= 100
+        Serial.flush();
+    #endif
+    delay(2); // make sure tx buf is empty before going back to sleep
+}
+
+//------------------------------------------------------------------------------
+//
+//
+static void handleCommand() {
+    switch (cmdData.type) {
+        case CMD_ON:
+            digitalWrite(DPIN_CTRL_LED, HIGH);
+            break;
+        case CMD_OFF:
+            digitalWrite(DPIN_CTRL_LED, LOW);
+            break;
+    }
+}
+
+//------------------------------------------------------------------------------
+// utility code to perform simple smoothing as a running average
+//
+static int smoothedAverage(int prev, int next, byte firstTime =0) {
+    return (firstTime) ? next : ((SMOOTH - 1) * prev + next + SMOOTH / 2) / SMOOTH;
+}
+
+//------------------------------------------------------------------------------
+// readout all the sensors and other values
+//
+static void doMeasure() {
+
+    // read switch status
+    sensorData.switchState = digitalRead(DPIN_CTRL_LED);
+
+    // read battery voltage
+    int val = analogRead(APIN_BATTERY);
+    int battery = int(val * 0.00488 * VDD_RATIO * 10);
+    sensorData.battery = smoothedAverage(sensorData.battery, battery, firstTime);
+
+    firstTime = false;
+}
+
+//------------------------------------------------------------------------------
+// generate periodic report (i.e. send out a packet and optionally report on
+// serial port)
+//
+static void doReport() {
+
+    rf12_sleep(RF12_WAKEUP);
+    rf12_sendNow(0, &sensorData, sizeof sensorData);
+    rf12_sendWait(RADIO_SYNC_MODE);
+    rf12_sleep(RF12_SLEEP);
+    blink_rf_led(DPIN_RF_LED, LED_DELAY);
+
+    #if SERIAL
+        Serial.print("SWITCH ");
+        Serial.print((int) sensorData.switchState);
+        Serial.print(' ');
+        Serial.print((int) sensorData.battery);
+        Serial.println();
+        serialFlush();
+    #endif
+
+}
+
+//------------------------------------------------------------------------------
+// Initializes the sensors.
+//
+static void setup_sensors() {
+    pinMode(DPIN_CTRL_LED, INPUT);
+    pinMode(DPIN_RF_LED, INPUT);
+}
+


Create Human_tracker_arduino.ino

Create Human_tracker_arduino.ino

error: pathspec 'Human_tracker_arduino.ino' did not match any file(s) known to git

--- Human_tracker_arduino.ino
+++ Human_tracker_arduino.ino
@@ -0,0 +1,118 @@
+//Define pin numbers
+
+//right motor
+int m1f = 10;
+int m1r = 9;
+//left motor
+int m2f = 6;
+int m2r = 5;
+int led = 13;
+char value;
+int val[3];
+int len;
+int direc;
+
+
+void setup()
+{
+  //start serial communication at Baud rate of 9600
+  Serial.begin(9600);
+  pinMode(m1f, OUTPUT);
+  pinMode(m1r, OUTPUT);
+  pinMode(m2f, OUTPUT);
+  pinMode(m2r, OUTPUT);
+  pinMode(led, OUTPUT);
+  digitalWrite(led, HIGH);
+}
+
+void execute()
+{
+  int no;
+  int i = 0;
+
+  //convert ASCII value from serial buffer into int
+  no = value - '0';
+  //Serial.println(no);
+
+  int a, b, c, d;
+
+  /*
+    """
+    Direction control Index:
+
+    '<' , '>' are the frame check bits for serial communication
+
+    Numbers represent the direction to be moved as per their     	position on numpad
+    1: Back Left
+    2: Back
+    3: Back right
+    4: Left
+    5: Stay still
+    6: Right
+    7: Front Left
+    8: Forward
+    9: Forward right
+    """
+  */
+
+  switch (no)
+  {
+    case 0:
+      a = 0; b = 100; c = 100; d = 0;
+      break;
+    case 3:
+      a = 0; b = 255; c = 0; d = 100;
+      break;
+    case 2:
+      a = 0; b = 255; c = 0; d = 255;
+      break;
+    case 1:
+      a = 0; b = 100; c = 0; d = 255;
+      break;
+    case 4:
+      a = 255; b = 0; c = 0; d = 0;
+      break;
+    case 5:
+      a = 0; b = 0; c = 0; d = 0;
+      break;
+    case 6:
+      a = 0; b = 0; c = 255; d = 0;
+      break;
+    case 7:
+      a = 255; b = 0; c = 100; d = 0;
+      break;
+    case 8:
+      a = 150; b = 0; c = 150; d = 0;
+      break;
+    case 9:
+      a = 100; b = 0; c = 255; d = 0;
+      break;
+  }
+
+  analogWrite(m1f, a);
+  analogWrite(m1r, b);
+  analogWrite(m2f, c);
+  analogWrite(m2r, d);
+  //delay(255);
+}
+
+void loop()
+{
+  if (Serial.available())
+  {
+    //Check for frame control bits
+    char ch = Serial.read();
+    if (ch == '<')
+    {
+      len = 0;
+    }
+    else if (ch == '>')
+    {
+      execute();
+      //Serial.println(value);
+      len = 1;
+    }
+    else if (len == 0)
+      value = ch;
+  }
+}


Add files via upload

Add files via upload

Initial commit

error: pathspec 'SetRTC.ino' did not match any file(s) known to git

--- SetRTC.ino
+++ SetRTC.ino
@@ -0,0 +1,232 @@
+#include "Arduino.h"
+#include "Wire.h"
+
+#define DS3231_I2C_ADDRESS 104
+
+// Acknowledgement: The code for reading and writing the DS3231 RTC is copied from http://www.goodliffe.org.uk/arduino/i2c_devices.php
+
+// SCL - pin A5
+// SDA - pin A4
+// To set the clock, run the sketch and use the serial monitor.
+// Enter T1124154091014; the code will read this and set the clock. See the code for full details.
+//
+byte second, minute, hour, dayOfWeek, day, month, year;
+boolean daylightSavingTime;
+char weekDay[4];
+
+byte tMSB, tLSB;
+float temp3231;
+
+void setup() {
+	Wire.begin();
+	Serial.begin(9600);
+}
+
+void printDigits(byte val, String separator) {
+	if (val < 10) {
+		Serial.print("0");
+	}
+	Serial.print(val);
+	Serial.print(separator);
+}
+
+void loop() {
+
+	watchConsole();
+
+	get3231Date();
+
+	Serial.print(weekDay);
+	Serial.print(", ");
+	printDigits(day, "/");
+	printDigits(month, "-");
+	printDigits(year, " - ");
+	printDigits(hour, ":");
+	printDigits(minute, ":");
+	printDigits(second, " - Temp: ");
+	Serial.print(get3231Temp());
+	if (daylightSavingTime) {
+		Serial.print(" ST");
+	}
+	Serial.println();
+
+	delay(1000);
+}
+
+// Convert normal decimal numbers to binary coded decimal
+byte decToBcd(byte val) {
+	return ((val / 10 * 16) + (val % 10));
+}
+
+void watchConsole() {
+	if (Serial.available()) { // Look for char in serial queue and process if found
+		if (Serial.read() == 84) {      //If command = "T" Set Date
+			set3231Date();
+			get3231Date();
+			Serial.println(" ");
+		}
+	}
+}
+
+void set3231Date() {
+//T(sec)(min)(hour)(dayOfWeek)(dayOfMonth)(month)(year)
+//T(00-59)(00-59)(00-23)(1-7)(01-31)(01-12)(00-99)
+//Example: 02-Feb-09 @ 19:57:11 for the 3rd day of the week -> T1157193020209
+//Sample dates for testing:
+// T0000005250316
+// T3059017270316 - 30 seconds before start of DST
+// T3059017301016 - 30 seconds before end of DST
+// T3059225010716 - 30 seconds before new day with DST
+// T3059224300616 - 30 seconds before new day on the last day of a month with DST
+// T3059234300616 - 30 seconds before new day on the last day of a month with DST, real time on timer chip
+// T1124154091014
+	second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48)); // Use of (byte) type casting and ascii math to achieve result.
+	minute = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
+	hour = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
+	dayOfWeek = (byte) (Serial.read() - 48);
+	day = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
+	month = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
+	year = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48));
+	Wire.beginTransmission(DS3231_I2C_ADDRESS);
+	Wire.write(0x00);
+	Wire.write(decToBcd(second));
+	Wire.write(decToBcd(minute));
+	Wire.write(decToBcd(hour));
+	Wire.write(decToBcd(dayOfWeek));
+	Wire.write(decToBcd(day));
+	Wire.write(decToBcd(month));
+	Wire.write(decToBcd(year));
+	Wire.endTransmission();
+}
+
+byte dateSunday() {
+	byte sunday = day - dayOfWeek;
+	if (sunday < 25) {
+		sunday += 7;
+	}
+	return sunday;
+}
+
+boolean isDST() {
+	switch (month) {
+	case 1:
+	case 2:
+		return false;
+	case 3:
+		if (day < 25) {
+			return false;
+		}
+		if (dayOfWeek == 7) {
+			return (hour < 2) ? false : true;
+		}
+		return (day < dateSunday()) ? false : true;
+	case 10:
+		if (day < 25) {
+			return true;
+		}
+		if (dayOfWeek == 7) {
+			return (hour >= 2) ? false : true;
+		}
+		return (day > dateSunday()) ? false : true;
+	case 11:
+	case 12:
+		return false;
+	default: return true;	// For dst, no test for the summer months in the switch.
+	}
+}
+
+byte daysInMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};	// Only months with DST will be used in this array - no need to test for leap year.
+
+void adjustTime() {		// Adjust for daylight saving time (clock is always winter time)
+	if (daylightSavingTime) {
+		hour += 1;
+		if (hour > 23) {
+			hour = 0;
+			dayOfWeek++;
+			if (dayOfWeek > 7) {
+				dayOfWeek = 1;
+			}
+			day++;
+			if (day > daysInMonth[month]) {
+				day = 1;
+				month++;
+			}
+		}
+	}
+}
+
+void get3231Date() {
+	// send request to receive data starting at register 0
+	Wire.beginTransmission(DS3231_I2C_ADDRESS); // 104 is DS3231 device address
+	Wire.write(0x00); // start at register 0
+	Wire.endTransmission();
+	Wire.requestFrom(DS3231_I2C_ADDRESS, 7); // request seven bytes
+
+	if (Wire.available()) {
+		second = Wire.read(); // get second
+		minute = Wire.read(); // get minutes
+		hour = Wire.read();   // get hour
+		dayOfWeek = Wire.read();
+		day = Wire.read();
+		month = Wire.read(); //temp month
+		year = Wire.read();
+
+		second = (((second & B11110000) >> 4) * 10 + (second & B00001111)); // convert BCD to decimal
+		minute = (((minute & B11110000) >> 4) * 10 + (minute & B00001111)); // convert BCD to decimal
+		hour = (((hour & B00110000) >> 4) * 10 + (hour & B00001111)); // convert BCD to decimal (assume 24 hour mode)
+		dayOfWeek = (dayOfWeek & B00000111); // 1-7
+		day = (((day & B00110000) >> 4) * 10 + (day & B00001111)); // 1-31
+		month = (((month & B00010000) >> 4) * 10 + (month & B00001111)); //msb7 is century overflow
+		year = (((year & B11110000) >> 4) * 10 + (year & B00001111));
+	} else {
+		//oh noes, no data!
+	}
+
+	daylightSavingTime = isDST();
+	adjustTime();
+
+	switch (dayOfWeek) {
+	case 1:
+		strcpy(weekDay, "Mon");
+		break;
+	case 2:
+		strcpy(weekDay, "Tue");
+		break;
+	case 3:
+		strcpy(weekDay, "Wed");
+		break;
+	case 4:
+		strcpy(weekDay, "Thu");
+		break;
+	case 5:
+		strcpy(weekDay, "Fri");
+		break;
+	case 6:
+		strcpy(weekDay, "Sat");
+		break;
+	case 7:
+		strcpy(weekDay, "Sun");
+		break;
+	}
+}
+
+float get3231Temp() {
+	//temp registers (11h-12h) get updated automatically every 64s
+	Wire.beginTransmission(DS3231_I2C_ADDRESS);
+	Wire.write(0x11);
+	Wire.endTransmission();
+	Wire.requestFrom(DS3231_I2C_ADDRESS, 2);
+
+	if (Wire.available()) {
+		tMSB = Wire.read(); //2's complement int portion
+		tLSB = Wire.read(); //fraction portion
+
+		temp3231 = (tMSB & B01111111); //do 2's math on Tmsb
+		temp3231 += ((tLSB >> 6) * 0.25); //only care about bits 7 & 8
+	} else {
+		//oh noes, no data!
+	}
+
+	return temp3231;
+}
+


Fixed the firmware file

Fixed the firmware file

error: pathspec 'Rev' did not match any file(s) known to git
error: pathspec 'B/electronic_load.ino' did not match any file(s) known to git


Delete ESPArto_pinDefDebounced.ino

Delete ESPArto_pinDefDebounced.ino

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/philbowles/esparto.git/'


3254 Digital motion sensor sketch polls for data less often to prevent flooding the server.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/myDevicesIoT/Cayenne-Arduino-Library.git/'


Add getting_started example

Add getting_started example

error: pathspec 'examples/getting_started/getting_started.ino' did not match any file(s) known to git

--- examples/getting_started/getting_started.ino
+++ examples/getting_started/getting_started.ino
@@ -0,0 +1,50 @@
+/*
+  Demonstrates how to set and get time from the RTC.
+
+  The type tmElements_t and functions like breakTime() are from
+  the Time library.
+*/
+
+#include <PCF2123.h>
+
+PCF2123 rtc(9); /* Chip enable on pin 9 */
+
+void setup() {
+  tmElements_t tm;
+  Serial.begin(57600);
+
+  Serial.println("Resetting RTC");
+  rtc.reset();
+
+  Serial.println("Setting time to Tue, 08 Nov 2016 23:49:50");
+
+  /* Convert Unix timestamp to tmElements_t */
+  breakTime(1478648990, tm);
+  rtc.time_set(&tm);
+}
+
+/* Print human readable time */
+void print_time(tmElements_t t) {
+  Serial.print(String("Year ") + (1970 + t.Year));
+  Serial.print(String(" Month ") + t.Month);
+  Serial.print(String(" Day ") + t.Day);
+  Serial.print(String(" Wday ") + t.Wday);
+  Serial.print(String(" Hour ") + t.Hour);
+  Serial.print(String(" Minute ") + t.Minute);
+  Serial.print(String(" Second ") + t.Second);
+  Serial.print("\n");
+}
+
+void loop() {
+  tmElements_t t;
+
+  /* Get and print current time */
+  rtc.time_get(&t);
+  print_time(t);
+
+  /* Print Unix timestamp */
+  Serial.print("Unix time: ");
+  Serial.println(makeTime(t));
+
+  delay(1000);
+}


Create ReadAndWrite.ino

Create ReadAndWrite.ino

is small sketch for read write .
comments in Italian and English .
enjoy empty_skull ( Nicola Coppola )

error: pathspec 'examples/MifareClassicValueBlock/ReadAndWrite.ino' did not match any file(s) known to git

--- examples/MifareClassicValueBlock/ReadAndWrite.ino
+++ examples/MifareClassicValueBlock/ReadAndWrite.ino
@@ -0,0 +1,240 @@
+/*
+ * MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT.
+ * The library file MFRC522.h has a wealth of useful info. Please read it.
+ * The functions are documented in MFRC522.cpp.
+ *
+ * Based on code Dr.Leong   ( WWW.B2CQSHOP.COM )
+ * Created by Miguel Balboa (circuitito.com), Jan, 2012.
+ * Rewritten by Søren Thing Andersen (access.thing.dk), fall of 2013 (Translation to English, refactored, comments, anti collision, cascade levels.)
+ *
+ * Released into the public domain.
+ *
+ * This sample shows how to setup a block on a MIFARE Classic PICC to be in "Value Block" mode.
+ * In Value Block mode the operations Increment/Decrement/Restore and Transfer can be used.
+ *
+ ----------------------------------------------------------------------------- empty_skull
+
+ - Aggiunti pin per arduino Mega
+ - Scritto semplice codice per la scrittura e lettura
+
+ - add pin configuration for arduino mega
+ - write simple read/write Code for new entry user
+
+ http://mac86project.altervista.org/
+
+ ----------------------------------------------------------------------------- Nicola Coppola
+ * Pin layout should be as follows:
+ * Signal     Pin              Pin               Pin
+ *            Arduino Uno      Arduino Mega      MFRC522 board
+ * ------------------------------------------------------------
+ * Reset      9                5                 RST
+ * SPI SS     10               53                SDA
+ * SPI MOSI   11               52                MOSI
+ * SPI MISO   12               51                MISO
+ * SPI SCK    13               50                SCK
+ *
+ * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on ebay.com.
+ */
+
+#include <SPI.h>
+#include <MFRC522.h>
+
+#define SS_PIN 53
+#define RST_PIN 5
+MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.
+
+void setup() {
+        Serial.begin(9600);        // Initialize serial communications with the PC
+        SPI.begin();                // Init SPI bus
+        mfrc522.PCD_Init();        // Init MFRC522 card
+        //Serial.println("Scan a MIFARE Classic PICC to demonstrate Value Blocks.");
+}
+
+void loop() {
+
+        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
+        MFRC522::MIFARE_Key key;
+        for (byte i = 0; i < 6; i++) {
+                key.keyByte[i] = 0xFF;
+        }
+        // Look for new cards
+        if ( ! mfrc522.PICC_IsNewCardPresent()) {
+                return;
+        }
+
+        // Select one of the cards
+        if ( ! mfrc522.PICC_ReadCardSerial()) {
+                return;
+        }
+        // Now a card is selected. The UID and SAK is in mfrc522.uid.
+
+        // Dump UID
+        Serial.print("Card UID:");
+        for (byte i = 0; i < mfrc522.uid.size; i++) {
+                Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
+                Serial.print(mfrc522.uid.uidByte[i], HEX);
+        }
+        Serial.println();
+
+        // Dump PICC type
+        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
+        Serial.print("PICC type: ");
+        Serial.println(mfrc522.PICC_GetTypeName(piccType));
+        if (        piccType != MFRC522::PICC_TYPE_MIFARE_MINI
+                &&        piccType != MFRC522::PICC_TYPE_MIFARE_1K
+                &&        piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
+                //Serial.println("This sample only works with MIFARE Classic cards.");
+                return;
+        }
+
+        // In this sample we use the second sector (ie block 4-7). the first sector is = 0
+        // scegliere settore di lettura da 0 = primo settore
+        byte sector         = 1;
+        // block sector 0-3(sector0) 4-7(sector1) 8-11(sector2)
+        // blocchi di scrittura da 0-3(sector0) 4-7(sector1) 8-11(sector2)
+        byte valueBlockA    = 4;
+        byte valueBlockB    = 5;
+        byte valueBlockC    = 6;
+        byte trailerBlock   = 7;
+        byte status;
+        // Authenticate using key A.
+        // avvio l'autentificazione A
+        //Serial.println("Authenticating using key A...");
+        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
+        if (status != MFRC522::STATUS_OK) {
+                Serial.print("PCD_Authenticate() failed: ");
+                Serial.println(mfrc522.GetStatusCodeName(status));
+                return;
+        }
+        // Authenticate using key B.
+        // avvio l'autentificazione B
+        //Serial.println("Authenticating again using key B...");
+        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid));
+        if (status != MFRC522::STATUS_OK) {
+                Serial.print("PCD_Authenticate() failed: ");
+                Serial.println(mfrc522.GetStatusCodeName(status));
+                return;
+        }
+
+        // Writing new value block A
+        // Scrivo i valori per il settore A
+        Serial.println("Writing new value block A(4) : the first of the sector TWO ");
+                byte value1Block[] = { 1,2,3,4,  5,6,7,8, 9,10,255,12,  13,14,15,16,   valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
+                status = mfrc522.MIFARE_Write(valueBlockA, value1Block, 16);
+                if (status != MFRC522::STATUS_OK) {
+                        Serial.print("MIFARE_Write() failed: ");
+                        Serial.println(mfrc522.GetStatusCodeName(status));
+                }
+        /*
+
+        // Writing new value block B
+        // Scrivo i valori per il settore B
+        Serial.println("Writing new value block B");
+                byte value2Block[] = { 255,255,255,255,  0,0,0,0, 0,0,0,0,  255,255,255,255,   valueBlockB,~valueBlockB,valueBlockB,~valueBlockB };
+                status = mfrc522.MIFARE_Write(valueBlockB, value2Block, 16);
+                if (status != MFRC522::STATUS_OK) {
+                        Serial.print("MIFARE_Write() failed: ");
+                        Serial.println(mfrc522.GetStatusCodeName(status));
+                }
+
+        // Writing new value block D
+        // Scrivo i valori per il settore C
+        Serial.println("Writing new value block C");
+                byte value3Block[] = { 255,255,255,255,  0,0,0,0, 0,0,0,0,  255,255,255,255,   valueBlockC,~valueBlockC,valueBlockC,~valueBlockC };
+                status = mfrc522.MIFARE_Write(valueBlockC, value3Block, 16);
+                if (status != MFRC522::STATUS_OK) {
+                        Serial.print("MIFARE_Write() failed: ");
+                        Serial.println(mfrc522.GetStatusCodeName(status));
+                }
+
+        */
+
+
+        Serial.println("Read block A(4) : the first of the sector TWO");
+        byte buffer[18];
+        byte size = sizeof(buffer);
+        // change this: valueBlockA , for read anather block
+        // cambiate valueBlockA per leggere un altro blocco
+        status = mfrc522.MIFARE_Read(valueBlockA, buffer, &size);
+        Serial.print("Settore : 0 Valore :");
+        Serial.println(buffer[0]);
+        Serial.print("Settore : 1 Valore :");
+        Serial.println(buffer[1]);
+        Serial.print("Settore : 2 Valore :");
+        Serial.println(buffer[2]);
+        Serial.print("Settore : 3 Valore :");
+        Serial.println(buffer[3]);
+        Serial.print("Settore : 4 Valore :");
+        Serial.println(buffer[4]);
+        Serial.print("Settore : 5 Valore :");
+        Serial.println(buffer[5]);
+        Serial.print("Settore : 6 Valore :");
+        Serial.println(buffer[6]);
+        Serial.print("Settore : 7 Valore :");
+        Serial.println(buffer[7]);
+        Serial.print("Settore : 8 Valore :");
+        Serial.println(buffer[8]);
+        Serial.print("Settore : 9 Valore :");
+        Serial.println(buffer[9]);
+        Serial.print("Settore :10 Valore :");
+        Serial.println(buffer[10]);
+        Serial.print("Settore :11 Valore :");
+        Serial.println(buffer[11]);
+        Serial.print("Settore :12 Valore :");
+        Serial.println(buffer[12]);
+        Serial.print("Settore :13 Valore :");
+        Serial.println(buffer[13]);
+        Serial.print("Settore :14 Valore :");
+        Serial.println(buffer[14]);
+        Serial.print("Settore :15 Valore :");
+        Serial.println(buffer[15]);
+
+
+
+        //byte value1Block[] = { 1,2,3,4,  5,6,7,8, 9,10,255,12,  13,14,15,16,   valueBlockA,~valueBlockA,valueBlockA,~valueBlockA };
+        if (
+        buffer[0]  == 1   &&
+        buffer[1]  == 2   &&
+        buffer[2]  == 3   &&
+        buffer[3]  == 4   &&
+        buffer[4]  == 5   &&
+        buffer[5]  == 6   &&
+        buffer[6]  == 7   &&
+        buffer[7]  == 8   &&
+        buffer[8]  == 9   &&
+        buffer[9]  == 10  &&
+        buffer[10] == 255 &&
+        buffer[11] == 12  &&
+        buffer[12] == 13  &&
+        buffer[13] == 14  &&
+        buffer[14] == 15  &&
+        buffer[15] == 16
+        ){
+
+        // sel a scrittura è uguale alla lettura allora e stato un successo !!
+        Serial.println("Read block A(4) : the first of the sector TWO : success");
+        Serial.println(":-)");
+
+        }else{
+
+         //  scrittura Fallita
+        Serial.println("Read block A(4) : the first of the sector TWO : no match - write don't work fine ");
+        Serial.println(":-( ");
+
+        }
+
+
+        // risponde successo
+        //Serial.println(mfrc522.GetStatusCodeName(status));
+
+        // Dump the result
+        //mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector);
+
+        // Halt PICC
+        mfrc522.PICC_HaltA();
+
+        // Stop encryption on PCD
+        mfrc522.PCD_StopCrypto1();
+
+
+}


imital computer switch

imital computer switch

error: pathspec 'Computer_Switch/Computer_Switch.ino' did not match any file(s) known to git

--- Computer_Switch/Computer_Switch.ino
+++ Computer_Switch/Computer_Switch.ino
@@ -0,0 +1,127 @@
+//----------------------------------------------------------------------------------------------------------------
+// Computer_Switch.ino
+//
+// This sketch is designed to run on a WeMos D1 mini.  Other controllers may require extensive tweaking.
+//
+// This runs a small webserver hosting a tiny API to remotely power on or off a computer
+// Also supports a rely to electrically isolate the server.
+//
+// Author - Joshua Villwock
+// Created - 2019-05-28
+// License - Mozilla Public License 2.0 (Do what you want, credit the author, must release under same license)
+//----------------------------------------------------------------------------------------------------------------
+
+// Import required libraries
+#include <ESP8266WiFi.h>
+#include <aREST.h>
+extern "C" {
+  #include "user_interface.h"
+}
+
+// Create aREST instance
+aREST rest = aREST();
+
+// WiFi parameters
+const char* ssid = "joshua";
+const char* password = "";
+
+// The port to listen for incoming TCP connections
+#define LISTEN_PORT           80
+
+// Create an instance of the server
+WiFiServer server(LISTEN_PORT);
+
+// Variables to be exposed to the API
+int relayOn;
+
+// Declare functions to be exposed to the API
+int powerOn(String command);
+int flashLed(String command);
+int hardReset(String command);
+
+void setup(void)
+{
+  // Start Serial
+  Serial.begin(115200);
+  WiFi.mode(WIFI_STA);
+  WiFi.hostname("ESP_EIDOLON_IPMI");
+  wifi_station_set_hostname("ESP_EIDOLON_IPMI");
+  delay(100);
+
+  // Init variables and expose them to REST API
+  relayOn = 0;
+  rest.variable("relayOn",&relayOn);
+
+  // Function to be exposed
+  rest.function("power",powerOn);
+  rest.function("led",flashLed);
+  rest.function("reset",hardReset);
+
+  // Give name & ID to the device (ID should be 6 characters long)
+  rest.set_id("1");
+  rest.set_name("ESP_EIDOLON_IPMI");
+
+  // Connect to WiFi
+  WiFi.begin(ssid, password);
+  while (WiFi.status() != WL_CONNECTED) {
+    delay(500);
+    Serial.print(".");
+  }
+  Serial.println("");
+  Serial.println("WiFi connected");
+
+  // Start the server
+  server.begin();
+  Serial.println("Server started");
+
+  // Print the IP address
+  Serial.println(WiFi.localIP());
+
+  pinMode(LED_BUILTIN, OUTPUT);
+  pinMode(D4, INPUT);
+}
+
+void loop() {
+  // Handle REST calls
+  WiFiClient client = server.available();
+  if (!client) {
+    return;
+  }
+  while(!client.available()){
+    delay(1);
+  }
+  rest.handle(client);
+}
+
+// Custom function accessible by the API
+int flashLed(String command) {
+  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
+  delay(1000);                       // wait for a second
+  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
+  delay(1000);                       // wait for a second
+  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
+  delay(1000);                       // wait for a second
+  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
+  delay(1000);                       // wait for a second
+  return 1;
+}
+
+// Custom function accessible by the API
+int powerOn(String command) {
+  pinMode(D4, OUTPUT);
+  digitalWrite(D4,LOW);
+  delay(1500);
+  digitalWrite(D4,HIGH);
+  pinMode(D4, INPUT);
+  return 1;
+}
+
+// Custom function accessible by the API
+int hardReset(String command) {
+  pinMode(D4, OUTPUT);
+  digitalWrite(D4,LOW);
+  delay(6000);
+  digitalWrite(D4,HIGH);
+  pinMode(D4, INPUT);
+  return 1;
+}


Added comments

Added comments

There is a discrepancy between the wiring as shown in the schematic vs the ones in the demonstration. I hope these comments will reduce any confusion.

Thank you to Steve Miller for spotting the descrepancy.

error: pathspec 'Shift' did not match any file(s) known to git
error: pathspec 'Registers/shiftRegisters_Demo2/shiftRegisters_Demo2.ino' did not match any file(s) known to git


Initial Upload

Initial Upload

Initial Upload

error: pathspec 'rusk-r002.ino' did not match any file(s) known to git

--- rusk-r002.ino
+++ rusk-r002.ino
@@ -0,0 +1,421 @@
+// This #include statement was automatically added by the Spark IDE.
+#include "FOXFIRE_EmonLib/FOXFIRE_EmonLib.h"
+
+// This #include statement was automatically added by the Spark IDE.
+#include "FOXFIRE_BMP085/FOXFIRE_BMP085.h"
+
+// This #include statement was automatically added by the Spark IDE.
+#include "FOXFIRE_Si70xx/FOXFIRE_Si70xx.h"
+
+// This #include statement was automatically added by the Spark IDE.
+#include "FOXFIRE_Si1132/FOXFIRE_Si1132.h"
+
+// This #include statement was automatically added by the Spark IDE.
+#include "FOXFIRE_MPU6050/FOXFIRE_MPU6050.h"
+
+//********************************************************************************
+//********************************************************************************
+//********************************************************************************
+
+// Initialize application variables
+int SENSORDELAY = 5000; // milliseconds (runs x1)
+int EVENTSDELAY = 1000; // milliseconds (runs x10)
+int SLEEP_DELAY = 45; // seconds (runs x1) - should get about 24 hours on 2100mAH - 0 to disable
+String SLEEP_DELAY_MIN = "15"; // seconds - easier to store as string then convert to int
+String SLEEP_DELAY_STATUS = "OK"; // always OK to start with
+
+int I2CEN = D2;
+int ALGEN = D3;
+int LED = D7;
+
+int SOUND = A1;
+int SOUNDV = 0; //Raw Peak-to-Peak Level/Amplitude
+
+int POWR1 = A2;
+int POWR2 = A3;
+int POWR3 = A4;
+double POWR1V = 0; //Watts
+double POWR2V = 0; //Watts
+double POWR3V = 0; //Watts
+
+int SOILT = A6;
+int SOILTV = 0; //Raw 0-4095
+
+int SOILH = A7;
+int SOILHV = 0; //Raw 0-4095
+
+bool BMP180OK = false;
+float BMP180Pressure = 0; //hPa
+float BMP180Temperature = 0; //Celsius
+float BMP180Altitude = 0; //Meters
+
+bool Si7020OK = false;
+float Si7020Temperature = 0; //Celsius
+float Si7020Humidity = 0; //%Relative Humidity
+
+bool Si1132OK = false;
+float Si1132UVIndex = 0; //UV Index scoring is as follows: 1-2  -> Low, 3-5  -> Moderate, 6-7  -> High, 8-10 -> Very High, 11+  -> Extreme
+float Si1132Visible = 0; //Lux
+float Si1132InfraRd = 0; //Lux
+
+bool ACCELOK = false;
+int16_t ax, ay, az;
+int16_t gx, gy, gz;
+
+//********************************************************************************
+//********************************************************************************
+//********************************************************************************
+
+// Initialize cloud API float-to-string-hack
+// https://community.spark.io/t/get-reads-all-return-same-variable-value/1290/7
+// These values are mapped and updated in the postSensingVariableMap() function
+char Sound[63] = "0";
+char Power[63] = "0.00 0.00 0.00";
+char SoilTnH[63] = "0 0";
+char PreTAlt[63] = "0.00 0.00 0.00";
+char AmbiTnH[63] = "0.00 0.00";
+char UVVisIR[63] = "0.00 0.00 0.00";
+char AcclXYZ[63] = "0 0 0";
+char GyroXYZ[63] = "0 0 0";
+
+//********************************************************************************
+//********************************************************************************
+//********************************************************************************
+
+// Power
+EnergyMonitor emon1;
+EnergyMonitor emon2;
+EnergyMonitor emon3;
+
+// Weather
+Adafruit_BMP085_Unified bmp180 = Adafruit_BMP085_Unified(10085);
+FOXFIRE_Si70xx si7020;
+FOXFIRE_Si1132 si1132;
+
+// MPU6050
+// class default I2C address is 0x68
+// specific I2C addresses may be passed as a parameter here
+// AD0 low = 0x68 (default for InvenSense evaluation board)
+// AD0 high = 0x69
+MPU6050 mpu6050(0x68);
+
+//********************************************************************************
+//********************************************************************************
+//********************************************************************************
+
+/*
+float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
+{
+  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+}
+*/
+
+void setPinsMode() {
+    pinMode(I2CEN, OUTPUT);
+    pinMode(ALGEN, OUTPUT);
+    pinMode(LED, OUTPUT);
+
+    pinMode(POWR1, INPUT);
+    pinMode(POWR2, INPUT);
+    pinMode(POWR3, INPUT);
+
+    pinMode(SOILT, INPUT);
+    pinMode(SOILH, INPUT);
+}
+
+int setSleepDelay(String SLEEP_DELAY_STR) {
+    if (SLEEP_DELAY_STR.toInt() > SLEEP_DELAY_MIN.toInt())
+    {
+        SLEEP_DELAY = SLEEP_DELAY_STR.toInt();
+        SLEEP_DELAY_STATUS = "OK";
+        return SLEEP_DELAY;
+    }
+    else
+    {
+        SLEEP_DELAY_STATUS = "SLEEP DELAY VALUE MUST BE GREATER THAN " + SLEEP_DELAY_MIN + " SECONDS";
+        return -1;
+    }
+}
+
+int readSoundLevel() {
+    unsigned int sampleWindow = 50; // Sample window width in milliseconds (50 milliseconds = 20Hz)
+    unsigned long endWindow = millis() + sampleWindow;  // End of sample window
+
+    unsigned int signalSample = 0;
+    unsigned int signalMin = 1024; // Minimum is the lowest signal below which we assume silence
+    unsigned int signalMax = signalMin; // Maximum signal starts out the same as the Minimum signal
+
+    // collect data for milliseconds equal to sampleWindow
+    while (millis() < endWindow)
+    {
+        signalSample = analogRead(SOUND);
+        if (signalSample > signalMax)
+        {
+            signalMax = signalSample;  // save just the max levels
+        }
+        else if (signalSample < signalMin)
+        {
+            signalMin = signalSample;  // save just the min levels
+        }
+    }
+
+    SOUNDV = signalMax - signalMin;  // max - min = peak-peak amplitude
+
+    return 1;
+}
+
+int readPower() {
+    // If voltage is fixed, e.g. 240V,
+    // and resistance is known/assumed,
+    // then the only variation is amperage.
+    POWR1V = (emon1.calcIrms(1480) * 1000); //Watts
+    POWR2V = (emon2.calcIrms(1480) * 1000); //Watts
+    POWR3V = (emon3.calcIrms(1480) * 1000); //Watts
+
+    return 1;
+}
+
+int readSoilTemperature() {
+    SOILTV = analogRead(SOILT);
+
+    return 1;
+}
+
+int readSoilHumidity() {
+    SOILHV = analogRead(SOILH);
+
+    return 2;
+}
+
+int readWeatherBMP180() {
+    if (BMP180OK)
+    {
+        /* Get a new sensor event */
+        sensors_event_t event;
+        bmp180.getEvent(&event);
+
+        // Read weather measurements from device
+        if (event.pressure)
+        {
+            BMP180Pressure = event.pressure;
+
+            /* First we get the current temperature from the BMP085 */
+            bmp180.getTemperature(&BMP180Temperature);
+
+            /* Then convert the atmospheric pressure, SLP and temp to altitude */
+            /* Update this next line with the current SLP for better results */
+            float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA;
+            BMP180Altitude = bmp180.pressureToAltitude(seaLevelPressure, BMP180Pressure, BMP180Temperature);
+        }
+    }
+
+    return BMP180OK ? 1 : 0;
+}
+
+int readWeatherSi7020() {
+    if (Si7020OK)
+    {
+        Si7020Temperature = si7020.readTemperature();
+        Si7020Humidity = si7020.readHumidity();
+    }
+
+    return Si7020OK ? 2 : 0;
+}
+
+int readWeatherSi1132() {
+    if (Si1132OK)
+    {
+        Si1132UVIndex = si1132.readUV() / 100;
+        Si1132Visible = si1132.readVisible();
+        Si1132InfraRd = si1132.readIR();
+    }
+
+    return Si1132OK ? 3 : 0;
+}
+
+int readMotion() {
+    if (ACCELOK)
+    {
+        // read raw accel/gyro measurements from device
+        mpu6050.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
+    }
+
+    return ACCELOK ? 1 : 0;
+}
+
+void postSensingVariableMap() {
+    sprintf(Sound, "%i", SOUNDV);
+    sprintf(Power, "%.2f %.2f %.2f", POWR1V, POWR2V, POWR3V);
+    sprintf(SoilTnH, "%i %i", SOILTV, SOILHV);
+    sprintf(PreTAlt, "%.2f %.2f %.2f", BMP180Pressure, BMP180Temperature, BMP180Altitude);
+    sprintf(AmbiTnH, "%.2f %.2f", Si7020Temperature, Si7020Humidity);
+    sprintf(UVVisIR, "%.2f %.2f %.2f", Si1132UVIndex, Si1132Visible, Si1132InfraRd);
+    sprintf(AcclXYZ, "%i %i %i", ax, ay, az);
+    sprintf(GyroXYZ, "%i %i %i", gx, gy, gz);
+}
+
+void postSensingEventPublish() {
+    // Publish update events
+    // --> up to a burst of 4 at rate of 1 per second
+    // --> testing delay of 1.0 seconds after each event
+    Spark.publish("Ready", NULL, String(EVENTSDELAY / 1000).toInt() * 8, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("Sound", String(Sound), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("Power", String(Power), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("SoilTnH", String(SoilTnH), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("PreTAlt", String(PreTAlt), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("AmbiTnH", String(AmbiTnH), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("UVVisIR", String(UVVisIR), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("AcclXYZ", String(AcclXYZ), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+    Spark.publish("GyroXYZ", String(GyroXYZ), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+}
+
+//********************************************************************************
+//********************************************************************************
+//********************************************************************************
+
+void setup() {
+    // Open serial over USB
+    Serial.begin(9600);
+
+    // Sets the I2C clock speed
+    //Wire.setSpeed(CLOCK_SPEED_400KHZ);
+
+    // Initialize IO pins
+    setPinsMode();
+
+    // Initialize cloud API variables
+    Spark.variable("Sound", &Sound, STRING);
+    Spark.variable("Power", &Power, STRING);
+    Spark.variable("SoilTnH", &SoilTnH, STRING);
+    Spark.variable("PreTAlt", &PreTAlt, STRING);
+    Spark.variable("AmbiTnH", &AmbiTnH, STRING);
+    Spark.variable("UVVisIR", &UVVisIR, STRING);
+    Spark.variable("AcclXYZ", &AcclXYZ, STRING);
+    Spark.variable("GyroXYZ", &GyroXYZ, STRING);
+
+    // Initialize cloud API functions
+    Spark.function("sleepDelay", setSleepDelay);
+}
+
+void loop(void) {
+    if (Spark.connected())
+    {
+        Serial.print("RUSK --> Device --> "); Serial.println(Spark.deviceID());
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        // Power up sensors
+        digitalWrite(I2CEN, HIGH);
+        digitalWrite(ALGEN, HIGH);
+
+        // Initialize BMP180
+        BMP180OK = bmp180.begin();
+        // Initialize Si7020
+        Si7020OK = si7020.begin();
+        // Initialize Si1132
+        Si1132OK = si1132.begin();
+        // Initialize MPU6050 and verify connection
+        mpu6050.initialize();
+        ACCELOK = mpu6050.testConnection();
+
+        // Allow sensors to warm up
+        delay(SENSORDELAY);
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        Serial.print("RUSK --> Sound --> "); Serial.println(readSoundLevel());
+        Serial.print("SoundNw:\t"); Serial.println(SOUNDV);
+
+        Serial.print("RUSK --> Power --> "); Serial.println(readPower());
+        Serial.print("WattsNw:\t");
+        Serial.print(POWR1V); Serial.print("\t");
+        Serial.print(POWR2V); Serial.print("\t");
+        Serial.println(POWR3V);
+
+        Serial.print("RUSK --> Soil --> "); Serial.println(readSoilTemperature() + readSoilHumidity());
+        Serial.print("SoilTem:\t"); Serial.println(SOILTV);
+        Serial.print("SoilHum:\t"); Serial.println(SOILHV);
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        Serial.print("RUSK --> Weather --> "); Serial.println(readWeatherBMP180() + readWeatherSi7020() + readWeatherSi1132());
+
+        // display values
+        Serial.print("BMPTemp:\t"); Serial.println(BMP180Temperature);
+        Serial.print("BMPPres:\t"); Serial.println(BMP180Pressure);
+        Serial.print("BMPAlti:\t"); Serial.println(BMP180Altitude);
+        Serial.print("AirTemp:\t"); Serial.println(Si7020Temperature);
+        Serial.print("AirHumi:\t"); Serial.println(Si7020Humidity);
+        Serial.print("UVIndx0:\t"); Serial.println(Si1132UVIndex);
+        Serial.print("Visible:\t"); Serial.println(Si1132Visible);
+        Serial.print("InfraRd:\t"); Serial.println(Si1132InfraRd);
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        Serial.print("RUSK --> Motion --> "); Serial.println(readMotion());
+
+        // display tab-separated accel x/y/z values
+        Serial.print("AcclXYZ:\t");
+        Serial.print(ax); Serial.print("\t");
+        Serial.print(ay); Serial.print("\t");
+        Serial.println(az);
+
+        // display tab-separated gyro x/y/z values
+        Serial.print("GyroXYZ:\t");
+        Serial.print(gx); Serial.print("\t");
+        Serial.print(gy); Serial.print("\t");
+        Serial.println(gz);
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        Serial.println("RUSK --> Device --> Post Sensing Activities");
+
+        // run post sensing activity
+        digitalWrite(LED, HIGH);
+        postSensingVariableMap();
+        postSensingEventPublish();
+        digitalWrite(LED, LOW);
+
+        //********************************************************************************
+        //********************************************************************************
+        //********************************************************************************
+
+        if (SLEEP_DELAY > 0)
+        {
+            // Power down sensors
+            digitalWrite(I2CEN, LOW);
+            digitalWrite(ALGEN, LOW);
+
+            //********************************************************************************
+            //********************************************************************************
+            //********************************************************************************
+
+            Serial.print("RUSK --> Sleep --> "); Serial.println(SLEEP_DELAY);
+            Serial.print("RUSK --> Sleep --> "); Serial.println(SLEEP_DELAY_STATUS);
+
+            // publish sleep event
+            Spark.publish("Sleep", String(SLEEP_DELAY), SLEEP_DELAY, PRIVATE); delay(EVENTSDELAY);
+
+            // run internal processes and invoke light sleep mode
+            Spark.process();
+            Spark.sleep(SLEEP_DELAY);
+        }
+    }
+    else
+    {
+        if (WiFi.ready())
+        {
+            Spark.connect();
+        }
+    }
+}


Add cycle test sketch

Add cycle test sketch

error: pathspec 'code/orb_cycle_test/orb_cycle_test.ino' did not match any file(s) known to git

--- code/orb_cycle_test/orb_cycle_test.ino
+++ code/orb_cycle_test/orb_cycle_test.ino
@@ -0,0 +1,60 @@
+/*
+  Cycles through each LED of the orb
+  2011-10-05 <nick.oleary@gmail.com>
+  http://opensource.org/licenses/mit-license.php
+*/
+
+
+#define l1rm 0x80
+#define l1gm 0x40
+#define l1bm 0x20
+
+#define l2rm 0x01
+#define l2gm 0x02
+#define l2bm 0x04
+
+#define l3rm 0x08
+#define l3gm 0x10
+#define l3bm 0x20
+
+#define LEDA(r1,g1,b1) PORTD = (PORTD&0x03)|(r1*l1rm)|(g1*l1gm)|(b1*l1bm)
+#define LEDB(r2,g2,b2) PORTC = (PORTC&0xF8)|(r2*l2rm)|(g2*l2gm)|(b2*l2bm)
+#define LEDC(r3,g3,b3) PORTC = (PORTC&0xC7)|(r3*l3rm)|(g3*l3gm)|(b3*l3bm)
+
+
+
+void setup() {
+  DDRD = DDRD | B11111100;
+  DDRC = DDRC | B00111111;
+  delay(1000);
+}
+
+
+
+void loop() {
+
+  LEDA(HIGH,LOW,LOW);
+  delay(500);
+  LEDA(LOW,HIGH,LOW);
+  delay(500);
+  LEDA(LOW,LOW,HIGH);
+  delay(500);
+  LEDA(LOW,LOW,LOW);
+
+  LEDB(HIGH,LOW,LOW);
+  delay(500);
+  LEDB(LOW,HIGH,LOW);
+  delay(500);
+  LEDB(LOW,LOW,HIGH);
+  delay(500);
+  LEDB(LOW,LOW,LOW);
+
+
+  LEDC(HIGH,LOW,LOW);
+  delay(500);
+  LEDC(LOW,HIGH,LOW);
+  delay(500);
+  LEDC(LOW,LOW,HIGH);
+  delay(500);
+  LEDC(LOW,LOW,LOW);
+}


add sketch to get MAC address and list visible networks

error: pathspec 'code/esp-scan/esp-scan.ino' did not match any file(s) known to git

--- code/esp-scan/esp-scan.ino
+++ code/esp-scan/esp-scan.ino
@@ -0,0 +1,60 @@
+#include "ESP8266WiFi.h"
+
+void setup()
+{
+  Serial.begin(115200);
+  Serial.println();
+
+  WiFi.mode(WIFI_STA);
+  WiFi.disconnect();
+  delay(100);
+
+  byte mac[6];
+  WiFi.macAddress(mac);
+  Serial.println("");
+  Serial.print("MAC: ");
+  Serial.print(mac[0],HEX);
+  Serial.print(":");
+  Serial.print(mac[1],HEX);
+  Serial.print(":");
+  Serial.print(mac[2],HEX);
+  Serial.print(":");
+  Serial.print(mac[3],HEX);
+  Serial.print(":");
+  Serial.print(mac[4],HEX);
+  Serial.print(":");
+  Serial.println(mac[5],HEX);
+}
+
+void loop()
+{
+
+  byte mac[6];
+  WiFi.macAddress(mac);
+  Serial.println("");
+  Serial.print("MAC: ");
+  Serial.print(mac[0],HEX);
+  Serial.print(":");
+  Serial.print(mac[1],HEX);
+  Serial.print(":");
+  Serial.print(mac[2],HEX);
+  Serial.print(":");
+  Serial.print(mac[3],HEX);
+  Serial.print(":");
+  Serial.print(mac[4],HEX);
+  Serial.print(":");
+  Serial.println(mac[5],HEX);
+
+
+  Serial.print("Scan start ... ");
+  int n = WiFi.scanNetworks();
+  Serial.print(n);
+  Serial.println(" network(s) found");
+  for (int i = 0; i < n; i++)
+  {
+    Serial.println(WiFi.SSID(i));
+  }
+  Serial.println();
+
+  delay(5000);
+}


#104 new example to show btree usage.

#104 new example to show btree usage.

error: pathspec 'examples/btreeCollection/btreeCollection.ino' did not match any file(s) known to git

--- examples/btreeCollection/btreeCollection.ino
+++ examples/btreeCollection/btreeCollection.ino
@@ -0,0 +1,118 @@
+/**
+ * This list is not designed to replace the collections in the standard library, it is a fairly light collection
+ * that works across a very wide range of boards. It is the underpinnings of switches, and we use it the mbed
+ * support too. So it is pretty much production ready.
+ *
+ * Here we create a class that we are going to store in the btree list, items in btree lists are ordered so
+ * insertion is a little slow, but retrieval, even by key is very quick - Log(NumItems). It dynamically reallocates
+ * if needed too, so there's no need in most cases to fiddle directly with the sizes.
+ *
+ * The only limitation of putting an item into the btree is that the method getKey() must be implemented by the type
+ * that is stored. You can see the default sizes of the list and other parameters in file SimpleCollections.h for
+ * advanced users.
+ *
+ * It is only designed to store small, simple class types that are not polymorphic, however, you can wrap a pointer
+ * to a more dynamic class type if you needed too as a field of this class.
+ *
+ * Important note for advanced users: This list is not thread safe. If you use it within task manager only this is not
+ * an issue, but if you use it elsewhere too, it must be protected by some kind of mutex or atomic block.
+ */
+
+#include <TaskManagerIO.h>
+#include <SimpleCollections.h>
+
+//
+// This is the type that we will store in our btree list, it will be stored indexed by it's key, and must implement
+// the getKey() method to return the key. In this type the key is an int.
+//
+class Book {
+private:
+    int key;
+    char name[20];
+public:
+    // You must include a default constructor that initialises the fields to empty, we store the actual
+    // items in the internal array in an initially empty state.
+    Book() {
+        key = 0;
+        name[0]=0;
+    }
+
+    // You must include a copy constructor that copies from an existing item. This is needed by the
+    // collection to copy items into the internal array.
+    Book(const Book& otherBook) {
+        strncpy(name, otherBook.name, sizeof name);
+        key = otherBook.key;
+    };
+
+    // And you'll probably need another constructor to initialise the fields for your own use.
+    Book(int bookKey, const char* bookName) {
+        strncpy(name, bookName, sizeof(name));
+        key = bookKey;
+    }
+
+    // you must implement a method that returns the key field with this name, it must return the same type as the
+    // key you specify for the list, (IE template parameter 1).
+    int getKey() {
+        return key;
+    }
+
+    // Just return the name we were given earlier
+    const char* getName() {
+        return name;
+    }
+};
+
+//
+// This is the declaration of the list, we declare it as a list of Book objects keyed using an int.
+//
+BtreeList<int, Book> myList;
+
+void setup() {
+    Serial.begin(115200);
+    while(!Serial);
+
+    myList.add(Book(3, "All about Arduino"));
+    myList.add(Book(2, "All about Xamarin"));
+    myList.add(Book(1, "Record players"));
+
+    // This shows us the current list capacity, do not worry if it drops to a very low value as it
+    // will reallocate automatically.
+    Serial.print("Capacity is now ");
+    Serial.println(myList.capacity());
+
+    // Get the index that is CLOSEST to a provided key, it is important to note that it's not an exact match
+    Serial.print("The nearest index to key 100 is ");
+    Serial.println(myList.nearestLocation(100));
+
+    // now every 10 seconds lets look for a book by it's ID
+    taskManager.scheduleFixedRate(10, [] {
+        auto book2 = myList.getByKey(2);
+        if(book2 != nullptr) {
+            Serial.print("Book 2 found: ");
+            Serial.println(book2->getName());
+        }
+        else {
+            Serial.println("Book 2 not found");
+        }
+    }, TIME_SECONDS);
+
+    // now every 15 seconds lets iterate all books in the collection
+    taskManager.scheduleFixedRate(15, [] {
+        for(bsize_t i = 0; i < myList.count(); ++i) {
+            auto book = myList.itemAtIndex(i);
+            Serial.print(book->getName());
+            Serial.print(", ");
+            Serial.println(book->getKey());
+        }
+    }, TIME_SECONDS);
+
+    // after a minute lets clean down the collection
+    taskManager.scheduleOnce(60, [] {
+        Serial.println("Now we will tear down the list");
+        myList.clear();
+    }, TIME_SECONDS);
+}
+
+void loop() {
+    taskManager.runLoop();
+}


Add gpio-comparison.ino

Add gpio-comparison.ino

error: pathspec 'examples/gpio-comparison/gpio-comparison.ino' did not match any file(s) known to git

--- examples/gpio-comparison/gpio-comparison.ino
+++ examples/gpio-comparison/gpio-comparison.ino
@@ -0,0 +1,65 @@
+// Compare time taken by digitalRead vs. a direct AVR register read for the same pin.
+
+#define TEST_PIN 4 // PD4
+
+uint16_t start = 0, end = 0;
+
+void setup()
+{
+  Serial.begin(115200);
+
+  // Wait for serial port to connect
+  while (!Serial) {}
+  Serial.println();
+
+  // Time 10k digitalRead calls
+  start = micros();
+  for (int i=0; i<10000; i++)
+  {
+    digitalRead(PD4);
+  }
+  end = micros();
+
+  Serial.print("Time (us) for 10000 digitalRead calls: ");
+  Serial.println(end - start); // 22640 us
+
+  // Time 10k AVR PIND register reads
+  start = micros();
+  for (int i=0; i<10000; i++)
+  {
+    PIND & (1 << PD4); // AVR equivalent to digitalRead(4)
+  }
+  end = micros();
+
+  Serial.print("Time (us) for 10000 AVR PIND register reads: ");
+  Serial.println(end - start); // 3448 us
+
+  pinMode(TEST_PIN, OUTPUT);
+  // Time 10k digitalWrite calls
+  start = micros();
+  for (int i=0; i<10000; i++)
+  {
+    digitalWrite(TEST_PIN, HIGH);
+  }
+  end = micros();
+
+  Serial.print("\nTime (us) for 10000 digitalWrite calls: ");
+  Serial.println(end - start); // 22640 us
+
+  // Time 10k AVR PIND register writes
+  start = micros();
+  for (int i=0; i<10000; i++)
+  {
+    PORTD |= (1 << PD4); // AVR equivalent to digitalRead(4)
+  }
+  end = micros();
+
+  Serial.print("Time (us) for 10000 AVR PIND register writes: ");
+  Serial.println(end - start); // 3448 us
+}
+
+void loop()
+{
+  // digitalWrite(TEST_PIN, !digitalRead(TEST_PIN)); // 56.58 kHz on scope
+  PORTD ^= (1 << PD4); // 444.4 kHz on scope
+}


Create edison2fiware.ino

Create edison2fiware.ino

error: pathspec 'arduino/edison2fiware.ino' did not match any file(s) known to git

--- arduino/edison2fiware.ino
+++ arduino/edison2fiware.ino
@@ -0,0 +1,107 @@
+//################# LIBRARIES ################
+  #include <SPI.h>
+  #include <WiFi.h>
+
+  //################# WIFI DETAILS #################
+  char ssid[] = "xxx"; //  your network SSID (name)
+  char pass[] = "xxx";    // your network password (use for WPA, or use as key for WEP)
+  int keyIndex = 0;            // your network key Index number (needed only for WEP)
+  int status = WL_IDLE_STATUS;
+
+  //################# NETWORK VARIABLES #################
+  // Name of the server we want to connect to
+  char server[] = "test.ttcloud.net";
+  int port = 8082;
+  WiFiClient client;
+
+  //################ FIWARE VARIABLES ################
+  int value = 0;
+  char alias[] = "l";
+
+
+  void setup()
+  {
+    // put your setup code here, to run once:
+    // initialize serial communications at 9600 bps:
+    Serial.begin(9600);
+
+    while (!Serial) {
+      ; // wait for serial port to connect. Needed for Leonardo only
+    }
+    setupNetwork();
+  }
+
+
+  void loop()
+  {
+    // read luminosity sensor value on analogic PIN 0
+    readSensor();
+    // send luminosity value to FIWARE IoT Stack
+    postMeasure(alias, value);
+    // wait 10s between measures
+    delay(10000);
+
+    // if the server's disconnected, stop the client:
+    if (!client.connected()) {
+      Serial.println();
+      Serial.println("Disconnecting from wifi");
+      client.stop();
+    }
+  }
+
+
+  void setupNetwork()
+  {
+    Serial.print("Configuring Network...");
+
+    // check for the presence of the shield:
+    if (WiFi.status() == WL_NO_SHIELD) {
+      Serial.println("WiFi shield not present");
+      // don't continue:
+      while(true);
+    }
+
+    String fv = WiFi.firmwareVersion();
+    if( fv != "1.1.0" )
+      Serial.println("Please upgrade the firmware");
+
+    // attempt to connect to Wifi network:
+    while (status != WL_CONNECTED) {
+      Serial.print("Attempting to connect to SSID: ");
+      Serial.println(ssid);
+      // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
+      status = WiFi.begin(ssid, pass);
+
+      // wait 10 seconds for connection:
+      delay(10000);
+    }
+    Serial.println("Connected to wifi");
+  }
+
+
+  void readSensor()
+  {
+    //Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
+    //read the input on analog pin 0:
+    value = analogRead(A0);
+  }
+
+
+  void postMeasure(char alias[],int value)
+  {
+    Serial.println("\nStarting connection to server...");
+
+    // if you get a connection, report back via serial:
+    if (client.connect(server, port)) {
+      Serial.println("connected to server");
+      // Make a HTTP request:
+      client.println("POST /iot/d?i=xxxx&k=xxxxx HTTP/1.1");
+      client.println("Host: test.ttcloud.net:8082");
+      String body = String(alias)+"|"+String(value);
+      client.println("Content-Length: "+String(body.length()));
+      client.println();
+      client.println(body);
+    }
+  }
+
+


Added modified version of StandardFirmata that uses the DotStar strip.

error: pathspec 'arduino/StandardFirmataChipKITSSPPII/StandardFirmataChipKITSSPPII.ino' did not match any file(s) known to git

--- arduino/StandardFirmataChipKITSSPPII/StandardFirmataChipKITSSPPII.ino
+++ arduino/StandardFirmataChipKITSSPPII/StandardFirmataChipKITSSPPII.ino
@@ -0,0 +1,745 @@
+/*
+  Firmata is a generic protocol for communicating with microcontrollers
+  from software on a host computer. It is intended to work with
+  any host computer software package.
+
+  To download a host software package, please clink on the following link
+  to open the list of Firmata client libraries your default browser.
+
+  https://github.com/firmata/arduino#firmata-client-libraries
+
+  Copyright (C) 2006-2008 Hans-Christoph Steiner.  All rights reserved.
+  Copyright (C) 2010-2011 Paul Stoffregen.  All rights reserved.
+  Copyright (C) 2009 Shigeru Kobayashi.  All rights reserved.
+  Copyright (C) 2009-2015 Jeff Hoefs.  All rights reserved.
+  Copyright (C) 2015 Brian Schmalz. All rights reserved.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  See file LICENSE.txt for further informations on licensing terms.
+
+  Last updated by Brian Schmalz: August 9th, 2015
+*/
+#include <SPI.h>
+#include <SoftPWMServo.h>  // Gives us PWM and Servo on every pin
+#include <Wire.h>
+#include <Firmata.h>
+#include <Adafruit_DotStar.h>
+
+
+#define NUMPIXELS 30 // Number of LEDs in strip
+#define DATAPIN    4
+#define CLOCKPIN   5
+
+#define I2C_WRITE                   B00000000
+#define I2C_READ                    B00001000
+#define I2C_READ_CONTINUOUSLY       B00010000
+#define I2C_STOP_READING            B00011000
+#define I2C_READ_WRITE_MODE_MASK    B00011000
+#define I2C_10BIT_ADDRESS_MODE_MASK B00100000
+#define I2C_MAX_QUERIES             8
+#define I2C_REGISTER_NOT_SPECIFIED  -1
+
+// the minimum interval for sampling analog input
+#define MINIMUM_SAMPLING_INTERVAL 10
+
+
+/*==============================================================================
+ * GLOBAL VARIABLES
+ *============================================================================*/
+/* apa102c rgb led strip */
+Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
+
+
+/* analog inputs */
+int analogInputsToReport = 0; // bitwise array to store pin reporting
+
+/* digital input ports */
+byte reportPINs[TOTAL_PORTS];       // 1 = report this port, 0 = silence
+byte previousPINs[TOTAL_PORTS];     // previous 8 bits sent
+
+/* pins configuration */
+byte pinConfig[TOTAL_PINS];         // configuration of every pin
+byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 = anything else
+int pinState[TOTAL_PINS];           // any value that has been written
+
+/* timer variables */
+unsigned long currentMillis;        // store the current value from millis()
+unsigned long previousMillis;       // for comparison with currentMillis
+unsigned int samplingInterval = 19; // how often to run the main loop (in ms)
+
+/* i2c data */
+struct i2c_device_info {
+  byte addr;
+  int reg;
+  byte bytes;
+};
+
+/* for i2c read continuous more */
+i2c_device_info query[I2C_MAX_QUERIES];
+
+byte i2cRxData[32];
+boolean isI2CEnabled = false;
+signed char queryIndex = -1;
+// default delay time between i2c read request and Wire.requestFrom()
+unsigned int i2cReadDelayTime = 0;
+
+SoftServo servos[MAX_SERVOS];
+byte servoPinMap[TOTAL_PINS];
+byte detachedServos[MAX_SERVOS];
+byte detachedServoCount = 0;
+byte servoCount = 0;
+
+boolean isResetting = false;
+
+/* utility functions */
+void wireWrite(byte data)
+{
+#if ARDUINO >= 100
+  Wire.write((byte)data);
+#else
+  Wire.send(data);
+#endif
+}
+
+byte wireRead(void)
+{
+#if ARDUINO >= 100
+  return Wire.read();
+#else
+  return Wire.receive();
+#endif
+}
+
+/*==============================================================================
+ * FUNCTIONS
+ *============================================================================*/
+
+void attachServo(byte pin, int minPulse, int maxPulse)
+{
+  if (servoCount < MAX_SERVOS) {
+    // reuse indexes of detached servos until all have been reallocated
+    if (detachedServoCount > 0) {
+      servoPinMap[pin] = detachedServos[detachedServoCount - 1];
+      if (detachedServoCount > 0) detachedServoCount--;
+    } else {
+      servoPinMap[pin] = servoCount;
+      servoCount++;
+    }
+    if (minPulse > 0 && maxPulse > 0) {
+      servos[servoPinMap[pin]].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse);
+    } else {
+      servos[servoPinMap[pin]].attach(PIN_TO_DIGITAL(pin));
+    }
+  } else {
+    Firmata.sendString("Max servos attached");
+  }
+}
+
+void detachServo(byte pin)
+{
+  servos[servoPinMap[pin]].detach();
+  // if we're detaching the last servo, decrement the count
+  // otherwise store the index of the detached servo
+  if (servoPinMap[pin] == servoCount && servoCount > 0) {
+    servoCount--;
+  } else if (servoCount > 0) {
+    // keep track of detached servos because we want to reuse their indexes
+    // before incrementing the count of attached servos
+    detachedServoCount++;
+    detachedServos[detachedServoCount - 1] = servoPinMap[pin];
+  }
+
+  servoPinMap[pin] = 255;
+}
+
+void readAndReportData(byte address, int theRegister, byte numBytes) {
+  // allow I2C requests that don't require a register read
+  // for example, some devices using an interrupt pin to signify new data available
+  // do not always require the register read so upon interrupt you call Wire.requestFrom()
+  if (theRegister != I2C_REGISTER_NOT_SPECIFIED) {
+    Wire.beginTransmission(address);
+    wireWrite((byte)theRegister);
+    Wire.endTransmission();
+    // do not set a value of 0
+    if (i2cReadDelayTime > 0) {
+      // delay is necessary for some devices such as WiiNunchuck
+      delayMicroseconds(i2cReadDelayTime);
+    }
+  } else {
+    theRegister = 0;  // fill the register with a dummy value
+  }
+
+  Wire.requestFrom(address, numBytes);  // all bytes are returned in requestFrom
+
+  // check to be sure correct number of bytes were returned by slave
+  if (numBytes < Wire.available()) {
+    Firmata.sendString("I2C: Too many bytes received");
+  } else if (numBytes > Wire.available()) {
+    Firmata.sendString("I2C: Too few bytes received");
+  }
+
+  i2cRxData[0] = address;
+  i2cRxData[1] = theRegister;
+
+  for (int i = 0; i < numBytes && Wire.available(); i++) {
+    i2cRxData[2 + i] = wireRead();
+  }
+
+  // send slave address, register and received bytes
+  Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData);
+}
+
+void outputPort(byte portNumber, byte portValue, byte forceSend)
+{
+  // pins not configured as INPUT are cleared to zeros
+  portValue = portValue & portConfigInputs[portNumber];
+  // only send if the value is different than previously sent
+  if (forceSend || previousPINs[portNumber] != portValue) {
+    Firmata.sendDigitalPort(portNumber, portValue);
+    previousPINs[portNumber] = portValue;
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * check all the active digital inputs for change of state, then add any events
+ * to the Serial output queue using Serial.print() */
+void checkDigitalInputs(void)
+{
+  /* Using non-looping code allows constants to be given to readPort().
+   * The compiler will apply substantial optimizations if the inputs
+   * to readPort() are compile-time constants. */
+  if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0, portConfigInputs[0]), false);
+  if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1, portConfigInputs[1]), false);
+  if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2, portConfigInputs[2]), false);
+  if (TOTAL_PORTS > 3 && reportPINs[3]) outputPort(3, readPort(3, portConfigInputs[3]), false);
+  if (TOTAL_PORTS > 4 && reportPINs[4]) outputPort(4, readPort(4, portConfigInputs[4]), false);
+  if (TOTAL_PORTS > 5 && reportPINs[5]) outputPort(5, readPort(5, portConfigInputs[5]), false);
+  if (TOTAL_PORTS > 6 && reportPINs[6]) outputPort(6, readPort(6, portConfigInputs[6]), false);
+  if (TOTAL_PORTS > 7 && reportPINs[7]) outputPort(7, readPort(7, portConfigInputs[7]), false);
+  if (TOTAL_PORTS > 8 && reportPINs[8]) outputPort(8, readPort(8, portConfigInputs[8]), false);
+  if (TOTAL_PORTS > 9 && reportPINs[9]) outputPort(9, readPort(9, portConfigInputs[9]), false);
+  if (TOTAL_PORTS > 10 && reportPINs[10]) outputPort(10, readPort(10, portConfigInputs[10]), false);
+  if (TOTAL_PORTS > 11 && reportPINs[11]) outputPort(11, readPort(11, portConfigInputs[11]), false);
+  if (TOTAL_PORTS > 12 && reportPINs[12]) outputPort(12, readPort(12, portConfigInputs[12]), false);
+  if (TOTAL_PORTS > 13 && reportPINs[13]) outputPort(13, readPort(13, portConfigInputs[13]), false);
+  if (TOTAL_PORTS > 14 && reportPINs[14]) outputPort(14, readPort(14, portConfigInputs[14]), false);
+  if (TOTAL_PORTS > 15 && reportPINs[15]) outputPort(15, readPort(15, portConfigInputs[15]), false);
+}
+
+// -----------------------------------------------------------------------------
+/* Sets a pin that is in Servo mode to a particular output value
+ * (i.e. pulse width). Different boards may have different ways of
+ * setting servo values, so putting it in a function keeps things cleaner.
+ */
+void servoWrite(byte pin, int value)
+{
+  SoftPWMServoPWMWrite(PIN_TO_PWM(pin), value);
+}
+
+// -----------------------------------------------------------------------------
+/* sets the pin mode to the correct state and sets the relevant bits in the
+ * two bit-arrays that track Digital I/O and PWM status
+ */
+void setPinModeCallback(byte pin, int mode)
+{
+  if (pinConfig[pin] == IGNORE)
+    return;
+
+  if (pinConfig[pin] == I2C && isI2CEnabled && mode != I2C) {
+    // disable i2c so pins can be used for other functions
+    // the following if statements should reconfigure the pins properly
+    disableI2CPins();
+  }
+  if (IS_PIN_DIGITAL(pin) && mode != SERVO) {
+    if (servoPinMap[pin] < MAX_SERVOS && servos[servoPinMap[pin]].attached()) {
+      detachServo(pin);
+    }
+  }
+  if (IS_PIN_ANALOG(pin)) {
+    reportAnalogCallback(PIN_TO_ANALOG(pin), mode == ANALOG ? 1 : 0); // turn on/off reporting
+  }
+  if (IS_PIN_DIGITAL(pin)) {
+    if (mode == INPUT) {
+      portConfigInputs[pin / 8] |= (1 << (pin & 7));
+    } else {
+      portConfigInputs[pin / 8] &= ~(1 << (pin & 7));
+    }
+  }
+  pinState[pin] = 0;
+  switch (mode) {
+    case ANALOG:
+      if (IS_PIN_ANALOG(pin)) {
+        if (IS_PIN_DIGITAL(pin)) {
+          pinMode(PIN_TO_DIGITAL(pin), INPUT);    // disable output driver
+          digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
+        }
+        pinConfig[pin] = ANALOG;
+      }
+      break;
+    case INPUT:
+      if (IS_PIN_DIGITAL(pin)) {
+        pinMode(PIN_TO_DIGITAL(pin), INPUT);    // disable output driver
+        digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable internal pull-ups
+        pinConfig[pin] = INPUT;
+      }
+      break;
+    case OUTPUT:
+      if (IS_PIN_DIGITAL(pin)) {
+        digitalWrite(PIN_TO_DIGITAL(pin), LOW); // disable PWM
+        pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
+        pinConfig[pin] = OUTPUT;
+      }
+      break;
+    case PWM:
+      if (IS_PIN_PWM(pin)) {
+        pinMode(PIN_TO_PWM(pin), OUTPUT);
+        servoWrite(PIN_TO_PWM(pin), 0);
+        pinConfig[pin] = PWM;
+      }
+      break;
+    case SERVO:
+      if (IS_PIN_DIGITAL(pin)) {
+        pinConfig[pin] = SERVO;
+        if (servoPinMap[pin] == 255 || !servos[servoPinMap[pin]].attached()) {
+          // pass -1 for min and max pulse values to use default values set
+          // by Servo library
+          attachServo(pin, -1, -1);
+        }
+      }
+      break;
+    case I2C:
+      if (IS_PIN_I2C(pin)) {
+        // mark the pin as i2c
+        // the user must call I2C_CONFIG to enable I2C for a device
+        pinConfig[pin] = I2C;
+      }
+      break;
+    default:
+      Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM
+  }
+  // TODO: save status to EEPROM here, if changed
+}
+
+void analogWriteCallback(byte pin, int value)
+{
+  if (pin < TOTAL_PINS) {
+    switch (pinConfig[pin]) {
+      case SERVO:
+        if (IS_PIN_DIGITAL(pin))
+          servos[servoPinMap[pin]].write(value);
+        pinState[pin] = value;
+        break;
+      case PWM:
+        if (IS_PIN_PWM(pin))
+          servoWrite(PIN_TO_PWM(pin), value);
+        pinState[pin] = value;
+        break;
+    }
+  }
+}
+
+void digitalWriteCallback(byte port, int value)
+{
+  byte pin, lastPin, mask = 1, pinWriteMask = 0;
+
+  if (port < TOTAL_PORTS) {
+    // create a mask of the pins on this port that are writable.
+    lastPin = port * 8 + 8;
+    if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS;
+    for (pin = port * 8; pin < lastPin; pin++) {
+      // do not disturb non-digital pins (eg, Rx & Tx)
+      if (IS_PIN_DIGITAL(pin)) {
+        // only write to OUTPUT and INPUT (enables pullup)
+        // do not touch pins in PWM, ANALOG, SERVO or other modes
+        if (pinConfig[pin] == OUTPUT || pinConfig[pin] == INPUT) {
+          pinWriteMask |= mask;
+          pinState[pin] = ((byte)value & mask) ? 1 : 0;
+        }
+      }
+      mask = mask << 1;
+    }
+    writePort(port, (byte)value, pinWriteMask);
+  }
+}
+
+
+// -----------------------------------------------------------------------------
+/* sets bits in a bit array (int) to toggle the reporting of the analogIns
+ */
+//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
+//}
+void reportAnalogCallback(byte analogPin, int value)
+{
+  if (analogPin < TOTAL_ANALOG_PINS) {
+    if (value == 0) {
+      analogInputsToReport = analogInputsToReport & ~ (1 << analogPin);
+    } else {
+      analogInputsToReport = analogInputsToReport | (1 << analogPin);
+      // prevent during system reset or all analog pin values will be reported
+      // which may report noise for unconnected analog pins
+      if (!isResetting) {
+        // Send pin value immediately. This is helpful when connected via
+        // ethernet, wi-fi or bluetooth so pin states can be known upon
+        // reconnecting.
+        Firmata.sendAnalog(analogPin, analogRead(analogPin));
+      }
+    }
+  }
+  // TODO: save status to EEPROM here, if changed
+}
+
+void reportDigitalCallback(byte port, int value)
+{
+  if (port < TOTAL_PORTS) {
+    reportPINs[port] = (byte)value;
+    // Send port value immediately. This is helpful when connected via
+    // ethernet, wi-fi or bluetooth so pin states can be known upon
+    // reconnecting.
+    if (value) outputPort(port, readPort(port, portConfigInputs[port]), true);
+  }
+  // do not disable analog reporting on these 8 pins, to allow some
+  // pins used for digital, others analog.  Instead, allow both types
+  // of reporting to be enabled, but check if the pin is configured
+  // as analog when sampling the analog inputs.  Likewise, while
+  // scanning digital pins, portConfigInputs will mask off values from any
+  // pins configured as analog
+}
+
+/*==============================================================================
+ * SYSEX-BASED commands
+ *============================================================================*/
+
+void sysexCallback(byte command, byte argc, byte *argv)
+{
+  byte mode;
+  byte slaveAddress;
+  byte data;
+  int slaveRegister;
+  unsigned int delayTime;
+
+  switch (command) {
+    case I2C_REQUEST:
+      mode = argv[1] & I2C_READ_WRITE_MODE_MASK;
+      if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) {
+        Firmata.sendString("10-bit addressing not supported");
+        return;
+      }
+      else {
+        slaveAddress = argv[0];
+      }
+
+      switch (mode) {
+        case I2C_WRITE:
+          Wire.beginTransmission(slaveAddress);
+          for (byte i = 2; i < argc; i += 2) {
+            data = argv[i] + (argv[i + 1] << 7);
+            wireWrite(data);
+          }
+          Wire.endTransmission();
+          delayMicroseconds(70);
+          break;
+        case I2C_READ:
+          if (argc == 6) {
+            // a slave register is specified
+            slaveRegister = argv[2] + (argv[3] << 7);
+            data = argv[4] + (argv[5] << 7);  // bytes to read
+          }
+          else {
+            // a slave register is NOT specified
+            slaveRegister = I2C_REGISTER_NOT_SPECIFIED;
+            data = argv[2] + (argv[3] << 7);  // bytes to read
+          }
+          readAndReportData(slaveAddress, (int)slaveRegister, data);
+          break;
+        case I2C_READ_CONTINUOUSLY:
+          if ((queryIndex + 1) >= I2C_MAX_QUERIES) {
+            // too many queries, just ignore
+            Firmata.sendString("too many queries");
+            break;
+          }
+          if (argc == 6) {
+            // a slave register is specified
+            slaveRegister = argv[2] + (argv[3] << 7);
+            data = argv[4] + (argv[5] << 7);  // bytes to read
+          }
+          else {
+            // a slave register is NOT specified
+            slaveRegister = (int)I2C_REGISTER_NOT_SPECIFIED;
+            data = argv[2] + (argv[3] << 7);  // bytes to read
+          }
+          queryIndex++;
+          query[queryIndex].addr = slaveAddress;
+          query[queryIndex].reg = slaveRegister;
+          query[queryIndex].bytes = data;
+          break;
+        case I2C_STOP_READING:
+          byte queryIndexToSkip;
+          // if read continuous mode is enabled for only 1 i2c device, disable
+          // read continuous reporting for that device
+          if (queryIndex <= 0) {
+            queryIndex = -1;
+          } else {
+            // if read continuous mode is enabled for multiple devices,
+            // determine which device to stop reading and remove it's data from
+            // the array, shifiting other array data to fill the space
+            for (byte i = 0; i < queryIndex + 1; i++) {
+              if (query[i].addr == slaveAddress) {
+                queryIndexToSkip = i;
+                break;
+              }
+            }
+
+            for (byte i = queryIndexToSkip; i < queryIndex + 1; i++) {
+              if (i < I2C_MAX_QUERIES) {
+                query[i].addr = query[i + 1].addr;
+                query[i].reg = query[i + 1].reg;
+                query[i].bytes = query[i + 1].bytes;
+              }
+            }
+            queryIndex--;
+          }
+          break;
+        default:
+          break;
+      }
+      break;
+    case I2C_CONFIG:
+      delayTime = (argv[0] + (argv[1] << 7));
+
+      if (delayTime > 0) {
+        i2cReadDelayTime = delayTime;
+      }
+
+      if (!isI2CEnabled) {
+        enableI2CPins();
+      }
+
+      break;
+    case SERVO_CONFIG:
+      if (argc > 4) {
+        // these vars are here for clarity, they'll optimized away by the compiler
+        byte pin = argv[0];
+        int minPulse = argv[1] + (argv[2] << 7);
+        int maxPulse = argv[3] + (argv[4] << 7);
+
+        if (IS_PIN_DIGITAL(pin)) {
+          if (servoPinMap[pin] < MAX_SERVOS && servos[servoPinMap[pin]].attached()) {
+            detachServo(pin);
+          }
+          attachServo(pin, minPulse, maxPulse);
+          setPinModeCallback(pin, SERVO);
+        }
+      }
+      break;
+    case SAMPLING_INTERVAL:
+      if (argc > 1) {
+        samplingInterval = argv[0] + (argv[1] << 7);
+        if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) {
+          samplingInterval = MINIMUM_SAMPLING_INTERVAL;
+        }
+      } else {
+        //Firmata.sendString("Not enough data");
+      }
+      break;
+    case EXTENDED_ANALOG:
+      if (argc > 1) {
+        int val = argv[1];
+        if (argc > 2) val |= (argv[2] << 7);
+        if (argc > 3) val |= (argv[3] << 14);
+        analogWriteCallback(argv[0], val);
+      }
+      break;
+    case CAPABILITY_QUERY:
+      Firmata.write(START_SYSEX);
+      Firmata.write(CAPABILITY_RESPONSE);
+      for (byte pin = 0; pin < TOTAL_PINS; pin++) {
+        if (IS_PIN_DIGITAL(pin)) {
+          Firmata.write((byte)INPUT);
+          Firmata.write(1);
+          Firmata.write((byte)OUTPUT);
+          Firmata.write(1);
+        }
+        if (IS_PIN_ANALOG(pin)) {
+          Firmata.write(ANALOG);
+          Firmata.write(10); // 10 = 10-bit resolution
+        }
+        if (IS_PIN_PWM(pin)) {
+          Firmata.write(PWM);
+          Firmata.write(8); // 8 = 8-bit resolution
+        }
+        if (IS_PIN_DIGITAL(pin)) {
+          Firmata.write(SERVO);
+          Firmata.write(14);
+        }
+        if (IS_PIN_I2C(pin)) {
+          Firmata.write(I2C);
+          Firmata.write(1);  // TODO: could assign a number to map to SCL or SDA
+        }
+        Firmata.write(127);
+      }
+      Firmata.write(END_SYSEX);
+      break;
+    case PIN_STATE_QUERY:
+      if (argc > 0) {
+        byte pin = argv[0];
+        Firmata.write(START_SYSEX);
+        Firmata.write(PIN_STATE_RESPONSE);
+        Firmata.write(pin);
+        if (pin < TOTAL_PINS) {
+          Firmata.write((byte)pinConfig[pin]);
+          Firmata.write((byte)pinState[pin] & 0x7F);
+          if (pinState[pin] & 0xFF80) Firmata.write((byte)(pinState[pin] >> 7) & 0x7F);
+          if (pinState[pin] & 0xC000) Firmata.write((byte)(pinState[pin] >> 14) & 0x7F);
+        }
+        Firmata.write(END_SYSEX);
+      }
+      break;
+    case ANALOG_MAPPING_QUERY:
+      Firmata.write(START_SYSEX);
+      Firmata.write(ANALOG_MAPPING_RESPONSE);
+      for (byte pin = 0; pin < TOTAL_PINS; pin++) {
+        Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
+      }
+      Firmata.write(END_SYSEX);
+      break;
+  }
+}
+
+void enableI2CPins()
+{
+  byte i;
+  // is there a faster way to do this? would probaby require importing
+  // Arduino.h to get SCL and SDA pins
+  for (i = 0; i < TOTAL_PINS; i++) {
+    if (IS_PIN_I2C(i)) {
+      // mark pins as i2c so they are ignore in non i2c data requests
+      setPinModeCallback(i, I2C);
+    }
+  }
+
+  isI2CEnabled = true;
+
+  Wire.begin();
+}
+
+/* disable the i2c pins so they can be used for other functions */
+void disableI2CPins() {
+  isI2CEnabled = false;
+  // disable read continuous mode for all devices
+  queryIndex = -1;
+}
+
+/*==============================================================================
+ * SETUP()
+ *============================================================================*/
+
+void systemResetCallback()
+{
+  isResetting = true;
+  // initialize a defalt state
+  // TODO: option to load config from EEPROM instead of default
+  if (isI2CEnabled) {
+    disableI2CPins();
+  }
+
+  for (byte i = 0; i < TOTAL_PORTS; i++) {
+    reportPINs[i] = false;    // by default, reporting off
+    portConfigInputs[i] = 0;  // until activated
+    previousPINs[i] = 0;
+  }
+
+  for (byte i = 0; i < TOTAL_PINS; i++) {
+    // pins with analog capability default to analog input
+    // otherwise, pins default to digital output
+    if (IS_PIN_ANALOG(i)) {
+      // turns off pullup, configures everything
+      setPinModeCallback(i, ANALOG);
+    } else {
+      // sets the output to 0, configures portConfigInputs
+      setPinModeCallback(i, OUTPUT);
+    }
+
+    servoPinMap[i] = 255;
+  }
+  // by default, do not report any analog inputs
+  analogInputsToReport = 0;
+
+  detachedServoCount = 0;
+  servoCount = 0;
+
+  /* send digital inputs to set the initial state on the host computer,
+   * since once in the loop(), this firmware will only send on change */
+  /*
+  TODO: this can never execute, since no pins default to digital input
+        but it will be needed when/if we support EEPROM stored config
+  for (byte i=0; i < TOTAL_PORTS; i++) {
+    outputPort(i, readPort(i, portConfigInputs[i]), true);
+  }
+  */
+  isResetting = false;
+}
+
+void setup()
+{
+  Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION);
+
+  Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
+  Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
+  Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
+  Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
+  Firmata.attach(SET_PIN_MODE, setPinModeCallback);
+  Firmata.attach(START_SYSEX, sysexCallback);
+  Firmata.attach(SYSTEM_RESET, systemResetCallback);
+
+  /* For chipKIT Pi board, we need to use Serial1. All others just use Serial. */
+#if defined(_BOARD_CHIPKIT_PI_)
+  Serial1.begin(57600);
+  Firmata.begin(Serial1);
+#else
+  Firmata.begin(57600);
+#endif
+  systemResetCallback();  // reset to default config
+}
+
+/*==============================================================================
+ * LOOP()
+ *============================================================================*/
+void loop()
+{
+  byte pin, analogPin;
+
+  /* DIGITALREAD - as fast as possible, check for changes and output them to the
+   * FTDI buffer using Serial.print()  */
+  checkDigitalInputs();
+
+  /* STREAMREAD - processing incoming messagse as soon as possible, while still
+   * checking digital inputs.  */
+  while (Firmata.available())
+    Firmata.processInput();
+
+  // TODO - ensure that Stream buffer doesn't go over 60 bytes
+
+  currentMillis = millis();
+  if (currentMillis - previousMillis > samplingInterval) {
+    previousMillis += samplingInterval;
+    /* ANALOGREAD - do all analogReads() at the configured sampling interval */
+    for (pin = 0; pin < TOTAL_PINS; pin++) {
+      if (IS_PIN_ANALOG(pin) && pinConfig[pin] == ANALOG) {
+        analogPin = PIN_TO_ANALOG(pin);
+        if (analogInputsToReport & (1 << analogPin)) {
+          Firmata.sendAnalog(analogPin, analogRead(analogPin));
+        }
+      }
+    }
+    // report i2c data for all device with read continuous mode enabled
+    if (queryIndex > -1) {
+      for (byte i = 0; i < queryIndex + 1; i++) {
+        readAndReportData(query[i].addr, query[i].reg, query[i].bytes);
+      }
+    }
+  }
+}


Adds E-stop arduino code

Adds E-stop arduino code

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jondolan/igvc-software.git/'


Final Working Arduino Code

Final Working Arduino Code

error: pathspec 'TStat_RevShare.ino' did not match any file(s) known to git

--- TStat_RevShare.ino
+++ TStat_RevShare.ino
@@ -0,0 +1,288 @@
+/* ArduStat, a web-controlled wifi thermostat project
+Author - Rahul Sangole
+Date - Jan 2014
+
+Thanks for Adafruit and all the active members on the Arduino forums for their inputs!
+ */
+#include <Adafruit_CC3000.h>
+#include <ccspi.h>
+#include <SPI.h>
+#include <string.h>
+#include "utility/debug.h"
+#include <Servo.h>
+#include "dht11.h"
+
+// ----------------------------
+// ----------------------------
+// Global Variables & Initiation
+// ----------------------------
+// Wireless Setup
+// These are the interrupt and control pins
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+// These can be any two pins
+#define ADAFRUIT_CC3000_VBAT  5
+#define ADAFRUIT_CC3000_CS    10
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,SPI_CLOCK_DIV2); // you can change this clock speed but DI
+#define WLAN_SSID "YOURSSID"        // cannot be longer than 32 characters!
+#define WLAN_PASS "YOURPASS"
+// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
+#define WLAN_SECURITY WLAN_SEC_WPA2
+#define IDLE_TIMEOUT_MS 3000      // Amount of time to wait (in milliseconds) with no data
+
+// ----------------------------
+// Website Setup
+#define WEBSITE      "YOUR SITE FOR TEMP COMMAND DATA"
+#define WEBPAGE      "/tdata.html"
+
+// ----------------------------
+// Xively Setup
+#define XWEBSITE  "api.xively.com"
+#define API_key  "YOUR API KEY"
+#define feedID  "YOUR FEED ID"
+
+// ----------------------------
+// Misc
+#define DELAY 900000
+int TEXIST=68;
+
+// ----------------------------
+// DHT Setup
+#define DHTPIN A0     // what pin we're connected to
+#define DHTTYPE DHT11
+dht11 DHT11;
+
+// ----------------------------
+Servo myservo;
+int SPOS=60;
+#define SPIN 4
+
+
+// ----------------------------
+// ----------------------------
+
+void setup(void){
+  Serial.begin(9600);
+  myservo.attach(SPIN);
+  myservo.write(SPOS);
+  delay(1000);
+  myservo.detach();
+}
+
+// ----------------------------
+// ----------------------------
+
+void loop(void){
+  Serial.print(F("Existing Temperature: "));
+  Serial.print(TEXIST);
+  Serial.println(F(" deg F"));
+  initWifi();
+  deleteOldConn();
+  connectWifi();
+  requestDCHP();
+  // Get Commanded Temperature
+  int treq=getTemp();
+  // Check Against Existing Temperature, Command Servo
+  if(treq!=TEXIST){
+    myservo.attach(SPIN);
+    changeTemp(treq);
+    delay(1000);
+    myservo.detach();
+  }
+  // Update Xively
+  updateXively();
+  // Close Wifi Connection
+  closeWifi();
+  // Delay
+  delay(DELAY);
+}
+
+void initWifi(void){
+  Serial.println(F("\nInitialising the CC3000 ..."));
+  if (!cc3000.begin())
+  {
+    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
+    while(1);
+  }
+}
+
+void deleteOldConn(void){
+  /* Delete any old connection data on the module */
+  Serial.println(F("\nDeleting old connection profiles"));
+  if (!cc3000.deleteProfiles()) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+}
+
+void connectWifi(void){
+  /* Attempt to connect to an access point */
+  char *ssid = WLAN_SSID;             /* Max 32 chars */
+  Serial.print(F("\nAttempting to connect to "));
+  Serial.println(ssid);
+  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+
+  Serial.println(F("Connected!"));
+  Serial.println(F("\n"));
+}
+
+void requestDCHP(){
+  /* Wait for DHCP to complete */
+  Serial.println(F("Requesting DHCP..."));
+  while (!cc3000.checkDHCP())
+  {
+    delay(100); // ToDo: Insert a DHCP timeout!
+  }
+  Serial.println(F("DCHP Done."));
+  Serial.println(F("\n\n"));
+
+}
+
+int getTemp(){
+  uint32_t ip = 0;
+  String readString = "";
+  Serial.println(F("Connecting to website..."));
+  while  (ip  ==  0)  {
+    if  (!  cc3000.getHostByName(WEBSITE, &ip))  {
+      Serial.println(F("Couldn't resolve!"));
+    }
+    delay(500);
+  }
+  cc3000.printIPdotsRev(ip);
+
+  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
+
+  Serial.println(F("Text Return:"));
+  if (www.connected()) {
+    www.fastrprint(F("GET "));
+    www.fastrprint(WEBPAGE);
+    www.fastrprint(F(" HTTP/1.1\r\n"));
+    www.fastrprint(F("Host: "));
+    www.fastrprint(WEBSITE);
+    www.fastrprint(F("\r\n"));
+    www.fastrprint(F("\r\n"));
+    www.println();
+  }
+  Serial.println(F("-------------------------------------"));
+
+  /* Read data until either the connection is closed, or the idle timeout is reached. */
+  unsigned long lastRead = millis();
+  while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
+    while (www.available()) {
+      char c = www.read();
+      Serial.print(c);      //read char by char HTTP request
+      readString+=c;
+      lastRead = millis();
+    }
+  }
+  www.close();
+  Serial.println(F("-------------------------------------"));
+  Serial.println(F("\n"));
+  //Find temperautre in the data based on <<
+  int index = readString.indexOf('<<');
+  String tempstr = readString.substring(index+2, index+4);
+  int tempcomm = tempstr.toInt();
+  Serial.print("Commanded temp in int: ");
+  Serial.println(tempcomm);
+  Serial.println(F("-------------------------------------"));
+  return tempcomm;
+}
+
+void changeTemp(int treq){
+  if (treq!=TEXIST){
+    //Command Servo
+    delay(1000);
+    Serial.print(F("Command Servo to "));
+    Serial.println(treq);
+    myservo.write(110);
+    delay(1000);
+    switch(treq){
+    case 58:
+      myservo.write(110);
+      break;
+    case 60:
+      myservo.write(100);
+      break;
+    case 62:
+      myservo.write(90);
+      break;
+    case 64:
+      myservo.write(80);
+      break;
+    case 66:
+      myservo.write(70);
+      break;
+    case 68:
+      myservo.write(60);
+      break;
+    case 70:
+      myservo.write(50);
+      break;
+    case 0:
+      myservo.write(100);
+      break;
+    }
+    TEXIST=treq;
+  }
+  else
+    Serial.println(F("No change in temp, no servo command"));
+  Serial.println(F("\n"));
+
+}
+
+void updateXively(){
+
+  uint32_t ip = 0;
+
+  Serial.print(F("Humidity is: ")); Serial.println((float)h,2);
+  Serial.print(F("Temp is: ")); Serial.println((float)t,2);
+
+  int length = 0;
+  String data = "";
+  data = data + "\n" + "{\"version\":\"1.0.0\",\"datastreams\" : [ {\"id\" : \"TCommand\",\"current_value\" : \"" + String((int)((TEXIST-32)*5/9)) + "\"},"
+    + "{\"id\" : \"Temperature\",\"current_value\" : \"" + String(t) + "\"},"
+    + "{\"id\" : \"Humidity\",\"current_value\" : \"" + String(h) + "\"}]}";
+
+  Serial.println(F("-------------------------------------"));
+  Serial.println(F("Connecting to Xively website..."));
+  while  (ip  ==  0)  {
+    if  (!  cc3000.getHostByName(XWEBSITE, &ip))  {
+      Serial.println(F("Couldn't resolve!"));
+    }
+    delay(500);
+  }
+  cc3000.printIPdotsRev(ip);
+  length = data.length();
+  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
+  if (client.connected()) {
+    Serial.println("Connected!");
+    client.println("PUT /v2/feeds/" + String(feedID) + ".json HTTP/1.0");
+    client.println("Host: api.xively.com");
+    client.println("X-ApiKey: " + String(API_key));
+    client.println("Content-Length: " + String(length));
+    client.print("Connection: close");
+    client.println();
+    client.print(data);
+    client.println();
+  }
+
+  while (client.connected()) {
+    while (client.available()) {
+      char c = client.read();
+      Serial.print(c);
+    }
+  }
+  Serial.println(F("Xively update complete"));
+  client.close();
+}
+
+void closeWifi(void){
+  Serial.println(F("\nCC3000 disconnected"));
+  cc3000.disconnect();
+}
+
+
+


Cleaning up code, adding or clarifiying comments.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/tomwagner1999/SmartHome.git/'


initial commit

initial commit

error: pathspec 'circadian_hallway_cycle_colors/circadian_hallway_cycle_colors.ino' did not match any file(s) known to git

--- circadian_hallway_cycle_colors/circadian_hallway_cycle_colors.ino
+++ circadian_hallway_cycle_colors/circadian_hallway_cycle_colors.ino
@@ -0,0 +1,129 @@
+#define GRN_PIN 5
+#define RED_PIN 6
+#define BLU_PIN 9
+
+byte RED, GREEN, BLUE;
+byte RED_A = 0;
+byte GREEN_A = 0;
+byte BLUE_A = 0;
+int led_delay = 0;
+byte color_count = 1;                //Count the colors out
+#define color_count_max 5              //Set this to the max number of colors defined
+#define color_delay 20000             //Define the delay between changing colors in ms
+#define time_at_color 1           //Time to stay on a color in ms
+
+//Some Time values
+unsigned long TIME_LED = 0;
+unsigned long TIME_color = 0;
+
+//Evening colors defined here
+#define C1_R 200
+#define C1_G 0
+#define C1_B 0
+
+#define C2_R 225
+#define C2_G 20
+#define C2_B 0
+
+#define C3_R 255
+#define C3_G 40
+#define C3_B 0
+
+#define C4_R 245
+#define C4_G 30
+#define C4_B 0
+
+#define C5_R 200
+#define C5_G 00
+#define C5_B 0
+
+void setup()
+{
+
+  //Assign initial values
+  RED = C1_R;
+  GREEN = C1_G;
+  BLUE = C1_B;
+  //Get the led_delay speed
+  led_delay = (color_delay - time_at_color) / 255;
+
+  analogWrite(GRN_PIN, 0);
+  analogWrite(RED_PIN, 0);
+  analogWrite(BLU_PIN, 0);
+
+}
+
+void loop()
+{
+
+  //Rest of your program - Avoid using delay(); function!
+
+  if(millis() - TIME_LED >= led_delay){
+    TIME_LED = millis();
+
+    //Run the LED Function to check and adjust the values
+    LED();
+  }
+
+  if(millis() - TIME_color >= color_delay){
+    TIME_color = millis();
+
+    //Run the color Change function
+    color();
+  }
+
+}
+
+void LED()
+{
+
+  //Check Values and adjust "Active" Value
+  if(RED != RED_A){
+    if(RED_A > RED) RED_A = RED_A - 1;
+    if(RED_A < RED) RED_A++;
+  }
+  if(GREEN != GREEN_A){
+    if(GREEN_A > GREEN) GREEN_A = GREEN_A - 1;
+    if(GREEN_A < GREEN) GREEN_A++;
+  }
+  if(BLUE != BLUE_A){
+    if(BLUE_A > BLUE) BLUE_A = BLUE_A - 1;
+    if(BLUE_A < BLUE) BLUE_A++;
+  }
+
+  //Assign modified values to the pwm outputs for each color led
+  analogWrite(RED_PIN, RED_A);
+  analogWrite(GRN_PIN, GREEN_A);
+  analogWrite(BLU_PIN, BLUE_A);
+
+}
+
+void color()
+{
+
+  //Increment the color by one or go back to 1 if maxed out
+  if(color_count < color_count_max) color_count++;
+  else color_count = 1;
+
+  if(color_count == 1){
+    RED = C1_R;
+    GREEN = C1_G;
+    BLUE = C1_B;
+  } else if(color_count == 2){
+    RED = C2_R;
+    GREEN = C2_G;
+    BLUE = C2_B;
+  } else if(color_count == 3){
+    RED = C3_R;
+    GREEN = C3_G;
+    BLUE = C3_B;
+  } else if(color_count == 4){
+    RED = C4_R;
+    GREEN = C4_G;
+    BLUE = C4_B;
+  } else if(color_count == 5){
+    RED = C5_R;
+    GREEN = C5_G;
+    BLUE = C5_B;
+  }
+}