Initial Commit

Initial Commit

error: pathspec 'skittle-color-sorter.ino' did not match any file(s) known to git

--- skittle-color-sorter.ino
+++ skittle-color-sorter.ino
@@ -0,0 +1,212 @@
+/*
+  Skittle Color Sorter
+
+  This sketch programs the Skittle Color Sorter that we
+  assembled.
+*/
+
+// The circuit:
+// * Top Servo
+//    Digital pin 13
+const int pinTopServo = 13;
+// * Bottom Servo (Arm)
+//    Digital pin 10
+const int pinBtmServo = 10;
+// * Color Sensor
+//    SDA pin to analog pin 4
+//    SCL pin to analog pin 5
+//    Color View Red pin to diginal pin 7
+//    Color View Green pin to diginal pin 9
+//    Color View Blue pin to diginal pin 6
+// * LCD
+//    RS pin to digital pin 12
+const int pinLcdRS = 12;
+//    Enable pin to digital pin 11
+const int pinLcdEnable = 11;
+//    LCD D4 pin to digital pin 5
+const int pinLcdD4 = 5;
+//    LCD D5 pin to digital pin 4
+const int pinLcdD5 = 4;
+//    LCD D6 pin to digital pin 3
+const int pinLcdD6 = 3;
+//    LCD D7 pin to digital pin 2
+const int pinLcdD7 = 2;
+//    LCD R/W pin to ground
+
+
+// Constants
+const boolean topServoTimeoutEnable = true; // Enable the timeout for the top servo
+const int topServoTimeout = 6000; // Timeout to determine if the top servo is stuck
+const int rewindingTime = 500; // Time in milliseconds when the top servo rewinds to solve jam
+
+// Include libraries
+#include <LiquidCrystal.h>      // LCD display
+#include <Servo.h>              // Servos
+#include "Adafruit_TCS34725.h"  // Color Sensor
+
+// Initialize the display with the numbers of the interface pins
+LiquidCrystal lcd(pinLcdRS, pinLcdEnable, pinLcdD4, pinLcdD5, pinLcdD6, pinLcdD7);
+// Create the object for the top continuous rotation servo
+Servo servoTop;
+// Create the object for the bottom standard servo
+Servo servoBtm;
+// Create the color sensor object
+Adafruit_TCS34725 tcs = Adafruit_TCS34725();
+
+// Variables
+int skittleCount = 0; // The number of skittles sorted
+unsigned long lastSkittleTime = 0; // Time when the last skittle was being sorted
+int topServoSpeed = 0; // The speed in which the top servo moves
+boolean isColorBeingMeasured = false; // Is the color sensor measuring the Skittle right now
+
+
+void setup() {
+  // Set up the serial for debugging purposes
+  Serial.begin(9600);
+
+  // Set up the LCD's number of columns and rows:
+  lcd.begin(16, 2);
+
+  // Attach the servos on corresponding pins to the servo objects
+  servoTop.attach(pinTopServo);
+  servoBtm.attach(pinBtmServo);
+
+  if(!tcs.begin()){
+    // If the color sensor failed to initialize, print out an error
+    lcd.print("ERR: Color Sensor Connection Error");
+    Serial.println("ERR: Color Sensor connection can't be established.");
+    while (1);
+  }
+
+  lcd.print("Color Sorter");
+
+}
+
+void updateTopServo(){
+  // Is the servo going the opposite direction
+  static boolean rewinding = false;
+
+  // Set the speed of the top servo
+  // 0 being full-speed clockwise
+  // 90 being no movement
+  // 180 being full-speed counterclockwise
+  servoTop.write(rewinding? 180: topServoSpeed);
+
+  // If color is being measured right now, skip the jam detection
+  if(isColorBeingMeasured)
+    return;
+
+  // If timeout is NOT enabled, skip the jam detection
+  if(!topServoTimeoutEnable)
+    return;
+
+  // If the top servo gets stuck, start rewinding
+  if(millis() - lastSkittleTime > topServoTimeout){
+    Serial.println("Top servo is stuck; Direction reversed.");
+    // Reserve the top servo's direction
+    rewinding = true;
+
+    lastSkittleTime = millis();
+  }
+
+  // If rewinding more than the set time, set direction back to normal
+  if(rewinding && millis() - lastSkittleTime > rewindingTime){
+    rewinding = false;
+  }
+
+}
+
+void updateBtmServo(){
+
+  // Calculate the angle of the bottom servo arm
+  static int btmAngle = 0;
+  static bool btmReversed = false;
+  btmAngle += btmReversed ? -10 : 10;
+
+  // The bottom arm angle range from 30 to 150 degrees
+  if (btmAngle >= 150)
+    btmReversed = true;
+  if (btmAngle <= 30)
+    btmReversed = false;
+
+  // Set the angle of the shaft (in degrees), ranging from 0 to 180
+  //servoBtm.write(90);
+  servoBtm.write(btmAngle);
+}
+
+void updateColorSensor(){
+  // Get color measurement values
+  uint16_t r, g, b, c;
+  delay(100);  // takes 50ms to read
+  tcs.getRawData(&r, &g, &b, &c);
+
+  // If clear value is less than 300
+  if(c < 300 && !isColorBeingMeasured){
+    // This is when the color sensor sees into the hole
+
+    if (millis() - lastSkittleTime > 1000){
+      skittleCount ++;
+      Serial.println(millis() - lastSkittleTime);
+      lastSkittleTime = millis();
+
+      // Slow down the top servo's speed for better accuracy
+      topServoSpeed = 90;
+      Serial.println("Start measuring this Skittle's color.");
+      isColorBeingMeasured = true;
+    }
+
+  }
+
+  if(c < 300){
+    Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
+    Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
+    Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
+    Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
+    Serial.println(" ");
+
+    if (millis() - lastSkittleTime > 1000){
+      topServoSpeed = 0;
+      Serial.println("Finish measuring.");
+      isColorBeingMeasured = false;
+      lastSkittleTime = millis();
+
+    }
+  }
+
+/*
+  Serial.print("Color Temp: "); Serial.print(colorTemp, DEC); Serial.print(" K - ");
+  Serial.print("Lux: "); Serial.print(lux, DEC); Serial.print(" - ");
+  Serial.print("R: "); Serial.print(r, DEC); Serial.print(" ");
+  Serial.print("G: "); Serial.print(g, DEC); Serial.print(" ");
+  Serial.print("B: "); Serial.print(b, DEC); Serial.print(" ");
+  Serial.print("C: "); Serial.print(c, DEC); Serial.print(" ");
+  Serial.println(" ");
+*/
+
+
+
+}
+
+void loop() {
+ // static byte frames = 0;
+
+  lcd.clear();
+  lcd.print("Count: ");lcd.print(skittleCount, DEC);
+
+  // Update the top servo
+  //if(frames == 0)
+  updateTopServo();
+
+  // Update the bottom servo (arm)
+  //if(frames == 0)
+  //updateBtmServo();
+
+  // Update the color sensor
+  updateColorSensor();
+
+  // Because the color sensor needs to measure the color more frequently,
+  // instead of delaying the main loop, which will affect the color sensor's
+  // refresh rate, a new variable was introduced to control and manually
+  // delay certain components while keep the color sensor up and running.
+  //frames ++;
+}


ENH: Debounce on pedals, initial framework.

Debounce value likely will need further tweaking.

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

--- sketches/midi_organ_debounce/midi_organ_debounce.ino
+++ sketches/midi_organ_debounce/midi_organ_debounce.ino
@@ -0,0 +1,180 @@
+#include <midi_Defs.h>
+#include <midi_Namespace.h>
+#include <midi_Settings.h>
+#include <midi_Message.h>
+#include <MIDI.h>
+/*
+ Test serial-MIDI commands from a 61-key keyboard.
+
+ The circuit:
+ * Up to five OrganDuino 2.0 PCB shields populated with diodes
+ * 61-key organ manuals soldered in with buss soldered to a Drive Pin thru-hole
+ * Solder jumpers on back for each manual properly set
+ * 32-key AGO pedalboard soldered in to first
+
+ created 2016-2019 by @JDWarner and @mscross
+*/
+
+#define keyON 127
+#define keyOFF 0
+#define no false
+#define debounce_value 24
+
+// Initialize MIDI
+MIDI_CREATE_DEFAULT_INSTANCE();
+
+// constants won't change. They're used here to
+// set pin numbers for first 2 octaves
+const int keyPins[] = {28, 26, 24, 22, 13, 12, 11, 10, 9, 8, 7, 6, 14, 15, 16, 17, 18, 19, 20, 21, 27, 25, 23, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30,};
+const int pedalPins[] = {28, 26, 24, 22, 13, 12, 11, 10, 9, 8, 7, 6, 14, 15, 16, 17, 18, 19, 20, 21, 27, 25, 23, 29, 31, 33, 35, 37, 39, 41, 43, 45,};
+const int manualPins[] = {5, 4, 3, 2, 67, };  // drive wire(s) for manuals are: {5, 4, 3, 2, 67, }
+const int pedalPin = 69;  // drive wire for pedals is 69 with appropriate jumper
+/*
+  Note for reference, the analog -> digital pin mappings for the Mega are:
+  A0 = 54
+  A1 = 55
+  A2 = 56
+  A3 = 57
+  A4 = 58
+  A5 = 59
+  A6 = 60
+  A7 = 61
+  A8 = 62
+  A9 = 63
+  A10 = 64
+  A11 = 65
+  A12 = 66
+  A13 = 67
+  A14 = 68
+  A15 = 69
+*/
+
+// define how large some things are (matrix size)
+const int numKeys = 61;    // full organ manual, also length of keyPins and midiKeyNotes
+const int numPedals = 32;  // full AGO 32-key pedalboard
+const int numManuals = 5;  // number of manuals
+
+const unsigned char midiKeyNotes[numKeys] = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, };
+const unsigned char midiChannels[numManuals] = {1, 2, 3, 4, 5, };  // Five manuals in first 5 MIDI channels
+const unsigned char pedalChannel = 16;  // Pedals always channel 16
+
+// State of all keys in a 2D multidimensional array
+bool keyStates[numManuals][numKeys] = {
+  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
+  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
+  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
+  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
+  {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, },
+};
+
+// State of all pedals in a 1D array
+bool pedalStates[numPedals] = {no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, no, };
+unsigned char pedalDebounce[numPedals] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
+
+
+// Convenience func to convert a boolean to the proper MIDI key velocity
+int stateMIDIvalue(bool state) {
+  if (state == true) {
+    return keyON;
+  }
+  else {
+    return keyOFF;
+  }
+}
+
+
+// simple function to compare current state with new read
+// if different, state and LED are updated
+// We're using input_pullup so the switch is active when LOW!
+// Note: Internally changing `state` requires call-by-reference
+void keyChange(bool value, bool &state, int key, int channel) {
+  // Compare them - `state` records inverse of switch read
+  if (value == state) { // Equal means a change
+
+    // Update values in state record
+    state = not value;
+
+    // If there is a state change, send a MIDI event
+    MIDI.sendNoteOn(midiKeyNotes[key], stateMIDIvalue(state), channel);
+  }
+}
+
+// same function as above, but take into effect debounce.
+void keyChangeDebounce(bool value, bool &state, char &debounce, int key, int channel) {
+  // Compare them - `state` records inverse of switch read
+  if (value == state) { // Equal means a change
+
+    if (debounce == 0) { // Zero is no recent change, accept change
+      state = not value;
+      debounce = debounce_value;
+    }
+
+    // If there is a state change, send a MIDI event
+    MIDI.sendNoteOn(midiKeyNotes[key], stateMIDIvalue(state), channel);
+  }
+
+  // Decrement debounce every loop for every key, even if unchanged.
+  if (debounce != 0) {
+    --debounce;
+  }
+}
+
+// function to handle the loop over a given rank, updating states
+void keyPoll(bool (&states)[numKeys], int arraySize, int rank) {
+  for(int key=0; key<arraySize; key++){
+      // run through all switches, reading their values
+      // pass results to keyChange which will dispatch a MIDI event if needed
+      keyChange(digitalRead(keyPins[key]), states[key], key, midiChannels[rank]);
+  }
+}
+
+// function to loop over pedals
+void pedalPoll(bool (&states)[numPedals], char (&debounce)[numPedals], int arraySize, int pedalMidiChannel) {
+  for(int key=0; key<arraySize; key++){
+      // run through all switches, reading their values
+      // pass results to keyChange which will dispatch a MIDI event if needed
+      keyChangeDebounce(digitalRead(pedalPins[key]), states[key], debounce[key], key, pedalMidiChannel);
+  }
+}
+
+
+void setup() {
+  // Start the Serial interface
+  MIDI.begin(1);
+  Serial.begin(115200);
+
+  // drive pins per rank
+  for(int d=0; d<numManuals; d++){
+      pinMode(manualPins[d], OUTPUT);
+      digitalWrite(manualPins[d], HIGH);
+  }
+
+  // pedal pin
+  pinMode(pedalPin, OUTPUT);
+  digitalWrite(pedalPin, HIGH);
+
+  // initialize the organ keys' pins as inputs
+  for(int k=0; k<numKeys; k++){
+      pinMode(keyPins[k], INPUT_PULLUP);
+  }
+}
+
+
+void loop() {
+  // read manuals
+  for(int manual=0; manual<numManuals; manual++){
+      // pull the drive pin for this manual to GND
+      digitalWrite(manualPins[manual], LOW);
+
+      // poll all keys, sending MIDI events if warranted
+      keyPoll(keyStates[manual], numKeys, manual);
+
+      // return the drive pin to +5V (off)
+      digitalWrite(manualPins[manual], HIGH);
+  }
+
+  // read the pedals with debounce
+  digitalWrite(pedalPin, LOW);
+  pedalPoll(pedalStates, pedalDebounce, numPedals, pedalChannel);
+  digitalWrite(pedalPin, HIGH);
+}


Delete Controlupdate(Old).ino

Delete Controlupdate(Old).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/nitricx/Tank_Automation.git/'


Added arduino sketch for reading pressure switch

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

--- ardu.ino
+++ ardu.ino
@@ -0,0 +1,12 @@
+
+void setup () {
+  Serial.begin (115200);
+  pinMode (2, INPUT);
+}
+
+void loop () {
+  if (digitalRead (2)) {
+    Serial.println("");
+    delay (2000);
+  }
+}


Simple push example

Simple push example

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

--- examples/Widgets/PushNotification/SimplestPushNotification.ino
+++ examples/Widgets/PushNotification/SimplestPushNotification.ino
@@ -0,0 +1,49 @@
+/**************************************************************
+ * Blynk is a platform with iOS and Android apps to control
+ * Arduino, Raspberry Pi and the likes over the Internet.
+ * You can easily build graphic interfaces for all your
+ * projects by simply dragging and dropping widgets.
+ *
+ *   Downloads, docs, tutorials: http://www.blynk.cc
+ *   Blynk community:            http://community.blynk.cc
+ *   Social networks:            http://www.fb.com/blynkapp
+ *                               http://twitter.com/blynk_app
+ *
+ * Blynk library is licensed under MIT license
+ * This example code is in public domain.
+ *
+ **************************************************************
+ * Simple push notification example
+ *
+ * App dashboard setup:
+ *   Push widget
+ *
+ * When device connected to server - it sends push notification to your phone
+ *
+ **************************************************************/
+//#define BLYNK_DEBUG
+#define BLYNK_PRINT Serial
+#include <SPI.h>
+#include <Ethernet.h>
+#include <BlynkSimpleEthernet.h>
+
+// You should get Auth Token in the Blynk App.
+// Go to the Project Settings (nut icon).
+char auth[] = "YourAuthToken";
+
+void setup()
+{
+  Serial.begin(9600);
+  Blynk.begin(auth);
+  while (!Blynk.connect()) {
+    // Wait until connected
+  }
+
+  // Notify immediately on startup
+  Blynk.notify("Device started");
+}
+
+void loop()
+{
+  Blynk.run();
+}


New Example pinDefLatch

New Example pinDefLatch

demo showing momentary pushbutton acting as latching switch

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/'


adds analog in example

adds analog in example

error: pathspec 'arduino-cc3000/analog-in/analog-in.ino' did not match any file(s) known to git

--- arduino-cc3000/analog-in/analog-in.ino
+++ arduino-cc3000/analog-in/analog-in.ino
@@ -0,0 +1,173 @@
+/***************************************************
+  Adafruit MQTT Library CC3000 Example
+
+  Designed specifically to work with the Adafruit WiFi products:
+  ----> https://www.adafruit.com/products/1469
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried/Ladyada for Adafruit Industries.
+  Adafruit IO example additions by Todd Treece.
+  MIT license, all text above must be included in any redistribution
+ ****************************************************/
+#include <Adafruit_SleepyDog.h>
+#include <Adafruit_CC3000.h>
+#include <SPI.h>
+#include "utility/debug.h"
+#include "Adafruit_MQTT.h"
+#include "Adafruit_MQTT_CC3000.h"
+
+/****************************** Pins ******************************************/
+
+#define PHOTOCELL             0  // analog 0
+#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
+#define ADAFRUIT_CC3000_VBAT  5  // VBAT & CS can be any digital pins.
+#define ADAFRUIT_CC3000_CS    10
+// Use hardware SPI for the remaining pins
+// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
+
+/************************* WiFi Access Point *********************************/
+
+#define WLAN_SSID       "...your SSID..."  // can't be longer than 32 characters!
+#define WLAN_PASS       "...your password..."
+#define WLAN_SECURITY   WLAN_SEC_WPA2  // Can be: WLAN_SEC_UNSEC, WLAN_SEC_WEP,
+                                       //         WLAN_SEC_WPA or WLAN_SEC_WPA2
+
+/************************* Adafruit.io Setup *********************************/
+
+#define AIO_SERVER      "io.adafruit.com"
+#define AIO_SERVERPORT  1883
+#define AIO_USERNAME    "...your AIO username (see https://accounts.adafruit.com)..."
+#define AIO_KEY         "...your AIO key..."
+
+/************ Global State (you don't need to change this!) ******************/
+
+// Setup the main CC3000 class, just like a normal CC3000 sketch.
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT);
+
+// Store the MQTT server, client ID, username, and password in flash memory.
+// This is required for using the Adafruit MQTT library.
+const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
+// Set a unique MQTT client ID using the AIO key + the date and time the sketch
+// was compiled (so this should be unique across multiple devices for a user,
+// alternatively you can manually set this to a GUID or other random value).
+const char MQTT_CLIENTID[] PROGMEM  = AIO_KEY __DATE__ __TIME__;
+const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
+const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;
+
+// Setup the CC3000 MQTT class by passing in the CC3000 class and MQTT server and login details.
+Adafruit_MQTT_CC3000 mqtt(&cc3000, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);
+
+// You don't need to change anything below this line!
+#define halt(s) { Serial.println(F( s )); while(1);  }
+
+// CC3000connect is a helper function that sets up the CC3000 and connects to
+// the WiFi network. See the cc3000helper.cpp tab above for the source!
+boolean CC3000connect(const char* wlan_ssid, const char* wlan_pass, uint8_t wlan_security);
+
+/****************************** Feeds ***************************************/
+
+// Setup a feed called 'photocell' for subscribing to changes.
+// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
+const char PHOTOCELL_FEED[] PROGMEM = AIO_USERNAME "/feeds/photocell";
+Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED);
+
+/*************************** Sketch Code ************************************/
+
+// photocell state
+int current = 0;
+int last = -1;
+
+void setup() {
+
+  Serial.begin(115200);
+
+  Serial.println(F("Adafruit IO Example:"));
+  Serial.print(F("Free RAM: ")); Serial.println(getFreeRam(), DEC);
+
+  // Initialise the CC3000 module
+  Serial.print(F("\nInit the CC3000..."));
+  if (! cc3000.begin())
+    halt("Failed");
+
+  // attempt wifi connection
+  while (! CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Retrying WiFi"));
+    while(1);
+  }
+  Serial.println(F("Connected to WiFi!"));
+
+  // connect to adafruit io
+  connect();
+
+}
+
+void loop() {
+
+  // Make sure to reset watchdog every loop iteration!
+  Watchdog.reset();
+
+  // ping adafruit io a few times to make sure we remain connected
+  if(! mqtt.ping(3)) {
+    // reconnect to adafruit io
+    if(! mqtt.connected())
+      connect();
+  }
+
+  // grab the current state of the photocell
+  current = analogRead(PHOTOCELL);
+
+  // return if the value hasn't changed
+  if(current == last)
+    return;
+
+  // Now we can publish stuff!
+  Serial.print(F("\nSending photocell value: "));
+  Serial.print(current);
+  Serial.print("... ");
+
+  if (! photocell.publish(current))
+    Serial.println(F("Failed."));
+  else
+    Serial.println(F("Success!"));
+
+  // save the photocell state
+  last = current;
+
+}
+
+// connect to adafruit io via MQTT
+void connect() {
+
+  Serial.print(F("Connecting to Adafruit IO... "));
+
+  int8_t ret;
+
+  while ((ret = mqtt.connect()) != 0) {
+
+    switch (ret) {
+      case 1: Serial.println(F("Wrong protocol")); break;
+      case 2: Serial.println(F("ID rejected")); break;
+      case 3: Serial.println(F("Server unavail")); break;
+      case 4: Serial.println(F("Bad user/pass")); break;
+      case 5: Serial.println(F("Not authed")); break;
+      case 6: Serial.println(F("Failed to subscribe")); break;
+      default:
+        Serial.println(F("Connection failed"));
+        CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
+        break;
+    }
+
+    if(ret >= 0)
+      mqtt.disconnect();
+
+    Serial.println(F("Retrying connection..."));
+    delay(5000);
+
+  }
+
+  Serial.println(F("Adafruit IO Connected!"));
+
+}


Added spark-ring.ino sketch

Added spark-ring.ino sketch

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

--- spark-ring.ino
+++ spark-ring.ino
@@ -0,0 +1,274 @@
+/*-------------------------------------------------------------------------
+
+  Spark Core sketch to control a NeoPixel 24 RGB LED ring: https://www.adafruit.com/product/1586
+  Written by Jason Coon, based on:
+
+  Spark Core library to control WS2811/WS2812 based RGB
+  LED devices such as Adafruit NeoPixel strips.
+  Currently handles 800 KHz and 400kHz bitstream on Spark Core,
+  WS2812, WS2812B and WS2811.
+
+  Also supports:
+  - Radio Shack Tri-Color Strip with TM1803 controller 400kHz bitstream.
+  - TM1829 pixels
+
+  PLEASE NOTE that the NeoPixels require 5V level inputs
+  and the Spark Core only has 3.3V level outputs. Level shifting is
+  necessary, but will require a fast device such as one of the following:
+
+  [SN74HCT125N]
+  http://www.digikey.com/product-detail/en/SN74HCT125N/296-8386-5-ND/376860
+
+  [SN74HCT245N]
+  http://www.digikey.com/product-detail/en/SN74HCT245N/296-1612-5-ND/277258
+
+  Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
+  Modified to work with Spark Core by Technobly.
+  Contributions by PJRC and other members of the open source community.
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing products
+  from Adafruit!
+  --------------------------------------------------------------------*/
+
+/* ======================= includes ================================= */
+
+#include "application.h"
+//#include "spark_disable_wlan.h" (for faster local debugging only)
+#include "neopixel/neopixel.h"
+
+/* ======================= prototypes =============================== */
+
+void colorAll(uint32_t c, uint8_t wait);
+void colorWipe(uint32_t c, uint8_t wait);
+void rainbow(uint8_t wait);
+void rainbowCycle(uint8_t wait);
+uint32_t Wheel(byte WheelPos);
+
+/* ======================= extra-examples.cpp ======================== */
+
+// IMPORTANT: Set pixel COUNT, PIN and TYPE
+#define PIXEL_COUNT 24
+#define PIXEL_PIN D2
+#define PIXEL_TYPE WS2812B
+
+// Parameter 1 = number of pixels in strip
+// Parameter 2 = pin number (most are valid)
+//               note: if not specified, D2 is selected for you.
+// Parameter 3 = pixel type [ WS2812, WS2812B, WS2811, TM1803 ]
+//               note: if not specified, WS2812B is selected for you.
+//               note: RGB order is automatically applied to WS2811,
+//                     WS2812/WS2812B/TM1803 is GRB order.
+//
+// 800 KHz bitstream 800 KHz bitstream (most NeoPixel products ...
+//                         ... WS2812 (6-pin part)/WS2812B (4-pin part) )
+//
+// 400 KHz bitstream (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
+//                   (Radio Shack Tri-Color LED Strip - TM1803 driver
+//                    NOTE: RS Tri-Color LED's are grouped in sets of 3)
+
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
+
+// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
+// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
+// and minimize distance between Arduino and first pixel.  Avoid connecting
+// on a live circuit...if you must, connect GND first.
+
+int brightness = 64;
+int patternCount = 6;
+int patternIndex = 4;
+char patternName[32] = "Rainbow Cycle";
+int power = 1;
+
+int setPower(String args) {
+    power = args.toInt();
+    if(power < 0)
+        power = 0;
+    else if (power > 1)
+        power = 1;
+
+    return power;
+}
+
+int setBrightness(String args)
+{
+    brightness = args.toInt();
+    if(brightness < 0)
+        brightness = 0;
+    else if(brightness > 255)
+        brightness = 255;
+
+    strip.setBrightness(brightness);
+    strip.show();
+    return brightness;
+}
+
+int setPatternIndex(String args)
+{
+    patternIndex = args.toInt();
+    if(patternIndex < 0)
+        patternIndex = 0;
+    else if (patternIndex >= patternCount)
+        patternIndex = patternCount - 1;
+
+    return patternIndex;
+}
+
+int setPatternName(String args)
+{
+    int pattern = args.toInt();
+    if(pattern < 0)
+        pattern = 0;
+    else if (pattern >= patternCount)
+        pattern = patternCount - 1;
+
+    switch(pattern)
+    {
+        case 0:
+        strcpy(patternName, "Color Wipe Red");
+        break;
+
+        case 1:
+        strcpy(patternName, "Color Wipe Green");
+        break;
+
+        case 2:
+        strcpy(patternName, "Color Wipe Blue");
+        break;
+
+        case 3:
+        strcpy(patternName, "Rainbow Cycle");
+        break;
+
+        case 4:
+        default:
+        strcpy(patternName, "Rainbow Spin");
+        break;
+
+        case 5:
+        strcpy(patternName, "Color All Magenta");
+        break;
+  }
+
+    return pattern;
+}
+
+void setup() {
+    Spark.function("power", setPower);
+    Spark.function("brightness", setBrightness);
+    Spark.function("patternIndex", setPatternIndex);
+    Spark.function("patternName", setPatternName);
+
+    Spark.variable("power", &power, INT);
+    Spark.variable("brightness", &brightness, INT);
+    Spark.variable("patternCount", &patternCount, INT);
+    Spark.variable("patternIndex", &patternIndex, INT);
+    Spark.variable("patternName", patternName, STRING);
+
+    strip.begin();
+    strip.setBrightness(64);
+    strip.show(); // Initialize all pixels to 'off'
+}
+
+void loop() {
+  // Some example procedures showing how to display to the pixels:
+  // Do not run more than one of these at a time, or the b/g tasks
+  // will be blocked.
+  //--------------------------------------------------------------
+
+  //strip.setPixelColor(0, strip.Color(255, 0, 255));
+  //strip.show();
+
+  if(power < 1) {
+      colorAll(strip.Color(0, 0, 0), 0); // Black
+      delay(250);
+      return;
+  }
+
+  switch(patternIndex)
+  {
+      case 0:
+      colorWipe(strip.Color(255, 0, 0), 50); // Red
+      break;
+
+      case 1:
+      colorWipe(strip.Color(0, 255, 0), 50); // Green
+      break;
+
+      case 2:
+      colorWipe(strip.Color(0, 0, 255), 50); // Blue
+      break;
+
+      case 3:
+      rainbowCycle(20);
+      break;
+
+      case 4:
+      default:
+      rainbowSpin(20);
+      break;
+
+      case 5:
+      colorAll(strip.Color(0, 255, 255), 50); // Magenta
+      break;
+  }
+}
+
+// Set all pixels in the strip to a solid color, then wait (ms)
+void colorAll(uint32_t c, uint8_t wait) {
+  uint16_t i;
+
+  for(i=0; i<strip.numPixels(); i++) {
+    strip.setPixelColor(i, c);
+  }
+  strip.show();
+  delay(wait);
+}
+
+// Fill the dots one after the other with a color, wait (ms) after each one
+void colorWipe(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<strip.numPixels(); i++) {
+    strip.setPixelColor(i, c);
+    strip.show();
+    delay(wait);
+  }
+}
+
+void rainbowCycle(uint8_t wait) {
+  uint16_t i, j;
+
+  for(j=0; j<256; j++) {
+    for(i=0; i<strip.numPixels(); i++) {
+      strip.setPixelColor(i, Wheel((i+j) & 255));
+    }
+    strip.show();
+    delay(wait);
+  }
+}
+
+// Slightly different, this makes the rainbow equally distributed throughout, then wait (ms)
+void rainbowSpin(uint8_t wait) {
+  uint16_t i, j;
+
+  for(j=0; j<256; j++) { // 1 cycle of all colors on wheel
+    for(i=0; i< strip.numPixels(); i++) {
+      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
+    }
+    strip.show();
+    delay(wait);
+  }
+}
+
+// Input a value 0 to 255 to get a color value.
+// The colours are a transition r - g - b - back to r.
+uint32_t Wheel(byte WheelPos) {
+  if(WheelPos < 85) {
+   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
+  } else if(WheelPos < 170) {
+   WheelPos -= 85;
+   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
+  } else {
+   WheelPos -= 170;
+   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
+  }
+}


Update sensorScript variables to reflect led instead of buzzer

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/onordbo/mood-cloud.git/'


Create StandardFirmataChipKITledstrip.ino

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

--- arduino/StandardFirmataChipKITledstrip/StandardFirmataChipKITledstrip.ino
+++ arduino/StandardFirmataChipKITledstrip/StandardFirmataChipKITledstrip.ino
@@ -0,0 +1,851 @@
+
+/*
+  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.
+  Copyright (C) 2016 Rick Anderson. 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 <Adafruit_DotStar.h>
+
+#include <SoftPWMServo.h>  // Gives us PWM and Servo on every pin
+#include <Wire.h>
+#include <Firmata.h>
+
+#define CK_COMMAND 0x40
+#define CK_PIXEL_SET 0x10
+#define CK_PIXEL_SHOW 0x11
+#define CK_PIXEL_CLEAR 0x12
+#define CK_PIXEL_BRIGHTNESS 0x13
+#define CK_PIXEL_ALERT_HIGH 0x14
+#define CK_PIXEL_ALERT_LOW 0x15
+
+#define NUMPIXELS 30 // Number of LEDs in strip
+#define RED  0xFF0000
+#define GREEN  0x00FF00
+#define BLUE  0x0000FF
+#define ICEBLUE 0x000055
+
+#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,  DOTSTAR_BGR);
+//Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, 18, 3  ,DOTSTAR_BGR);
+
+
+/* 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);
+}
+
+//----------------------------------
+/*
+   contact DOTSTAR strip
+   goup the dotstar functions to act as a callback from firmata commands
+*/
+void dotstarHello() {
+  strip.clear();
+  uint32_t frame[NUMPIXELS];
+  for (int ii = 0; ii < NUMPIXELS; ii++) {
+    frame[ii] = BLUE; //initialize all to BLUE
+    strip.setPixelColor(ii, frame[ii]);
+  }
+  strip.show();
+}
+void dotstarAlertHigh() {
+  strip.clear();
+  uint32_t frame[NUMPIXELS];
+  for (int ii = 0; ii < NUMPIXELS; ii++) {
+    frame[ii] = RED; //initialize all to RED
+    strip.setPixelColor(ii, frame[ii]);
+  }
+  strip.show();
+}
+void dotstarAlertLow() {
+  strip.clear();
+  uint32_t frame[NUMPIXELS];
+  for (int ii = 0; ii < NUMPIXELS; ii++) {
+    frame[ii] = ICEBLUE; //initialize all to ICEBLUE
+    strip.setPixelColor(ii, frame[ii]);
+  }
+  strip.show();
+}
+
+
+// -----------------------------------------------------------------------------
+/* 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);
+        }
+      }
+    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
+}
+
+
+void ckCommand(byte command, byte argc, byte* argv) {
+  switch (command) {
+    case CK_PIXEL_CLEAR:
+      strip.clear();
+      //strip.setPixelColor(11, 0xFFFFFF);
+      break;
+    case CK_PIXEL_SHOW:
+      //strip.setPixelColor(12, 0xFFFFFF);
+      strip.show();
+      break;
+    case CK_PIXEL_SET:
+      //strip.setPixelColor(10, 0xFFFFFF);
+      //strip.show();
+      // This code is directly from the CircuitPlayground
+      // Set a NeoPixel to the specified RGB color.
+      // Expect: 1 byte pixel number, 4 bytes pixel RGB value (as 7-bit bytes)
+
+      if (argc >= 5) {
+        // Parse out the pixel number and R, G, B bytes.
+        uint8_t pixel = argv[0] & 0x7F;
+        uint8_t r = (argv[1] << 1) | ((argv[2] & 0x7F) >> 6);  // Red = 7 bits from byte 4 and 1 bit from byte 5
+        uint8_t g = ((argv[2] & 0x3F) << 2) | (((argv[3]) & 0x7F) >> 5);  // Green = 6 bits from byte 5 and 2 bits from byte 6
+        uint8_t b = ((argv[3] & 0x1F) << 3) | (((argv[4]) & 0x7F) >> 4);  // Blue = 5 bits from byte 6 and 3 bits from byte 7
+        strip.setPixelColor(pixel, r, g, b);
+      }
+      break;
+    case CK_PIXEL_BRIGHTNESS:
+      uint8_t data;
+      data = argv[0] & 0x7F;
+      strip.setBrightness(data);
+      break;
+    case CK_PIXEL_ALERT_LOW:
+      dotstarAlertLow();
+      break;
+    case CK_PIXEL_ALERT_HIGH:
+      dotstarAlertHigh();
+      break;
+  }
+}
+
+void printPixels(int cc) {
+  for (int ii = 0; ii < cc; ii++)
+  {
+    //count argc in pixels
+    strip.setPixelColor(ii, 0x00FF00);
+  }
+  strip.show();
+}
+/*==============================================================================
+   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 CK_COMMAND:
+      if (argc < 1) {
+        dotstarHello();
+        return;
+      }
+      //   printPixels(argc);
+      ckCommand(argv[0], argc - 1, argv + 1);
+      break;
+    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
+  strip.begin();
+}
+
+/*==============================================================================
+   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);
+      }
+    }
+  }
+}


initial

initial

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

--- SimpleClientDHTSSL.ino
+++ SimpleClientDHTSSL.ino
@@ -0,0 +1,321 @@
+/* WeMos DHT Server
+ *
+ * Connect to WiFi and respond to http requests with temperature and humidity
+ *
+ * Based on Adafruit ESP8266 Temperature / Humidity Webserver
+ * https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver
+ *
+ * Depends on Adafruit DHT Arduino library
+ * https://github.com/adafruit/DHT-sensor-library
+ */
+
+#include <ESP8266WiFi.h>
+#include <WiFiClientSecure.h>
+#include <DHT.h>
+
+#define DHTTYPE DHT22   // DHT Shield uses DHT 11
+#define DHTPIN D4       // DHT Shield uses pin D4
+
+//const char* DEVNAME = "VCW100” ; const char* ISSUEID  = “ZGKL01”; const char* ssid = ""; const char* password = “”;
+
+
+IPAddress server(120,138,27,109);
+
+// Initialize DHT sensor
+// Note that older versions of this library took an optional third parameter to
+// tweak the timings for faster processors.  This parameter is no longer needed
+// as the current DHT reading algorithm adjusts itself to work on faster procs.
+DHT dht(DHTPIN, DHTTYPE);
+
+float humidity, temperature;                 // Raw float values from the sensor
+char str_humidity[10], str_temperature[10];  // Rounded sensor values and as strings
+
+// Generally, you should use "unsigned long" for variables that hold time
+unsigned long previousMillis = 0;            // When the sensor was last read
+const long interval = 5000;                  // Wait this long until reading again
+unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
+enum WiFiStateEnum { DOWN, STARTING, UP }    ;
+WiFiStateEnum WiFiState = DOWN;
+unsigned long WiFiStartTime = 0;
+
+void read_sensor() {
+  // Wait at least 2 seconds seconds between measurements.
+  // If the difference between the current time and last time you read
+  // the sensor is bigger than the interval you set, read the sensor.
+  // Works better than delay for things happening elsewhere also.
+  unsigned long currentMillis = millis();
+
+  if (currentMillis - previousMillis >= interval) {
+    // Save the last time you read the sensor
+    previousMillis = currentMillis;
+
+    // Reading temperature and humidity takes about 250 milliseconds!
+    // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
+    humidity = dht.readHumidity();        // Read humidity as a percent
+    temperature = dht.readTemperature();  // Read temperature as Celsius
+
+    // Check if any reads failed and exit early (to try again).
+    if (isnan(humidity) || isnan(temperature)) {
+      Serial.println("Failed to read from DHT sensor!");
+      return;
+    }
+
+    // Convert the floats to strings and round to 2 decimal places
+    dtostrf(humidity, 1, 2, str_humidity);
+    dtostrf(temperature, 1, 2, str_temperature);
+
+    Serial.print("Humidity: ");
+    Serial.print(str_humidity);
+    Serial.print(" %\t");
+    Serial.print("Temperature: ");
+    Serial.print(str_temperature);
+    Serial.println(" °C");
+  }
+}
+
+void WiFiEvent(WiFiEvent_t event) {
+    Serial.printf("[WiFi-event] event: %d\n", event);
+
+    switch(event) {
+        case WIFI_EVENT_STAMODE_GOT_IP:
+            Serial.println("WiFi connected");
+            Serial.println("IP address: ");
+            Serial.println(WiFi.localIP());
+            WiFiState = UP;
+            break;
+        case WIFI_EVENT_STAMODE_DISCONNECTED:
+            WiFiState = DOWN;
+            Serial.println("WiFi lost connection");
+            break;
+    }
+}
+
+void WifiTryUp() {
+    // delete old config
+
+    WiFi.disconnect(true);
+
+    delay(1000);
+
+
+
+    WiFi.begin(ssid, password);
+
+    Serial.println();
+    Serial.println();
+    Serial.println("Wait for WiFi... ");
+
+}
+
+
+unsigned long _ESP_id;
+void setup(void)
+{
+  // Open the Arduino IDE Serial Monitor to see what the code is doing
+  Serial.begin(115200);
+  dht.begin();
+
+  Serial.println("WeMos DHT Server");
+  _ESP_id = ESP.getChipId();  // uint32 -> unsigned long on arduino
+  Serial.println(_ESP_id,HEX);
+  Serial.println("");
+
+  WiFi.onEvent(WiFiEvent);
+
+  // Initial read
+  read_sensor();
+
+}
+
+void loop(void)
+{
+  delay(60000);
+  read_sensor();
+
+  if (WiFiState == UP) { httpsRequest(temperature,humidity); }
+
+  // Connect to your WiFi network
+  if (WiFiState == DOWN) {
+    WifiTryUp();
+    WiFiState = STARTING;
+    WiFiStartTime = millis();
+  }
+  if (WiFiState == STARTING) {
+    if (millis() - WiFiStartTime > 120000) { WiFiState = DOWN; Serial.println("WiFi Connect Timeout"); }
+  }
+
+
+}
+
+
+
+
+// this method makes a HTTP connection to the server:
+void httpRequest(float temp, float humid) {
+
+  // Use WiFiClient class to create TCP connections
+  WiFiClient client;
+  const int httpPort = 80;
+  if (!client.connect(server, httpPort)) {
+    Serial.println("connection failed");
+    return;
+  }
+
+  String url = "/updateweatherstation.php?action=updateraw";
+  url += "&devid=";
+  url += String(_ESP_id,HEX);
+  url += "&devname=";
+  url += DEVNAME;
+  url += "&issueid=";
+  url += ISSUEID;
+  url += "&dateutc=now&indoortemp=";
+  url += temp;
+  url += "&indoorhumidity=";
+  url += humid;
+
+
+  Serial.print("Requesting URL: ");
+  Serial.println(url);
+
+  // This will send the request to the server
+  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
+               "Host: " + "www.shac.org.nz" + "\r\n" +
+               "Connection: close\r\n\r\n");
+  unsigned long timeout = millis();
+  while (client.available() == 0) {
+    delay(10);
+    if (millis() - timeout > 5000) {
+      Serial.println(">>> Client Timeout !");
+      client.stop();
+      return;
+    }
+  }
+
+  // Read all the lines of the reply from server and print them to Serial
+  while(client.available()){
+    String line = client.readStringUntil('\r');
+    Serial.print(line);
+  }
+
+  Serial.println();
+  Serial.println("closing connection");
+
+    // note the time that the connection was made:
+  lastConnectionTime = millis();
+
+}
+
+
+
+// Use web browser to view and copy
+// SHA1 fingerprint of the certificate
+const char* fingerprint = "CF 05 98 89 CA FF 8E D8 5E 5C E0 C2 E4 F7 E6 C3 C7 50 DD 5C";
+
+// this method makes a HTTP connection to the server:
+void httpsRequest(float temp, float humid) {
+
+  // Use WiFiClientSecure class to create TLS connection
+  WiFiClientSecure client;
+  Serial.print("connecting HTTPS ");
+  Serial.println(server);
+  if (!client.connect(server, 443)) {
+    Serial.println("connection failed");
+    return;
+  }
+
+  if (client.verify(fingerprint, "www.shac.org.nz")) {
+    Serial.println("certificate matches");
+  } else {
+    Serial.println("certificate doesn't match");
+  }
+
+ // We now create a URI for the request
+  String url = "/updateweatherstation.php?action=updateraw";
+  url += "&devid=";
+  url += String(_ESP_id,HEX);
+  url += "&devname=";
+  url += DEVNAME;
+  url += "&issueid=";
+  url += ISSUEID;
+  url += "&dateutc=now&indoortemp=";
+  url += temp;
+  url += "&indoorhumidity=";
+  url += humid;
+
+
+
+  Serial.print("Requesting URL: ");
+  Serial.println(url);
+
+  // This will send the request to the server
+  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
+               "Host: " + "www.shac.org.nz" + "\r\n" +
+               "User-Agent: indoor-wx-v0.1" + "\r\n" +
+               "Connection: close\r\n\r\n");
+
+  Serial.println("request sent");
+
+  //delay(100);
+
+/*
+  Serial.print("01"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("02"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("03"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("04"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("05"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("06"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("07"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("08"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("09"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("10"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("11"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("12"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("13"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("14"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("15"); Serial.println(client.readStringUntil('\n'));
+  Serial.print("16"); Serial.println(client.readStringUntil('\n'));
+*/
+
+
+
+  unsigned long _timeout = 1000;
+  unsigned long _startMillis = millis();
+  //while (client.connected()) {     // client.connected seems to not always work! - returns FALSE at this point sometimes.
+
+  while (millis() - _startMillis < _timeout) {
+    String line = client.readStringUntil('\n');
+    yield();
+    Serial.print("Header Line: ");
+    Serial.println(line);
+    if (line == String("\r") ) {
+      Serial.println("headers received");
+      break;
+    }
+  }
+
+  while (client.connected()) {
+    String line = client.readStringUntil('\n');
+    yield();
+    if (line.startsWith("GMT:")) {
+      Serial.print("Got GMT: ");
+      Serial.println(line);
+    } else {
+      Serial.print("Body Line: ");
+      Serial.println(line);
+    }
+  }
+
+
+  Serial.println("Finished");
+  // read until return -1?????
+  //while (client.read() >= 0) {Serial.print("."); }
+
+  //Serial.println("reply was:");
+  //Serial.println("==========");
+  //Serial.println(line);
+  //Serial.println("==========");
+  //Serial.println("closing connection");
+
+
+}
+


daily tuning for today's leaderboard

daily tuning for today's leaderboard

error: pathspec 'exploration' did not match any file(s) known to git
error: pathspec 'use' did not match any file(s) known to git
error: pathspec 'IR' did not match any file(s) known to git
error: pathspec 'sensor' did not match any file(s) known to git
error: pathspec 'to' did not match any file(s) known to git
error: pathspec 'turn/src/main.ino' did not match any file(s) known to git


Create simplificado_230520171205_FUNCIONA_CORRECTAMENTE.ino

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

--- simplificado_230520171205_FUNCIONA_CORRECTAMENTE.ino
+++ simplificado_230520171205_FUNCIONA_CORRECTAMENTE.ino
@@ -0,0 +1,455 @@
+/*
+   *********  AUTOR: ALIENNEO  *********
+   *********  DATE: 07/05/2013  ********
+   ***********  VERSION: 1.1  **********
+*/
+#include <Wire.h>
+#define MPU 0x68
+#define A_R 16384.0
+#define G_R 131.0
+#define RAD_A_DEG = 57.295779
+
+
+#define BAUDIOS  9600
+
+
+
+#define LIMITE_ANGULO_OBJETIVO    3  //12
+
+#define MAX_CONTROL_SALIDA        200  //500 maximo de velocidad de salida
+#define MAXIMA_ACELERACION         6 // MAX RECOMMENDED VALUE: 8) (default:7)
+#define ITERM_MAX_ERROR           25  // Iterm windup constants for PI control //40
+#define ITERM_MAX                 8000  // 5000
+
+#define MICROSTEPPING             16  // 8 or 16 for 1/8 or 1/16 driver microstepping (default:16)
+
+//
+#define CLR(x,y) (x&=(~(1<<y)))
+#define SET(x,y) (x|=(1<<y))
+
+#define ZERO_SPEED 65535  //  65535 se trata de la frecuencia máxima en 8bits
+
+// Default control terms
+#define KP 0.20
+#define KD 20
+#define KP_THROTTLE 0.07
+#define KI_THROTTLE 0.04
+
+
+bool Robot_tumbado = false;           // Robot tumbado flag => Out of
+int16_t AcX, AcY, AcZ, GyX, GyY, GyZ;
+float Acc[2];
+float Gy[2];
+float Angle[2];
+long tiempo_antiguo;
+long tiempo_valor;
+float dt;
+float angulo_recogido;
+float angulo_recogido_antiguo;
+float PID_errorSuma;
+float PID_errorAntiguo = 0;
+float PID_errorAntiguo2 = 0;
+float setPointAntiguo = 0;
+float angulo_objetivo;
+float acelerador;
+float direccion;
+float control_salida;
+
+
+int16_t motor_A;
+int16_t motor_B;
+
+
+int16_t velocidad_Motor_A;
+int16_t velocidad_Motor_B;
+uint8_t loop_counter;
+uint8_t slow_loop_counter;
+
+float Kp = KP;
+float Kd = KD;
+float Kp_thr = KP_THROTTLE;
+float Ki_thr = KI_THROTTLE;
+float Kp_user = KP;
+float Kd_user = KD;
+float Kp_thr_user = KP_THROTTLE;
+float Ki_thr_user = KI_THROTTLE;
+
+
+int8_t  dir_Motor_A;
+int8_t  dir_Motor_B;          // Actual direction of steppers motors
+int16_t actual_robot_velocidad;
+int16_t actual_robot_velocidad_antiguo;
+float velocidad_estimada_filtered;    // Estimated robot velocidad
+
+
+
+
+//// 16 single cycle instructions = 1us at 16Mhz
+void delay_1us()
+{
+  __asm__ __volatile__ (
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop" "\n\t"
+    "nop");
+}
+
+/***********       SETUP        ************* */
+void setup() {
+
+
+  pinMode(8, OUTPUT); // DIR MOTOR_A PORTB,4
+  pinMode(11, OUTPUT); // STEP MOTOR_A  PORTB,7
+  pinMode(7, OUTPUT); // DIR MOTOR_B PORTE,6
+  pinMode(6, OUTPUT); // STEP MOTOR_B  PORTD,7
+
+  pinMode(9, OUTPUT); // ENABLE MOTORS
+
+  digitalWrite(9, HIGH);  // HIGH Deshabilitar motores
+
+  Wire.begin();
+  Wire.beginTransmission(MPU);
+  Wire.write(0x6B);
+  Wire.write(0);
+  Wire.endTransmission(true);
+
+  Serial.begin(BAUDIOS); // Serial salida to console
+
+  Serial.println("Rob-Bat by Alienneo v.1.1");
+  Serial.println("Iniciando...");
+
+  // Gyro calibration
+  // The robot must be steady during initialization
+  delay(500);
+  Serial.println("Gyro calibracion!!  No mover en 10 segundos... ");
+  delay(500);
+
+  Serial.println("Iniciando motores...");
+
+  //******************************************************
+  cli();
+  TCCR1A = 0;                                              // Timer1 CTC mode 4
+  TCCR1B = (1 << WGM12) | (1 << CS11);                     // Prescaler=256
+  OCR1A = ZERO_SPEED;                                             // Motor parado
+  TCNT1 = 0;
+
+  TCCR3A = 0;                                     // Timer2 CTC mode 4
+  TCCR3B = (1 << WGM32) | (1 << CS31);                     // Prescaler=256
+  OCR3A = ZERO_SPEED;                                             // Motor parado
+  TCNT3 = 0;
+
+
+  TIMSK1 |= (1 << OCIE1A);
+  TIMSK3 |= (1 << OCIE3A);
+  sei();
+
+  //pequeña vibracion en los motores para comprobar que estan preparados
+  for (uint8_t k = 0; k < 5; k++) {
+    setSpeed_Motor_A(5);
+    setSpeed_Motor_B(-5);
+    delay(200);
+    setSpeed_Motor_A(-5);
+    setSpeed_Motor_B(5);
+    delay(200);
+
+  }
+  setSpeed_Motor_A(0);
+  setSpeed_Motor_B(0);
+
+
+}  /*   ************ FINAL SETUP *************** */
+
+
+/* ************  LOOP   ***************** */
+void loop() {
+  tiempo_valor=millis();
+  /* ************   DATOS DEL ACELEROMETRO/GIROSCOPIO *********************** */
+  Wire.beginTransmission(MPU);
+  Wire.write(0x3B);
+  Wire.endTransmission(false);
+  Wire.requestFrom(MPU, 6, true);
+  AcX = Wire.read() << 8 | Wire.read();
+  AcY = Wire.read() << 8 | Wire.read();
+  AcZ = Wire.read() << 8 | Wire.read();
+  Acc[1] = atan(-1 * (AcX / A_R) / sqrt(pow((AcY / A_R), 2) + pow((AcZ / A_R), 2))) * RAD_TO_DEG;
+  Acc[0] = atan((AcY / A_R) / sqrt(pow((AcX / A_R), 2) + pow((AcZ / A_R), 2))) * RAD_TO_DEG;
+  Wire.beginTransmission(MPU);
+  Wire.write(0x43);
+  Wire.endTransmission(false);
+  Wire.requestFrom(MPU, 4, true);
+  GyX = Wire.read() << 8 | Wire.read();
+  GyY = Wire.read() << 8 | Wire.read();
+  Gy[0] = GyX / G_R;
+  Gy[1] = GyY / G_R;
+  Angle[0] = 0.98 * (Angle[0] + Gy[0] * 0.010) + 0.02 * Acc[0];
+  Angle[1] = 0.98 * (Angle[1] + Gy[1] * 0.010) + 0.02 * Acc[1];
+  //Serial.print("Angle X: "); Serial.print(Angle[0]); Serial.print("\n");
+  //Serial.print("Angle Y: "); Serial.println(Angle[1]);  // Angulo necesario
+  delay(2);
+
+
+
+
+  loop_counter++;
+  slow_loop_counter++;
+  dt = (tiempo_valor - tiempo_antiguo);
+  tiempo_antiguo = tiempo_valor;
+
+  angulo_recogido_antiguo = angulo_recogido;
+
+  angulo_recogido = Angle[1];
+
+  //Serial.println(angulo_recogido);
+
+
+  // We calculate the estimated robot speed:
+  // Estimated_Speed = angular_velocity_of_stepper_motors(combined) - angular_velocity_of_robot(angle measured by IMU)
+  actual_robot_velocidad_antiguo = actual_robot_velocidad;
+  actual_robot_velocidad = (velocidad_Motor_A + velocidad_Motor_B) / 2; // Positive: forward
+
+  int16_t velocidad_angular = (angulo_recogido - angulo_recogido_antiguo) * 90.0; // 90 is an empirical extracted factor to adjust for real units
+  int16_t velocidad_estimada = -actual_robot_velocidad_antiguo - velocidad_angular;     // We use robot_speed(t-1) or (t-2) to compensate the delay
+  velocidad_estimada_filtered = velocidad_estimada_filtered * 0.95 + (float)velocidad_estimada * 0.05;  // low pass filter on estimated speed
+
+  angulo_objetivo = controlVelocidadPI(dt, velocidad_estimada_filtered, acelerador, Kp_thr, Ki_thr);
+  angulo_objetivo = constrain(angulo_objetivo, -LIMITE_ANGULO_OBJETIVO, LIMITE_ANGULO_OBJETIVO); // limited outpu
+
+
+
+  control_salida += controlEstabilidadPD(dt, angulo_recogido, angulo_objetivo, Kp, Kd);
+ control_salida = constrain(control_salida, -MAX_CONTROL_SALIDA, MAX_CONTROL_SALIDA); // Limit max output from control
+
+  // The steering part from the user is injected directly on the output
+  motor_A = control_salida + direccion;
+  motor_B = control_salida - direccion;
+
+  // Limit max speed (control output)
+  motor_A = constrain(motor_A, -MAX_CONTROL_SALIDA, MAX_CONTROL_SALIDA);
+  motor_B = constrain(motor_B, -MAX_CONTROL_SALIDA, MAX_CONTROL_SALIDA);
+
+
+  if ((angulo_recogido < 76) && (angulo_recogido > -76)) // Is robot ready (upright?)
+  {
+    // NORMAL MODE
+    digitalWrite(9, LOW);  // Motors enable
+    setSpeed_Motor_A(-motor_A);
+    setSpeed_Motor_B(motor_B);
+
+  }
+
+
+//Serial.print(",");
+Serial.print("dt: ");
+Serial.print(dt);
+Serial.print("  kp: ");
+Serial.print(Kp);
+Serial.print("  kd:  ");
+Serial.print(Kd);
+
+Serial.print("  angulo_recogido: ");
+Serial.print(angulo_recogido);
+Serial.print("  angulo_objetivo: ");
+Serial.print(angulo_objetivo);
+Serial.print("  motor_A:  ");
+Serial.print(motor_A);
+Serial.print("  motor_B:  ");
+Serial.print(motor_B);
+Serial.print("  control_salida: ");
+Serial.println(control_salida);
+//Serial.println(motor_A);
+//Serial.print(",");
+//Serial.println(motor_B);
+
+
+
+
+  //  if (velocidad < 50) {
+  //    setSpeed_Motor_A(velocidad);//
+  //    setSpeed_Motor_B(-velocidad);
+  //    ++velocidad;
+  //    Serial.println(velocidad);
+  //    delay(10);
+  //  }
+  //  Serial.print("motor_A 16bits steps: ");
+  //  Serial.println(cuenta_A);
+  //  Serial.print("motor_B  8bits steps: ");
+  //  Serial.println(cuenta_B);
+
+}/* **************   FINAL LOOP   ******************** */
+
+
+
+
+// TIMER 1 : STEPPER MOTOR_A SPEED CONTROL  *********   ISR  ****************
+ISR(TIMER1_COMPA_vect) //16bits
+{
+
+  SET(PORTB, 7); // STEP MOTOR A
+  delay_1us();
+  delay_1us();
+  CLR(PORTB, 7);
+
+
+}
+//TIMER 3 : STEPPER MOTOR_B SPEED CONTROL
+ISR(TIMER3_COMPA_vect) //16bits
+{
+
+  SET(PORTD, 7); // STEP MOTOR B
+  delay_1us();
+  delay_1us();
+  CLR(PORTD, 7);
+
+
+}
+/* ******************************************************************** */
+/* ****************        setSpeed_Motor_A         ******************* */
+/* ******************************************************************** */
+void setSpeed_Motor_A(int16_t tspeed)
+{
+  long timer_period;
+  int16_t speed;
+
+  // Limit max speed?
+
+  // WE LIMIT MAX ACCELERATION of the motors
+  if ((velocidad_Motor_A - tspeed) > MAXIMA_ACELERACION)
+    velocidad_Motor_A -= MAXIMA_ACELERACION;
+  else if ((velocidad_Motor_A - tspeed) < -MAXIMA_ACELERACION)
+    velocidad_Motor_A += MAXIMA_ACELERACION;
+  else
+    velocidad_Motor_A = tspeed;
+
+#if MICROSTEPPING==16
+  speed = velocidad_Motor_A * 46; // Adjust factor from control output speed to real motor speed in steps/second
+#else
+  speed = velocidad_Motor_A * 23; // 1/8 Microstepping
+#endif
+
+  if (speed == 0)
+  {
+    timer_period = ZERO_SPEED;
+    dir_Motor_A = 0;
+  }
+  else if (speed > 0)
+  {
+    timer_period = 2000000 / speed; // 2Mhz timer
+    dir_Motor_A = 1;
+    SET(PORTB, 4); // DIR Motor 1 (Forward)
+  }
+  else
+  {
+    timer_period = 2000000 / -speed;
+    dir_Motor_A = -1;
+    CLR(PORTB, 4); // Dir Motor 1
+  }
+  if (timer_period > 65535)   // Check for minimun speed (maximun period without overflow)
+    timer_period = ZERO_SPEED;
+  //Serial.println(timer_period);
+  OCR1A = timer_period;
+  // Check  if we need to reset the timer...
+  if (TCNT1 > OCR1A)
+    TCNT1 = 0;
+
+/* ******************************************************************** */
+/* ****************        setSpeed_Motor_B         ******************* */
+/* ******************************************************************** */
+} void setSpeed_Motor_B(int16_t tspeed)
+{
+  long timer_period;
+  int16_t speed;
+
+  // Limit max speed?
+
+  // WE LIMIT MAX ACCELERATION of the motors
+  if ((velocidad_Motor_B - tspeed) > MAXIMA_ACELERACION)
+    velocidad_Motor_B -= MAXIMA_ACELERACION;
+  else if ((velocidad_Motor_B - tspeed) < -MAXIMA_ACELERACION)
+    velocidad_Motor_B += MAXIMA_ACELERACION;
+  else
+    velocidad_Motor_B = tspeed;
+
+#if MICROSTEPPING==16
+  speed = velocidad_Motor_B * 46; // Adjust factor from control output speed to real motor speed in steps/second
+#else
+  speed = velocidad_Motor_B * 23; // 1/8 Microstepping
+#endif
+
+  if (speed == 0)
+  {
+    timer_period = ZERO_SPEED;
+    dir_Motor_B = 0;
+  }
+  else if (speed > 0)
+  {
+    timer_period = 2000000 / speed; // 2Mhz timer
+    dir_Motor_B = 1;
+    SET(PORTE, 6); // DIR Motor 1 (Forward)
+  }
+  else
+  {
+    timer_period = 2000000 / -speed;
+    dir_Motor_B = -1;
+    CLR(PORTE, 6); // Dir Motor 1
+  }
+  if (timer_period > 65535)   // Check for minimun speed (maximun period without overflow)
+    timer_period = ZERO_SPEED;
+  //Serial.println(timer_period);
+  OCR3A = timer_period;
+  // Check  if we need to reset the timer...
+  if (TCNT3 > OCR3A)
+    TCNT3 = 0;
+}
+
+/* ******************************************************************** */
+/* ****************     CONTROL PID  (B-ROBOT)      ******************* */
+/* ******************************************************************** */
+
+// PD controller implementation(Proportional, derivative). DT is in miliseconds
+float controlEstabilidadPD(float DT, float input, float setPoint,  float Kp, float Kd)
+{
+  float error;
+  float output;
+
+  error = setPoint - input;
+
+  // Kd is implemented in two parts
+  //    The biggest one using only the input (sensor) part not the SetPoint input-input(t-2)
+  //    And the second using the setpoint to make it a bit more agressive   setPoint-setPoint(t-1)
+  output = Kp * error + (Kd * (setPoint - setPointAntiguo) - Kd * (input - PID_errorAntiguo2)) / DT;
+  //Serial.print(Kd*(error-PID_errorOld));Serial.print("\t");
+  PID_errorAntiguo2 = PID_errorAntiguo;
+  PID_errorAntiguo = input;  // error for Kd is only the input component
+  setPointAntiguo = setPoint;
+  return (output);
+}
+
+
+// PI controller implementation (Proportional, integral). DT is in miliseconds
+float controlVelocidadPI(float DT, float input, float setPoint,  float Kp, float Ki)
+{
+  float error;
+  float output;
+
+  error = setPoint - input;
+  PID_errorSuma += constrain(error, -ITERM_MAX_ERROR, ITERM_MAX_ERROR);
+  PID_errorSuma = constrain(PID_errorSuma, -ITERM_MAX, ITERM_MAX);
+
+  //Serial.println(PID_errorSum);
+
+  output = Kp * error + Ki * PID_errorSuma * DT * 0.001; // DT is in miliseconds...
+  return (output);
+}
+


Arduino Code

Arduino Code

error: pathspec 'Essential-JAVA-and-ARDUINO-codes/Gahirai.ino' did not match any file(s) known to git

--- Essential-JAVA-and-ARDUINO-codes/Gahirai.ino
+++ Essential-JAVA-and-ARDUINO-codes/Gahirai.ino
@@ -0,0 +1,177 @@
+#include <dht11.h>
+#include <SFE_BMP180.h>
+#include <Wire.h>
+#include <LiquidCrystal.h>
+SFE_BMP180 pressure;
+#define ALTITUDE 1655.0
+dht11 DHT11;
+#define DHT11PIN 4
+#define trigPin 3 //Sensor Echo pin connected to Arduino pin 13
+#define echoPin 2 //Sensor Trip pin connected to Arduino pin 12
+long duration, cm, inches, depth;
+int i;
+int flag=0;
+float humidity;
+float temperature;
+float pres;
+int intensity;
+boolean inten;
+LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
+void setup() {
+  Serial.begin(9600);
+  pinMode(5, OUTPUT);
+  pinMode(trigPin, OUTPUT);
+  pinMode(echoPin, INPUT);
+  if (pressure.begin()){}
+  else
+  {
+    Serial.println("BMP180 init fail\n\n");
+    while(1); // Pause forever.
+  }
+  lcd.begin(16, 2);
+  lcd.print("ShreStsaV");
+  delay(1200);
+  for(i=0;i<2;i++)
+  {
+    lcd.clear();
+    lcd.setCursor(0, 0);
+    delay(100);
+    lcd.print("WATER MONITORING");
+  }
+  delay(3000);
+}
+
+void loop()
+{
+  hope:
+  digitalWrite(trigPin, LOW);
+  delayMicroseconds(5);
+  digitalWrite(trigPin, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(trigPin, LOW);
+  pinMode(echoPin, INPUT);
+  duration = pulseIn(echoPin, HIGH);
+  cm = (duration/2) / 29.1;
+  inches = (duration/2) / 74;
+  depth = 48-cm;
+  if (cm>500){
+    lcd.clear();
+    lcd.setCursor(0,0);
+    lcd.print("IrregularSurface");
+    goto hope;
+    delay(700);
+   }
+  else if(cm<10){
+      lcd.clear();
+      lcd.setCursor(0,0);
+      lcd.print("WARNING");
+      digitalWrite(5, HIGH);   // turn the LED on (HIGH is the voltage level)
+      delay(700);              // wait for a second
+     }
+  else{
+     digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW
+     lcd.clear();
+     lcd.setCursor(0,0);  //Set cursor to first column of second row
+     lcd.print("Distance"); //Print blanks to clear the row
+     lcd.setCursor(0,1);   //Set Cursor again to first column of second row
+     lcd.print(cm); //Print measured distance
+     lcd.print(" cm");
+     lcd.setCursor(7,1);
+     lcd.print(inches);
+     lcd.print("in");
+     delay(750);
+     //Depth
+     lcd.clear();
+     lcd.setCursor(0,0);
+     lcd.print("River Depth");
+     lcd.setCursor(0,1);
+     lcd.print(depth);
+     lcd.print(" cm");
+   }
+//  Serial.print(inches);
+//  Serial.print("in, ");
+//  Serial.print(cm);
+//  Serial.print("cm");
+//  Serial.println();
+
+  delay(750);
+
+  //while(1){Serial.println(analogRead(A0));delay(500);}
+            char status;
+            double T,P,p0,a;
+            int chk = DHT11.read(DHT11PIN);
+            switch (chk)
+            {
+              case DHTLIB_OK:
+              //Serial.println("OK");
+              break;
+              case DHTLIB_ERROR_CHECKSUM:
+              Serial.println("Checksum error");
+              break;
+              case DHTLIB_ERROR_TIMEOUT:
+              Serial.println("Time out error");
+              break;
+              default:
+              Serial.println("Unknown error");
+              break;
+            }
+    intensity=analogRead(A0);
+    if(intensity>200)
+    inten=1;
+    else inten=0;
+    humidity=(float)DHT11.humidity;
+    temperature=(float)DHT11.temperature;
+    status = pressure.startTemperature();
+    if (status != 0)
+        {
+            delay(status);
+            status = pressure.getTemperature(T);
+            if (status != 0)
+        {
+        status = pressure.startPressure(3);
+        if (status != 0)
+        {
+        delay(status);
+        status = pressure.getPressure(P,T);
+        if (status != 0)
+        {//lcd.print(P);
+        pres=P;
+        }
+       }}}
+  if(Serial.available()>0)
+       {
+        flag=Serial.read();
+        if (flag=='1'){}
+        else
+        {
+        //delay(10);
+        char tempstr[7],humistr[5],presstr[7],daynight[1],distance[5],rdepth[5];
+        dtostrf(temperature,6,2,tempstr);
+        dtostrf(humidity,4,2,humistr);
+        dtostrf(pres,6,2,presstr);
+        dtostrf(inten,1,0,daynight);
+        dtostrf(cm,2,0,distance);
+        dtostrf(depth,2,0,rdepth);
+        Serial.println(String(tempstr)+","+String(humistr)+","+String(presstr)+","+String(daynight)+","+String(distance)+","+String(rdepth));
+
+        }}
+     lcd.clear();
+     lcd.setCursor(0,0);
+     lcd.print("Temperature:");
+     lcd.setCursor(0,1);
+     lcd.print(temperature);
+     delay(700);
+     lcd.clear();
+     lcd.setCursor(0,0);
+     lcd.print("Humidity:");
+     lcd.setCursor(0,1);
+     lcd.print(humidity);
+     delay(700);
+      lcd.clear();
+     lcd.setCursor(0,0);
+     lcd.print("Pressure (AB):");
+     lcd.setCursor(0,1);
+     lcd.print(pres);
+     delay(700);
+     }
+


added idling timer. initial sammpling buffer support

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/manashmndl/bluebrain.git/'


modified to use arrays

modified to use arrays

error: pathspec 'matrix' did not match any file(s) known to git
error: pathspec 'timer/my_-_matrix8x8.ino' did not match any file(s) known to git