From: rtrimana Date: Thu, 21 Mar 2019 21:50:30 +0000 (-0700) Subject: Compacting files. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fa63657039f0281dfda44db25b561504e36cfa14;p=iotcloud.git Compacting files. --- diff --git a/version2/src/others/IR-Sensor/IR-Sensor_Particle-Cloud.ino b/version2/src/others/IR-Sensor/IR-Sensor_Particle-Cloud.ino deleted file mode 100644 index c51c30f..0000000 --- a/version2/src/others/IR-Sensor/IR-Sensor_Particle-Cloud.ino +++ /dev/null @@ -1,46 +0,0 @@ -// ------------------------------------------------ -// Controlling HC-SR501 through Particle Cloud -// @author Rahmadi Trimananda - UC Irvine -// ------------------------------------------------ -// HC-SR501 Motion Detector -// Basically, this simple code detects motion and send the occurrences to the cloud -// We use the WKP port (port A7) to wake up the device when there is motion -// -// Based on tutorial: http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/ - -int64_t machineId; -// Key and data -char keyBuffer[80]; -char dataBuffer[80]; - -// Setting up pins for input -void setup() { - - // Get the MAC address - byte mac[6]; - WiFi.macAddress(mac); - // Prepare machine ID - int64_t mac4 = (int64_t) mac[4]; - int64_t mac5 = (int64_t) mac[5]; - machineId = (mac4 * 256) + mac5; -} - -void loop() { - - // Basically delay to give time to send updates to Particle cloud. - // If we do less than this then it would fail publishing. - delay(2000); - // Machine ID - sprintf(keyBuffer, "%04x", machineId); - // Motion detection - sprintf(dataBuffer, "%s -> motion-detected", Time.timeStr().c_str()); - Particle.publish(keyBuffer, dataBuffer); - delay(1000); - - // TODO: Profiling - //String strTime(micros()); - //Particle.publish("Time motion sensor", strTime.c_str()); - //while(true); - - System.sleep(SLEEP_MODE_DEEP, 0); -} diff --git a/version2/src/others/IR-Sensor/Makefile b/version2/src/others/IR-Sensor/Makefile deleted file mode 100644 index f3ab16b..0000000 --- a/version2/src/others/IR-Sensor/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -include common.mk - -all: compile - -# To run Particle, we need to install Particle CLI -# Please see: -# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli -monitor: - sudo chmod 666 /dev/ttyACM0 - particle serial monitor - -compile: - rm -f *.bin - particle compile photon - -flash8: - particle flash IoT-8 photon*.bin - -flash9: - particle flash IoT-9 photon*.bin - -flash10: - particle flash IoT-10 photon*.bin - -PHONY += clean -clean: - rm -f *.bin - -PHONY += mrclean -mrclean: clean - rm -rf ../docs - -tabbing: - uncrustify -c C.cfg --no-backup *.cpp - uncrustify -c C.cfg --no-backup *.h - -wc: - wc *.cpp *.h - -.PHONY: $(PHONY) diff --git a/version2/src/others/IR-Sensor/common.mk b/version2/src/others/IR-Sensor/common.mk deleted file mode 100644 index 479a31c..0000000 --- a/version2/src/others/IR-Sensor/common.mk +++ /dev/null @@ -1,16 +0,0 @@ -# A few common Makefile items - -CC := gcc -CXX := g++ - -UNAME := $(shell uname) - -LIB_NAME := iotcloud -LIB_SO := lib_$(LIB_NAME).so - -CPPFLAGS += -Wall -g -O0 - -# Mac OSX options -ifeq ($(UNAME), Darwin) -CPPFLAGS += -D_XOPEN_SOURCE -DMAC -endif diff --git a/version2/src/others/Magnetic-Sensor/Magnetic-Sensor_Particle-Cloud.ino b/version2/src/others/Magnetic-Sensor/Magnetic-Sensor_Particle-Cloud.ino deleted file mode 100644 index 855c567..0000000 --- a/version2/src/others/Magnetic-Sensor/Magnetic-Sensor_Particle-Cloud.ino +++ /dev/null @@ -1,46 +0,0 @@ -// ------------------------------------------------ -// Controlling Arduino EK1656 through cloud -// @author Rahmadi Trimananda - UC Irvine -// ------------------------------------------------ -// Gikfun MC-38 - Arduino EK1656 (magnetic sensor) -// Basically, this simple code detects sensor opening and send the occurrences to the cloud -// We use the WKP port (port A7) to wake up the device when there is motion -// - -int64_t machineId; -// Key and data -char keyBuffer[80]; -char dataBuffer[80]; - -// Setting up pins for input -void setup() { - - // Get the MAC address - byte mac[6]; - WiFi.macAddress(mac); - // Prepare machine ID - int64_t mac4 = (int64_t) mac[4]; - int64_t mac5 = (int64_t) mac[5]; - machineId = (mac4 * 256) + mac5; -} - -void loop() { - - // Basically delay to give time to send updates to Particle cloud. - // If we do less than this then it would fail publishing. - delay(2000); - // Machine ID - sprintf(keyBuffer, "%04x", machineId); - // Motion detection - sprintf(dataBuffer, "%s -> closing-door-detected", Time.timeStr().c_str()); - Particle.publish(keyBuffer, dataBuffer); - - delay(1000); - - // TODO: Profiling - //String strTime(micros()); - //Particle.publish("Time motion sensor", strTime.c_str()); - //while(true); - - System.sleep(SLEEP_MODE_DEEP, 0); -} diff --git a/version2/src/others/Magnetic-Sensor/Makefile b/version2/src/others/Magnetic-Sensor/Makefile deleted file mode 100644 index 978f5f6..0000000 --- a/version2/src/others/Magnetic-Sensor/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -include common.mk - -all: compile - -# To run Particle, we need to install Particle CLI -# Please see: -# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli -monitor: - sudo chmod 666 /dev/ttyACM0 - particle serial monitor - -compile: - rm -f *.bin - particle compile photon - -flash0: - particle flash IoT-0 photon*.bin - -flash1: - particle flash IoT-1 photon*.bin - -flash2: - particle flash IoT-2 photon*.bin - -flash14: - particle flash IoT-14 photon*.bin - -PHONY += clean -clean: - rm -f *.bin - -PHONY += mrclean -mrclean: clean - rm -rf ../docs - -tabbing: - uncrustify -c C.cfg --no-backup *.cpp - uncrustify -c C.cfg --no-backup *.h - -wc: - wc *.cpp *.h - -.PHONY: $(PHONY) diff --git a/version2/src/others/Magnetic-Sensor/common.mk b/version2/src/others/Magnetic-Sensor/common.mk deleted file mode 100644 index 479a31c..0000000 --- a/version2/src/others/Magnetic-Sensor/common.mk +++ /dev/null @@ -1,16 +0,0 @@ -# A few common Makefile items - -CC := gcc -CXX := g++ - -UNAME := $(shell uname) - -LIB_NAME := iotcloud -LIB_SO := lib_$(LIB_NAME).so - -CPPFLAGS += -Wall -g -O0 - -# Mac OSX options -ifeq ($(UNAME), Darwin) -CPPFLAGS += -D_XOPEN_SOURCE -DMAC -endif diff --git a/version2/src/others/Temp-Sensor/DHT.cpp b/version2/src/others/Temp-Sensor/DHT.cpp deleted file mode 100644 index 2ef244c..0000000 --- a/version2/src/others/Temp-Sensor/DHT.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -#include "DHT.h" - -DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { - _pin = pin; - _type = type; - _count = count; - firstreading = true; -} - -void DHT::begin(void) { - // set up the pins! - pinMode(_pin, INPUT); - digitalWrite(_pin, HIGH); - _lastreadtime = 0; -} - -//boolean S == Scale. True == Farenheit; False == Celcius -float DHT::readTemperature(bool S) { - float f; - - if (read()) { - switch (_type) { - case DHT11: - f = data[2]; - if(S) - f = convertCtoF(f); - - return f; - case DHT22: - case DHT21: - f = data[2] & 0x7F; - f *= 256; - f += data[3]; - f /= 10; - if (data[2] & 0x80) - f *= -1; - if(S) - f = convertCtoF(f); - - return f; - } - } - return NAN; -} - -float DHT::convertCtoF(float c) { - return c * 9 / 5 + 32; -} - -float DHT::convertFtoC(float f) { - return (f - 32) * 5 / 9; -} - -float DHT::readHumidity(void) { - float f; - if (read()) { - switch (_type) { - case DHT11: - f = data[0]; - return f; - case DHT22: - case DHT21: - f = data[0]; - f *= 256; - f += data[1]; - f /= 10; - return f; - } - } - return NAN; -} - -float DHT::computeHeatIndex(float tempFahrenheit, float percentHumidity) { - // Adapted from equation at: https://github.com/adafruit/DHT-sensor-library/issues/9 and - // Wikipedia: http://en.wikipedia.org/wiki/Heat_index - return -42.379 + - 2.04901523 * tempFahrenheit + - 10.14333127 * percentHumidity + - -0.22475541 * tempFahrenheit*percentHumidity + - -0.00683783 * pow(tempFahrenheit, 2) + - -0.05481717 * pow(percentHumidity, 2) + - 0.00122874 * pow(tempFahrenheit, 2) * percentHumidity + - 0.00085282 * tempFahrenheit*pow(percentHumidity, 2) + - -0.00000199 * pow(tempFahrenheit, 2) * pow(percentHumidity, 2); -} - - -boolean DHT::read(void) { - uint8_t laststate = HIGH; - uint8_t counter = 0; - uint8_t j = 0, i; - unsigned long currenttime; - - // Check if sensor was read less than two seconds ago and return early - // to use last reading. - currenttime = millis(); - if (currenttime < _lastreadtime) { - // ie there was a rollover - _lastreadtime = 0; - } - if (!firstreading && ((currenttime - _lastreadtime) < 2000)) { - return true; // return last correct measurement - //delay(2000 - (currenttime - _lastreadtime)); - } - firstreading = false; - /* - Serial.print("Currtime: "); Serial.print(currenttime); - Serial.print(" Lasttime: "); Serial.print(_lastreadtime); - */ - _lastreadtime = millis(); - - data[0] = data[1] = data[2] = data[3] = data[4] = 0; - - // pull the pin high and wait 250 milliseconds - digitalWrite(_pin, HIGH); - delay(250); - - // now pull it low for ~20 milliseconds - pinMode(_pin, OUTPUT); - digitalWrite(_pin, LOW); - delay(20); - noInterrupts(); - digitalWrite(_pin, HIGH); - delayMicroseconds(40); - pinMode(_pin, INPUT); - - // read in timings - for ( i=0; i< MAXTIMINGS; i++) { - counter = 0; - while (digitalRead(_pin) == laststate) { - counter++; - delayMicroseconds(1); - if (counter == 255) { - break; - } - } - laststate = digitalRead(_pin); - - if (counter == 255) break; - - // ignore first 3 transitions - if ((i >= 4) && (i%2 == 0)) { - // shove each bit into the storage bytes - data[j/8] <<= 1; - if (counter > _count) - data[j/8] |= 1; - j++; - } - - } - - interrupts(); - - /* - Serial.println(j, DEC); - Serial.print(data[0], HEX); Serial.print(", "); - Serial.print(data[1], HEX); Serial.print(", "); - Serial.print(data[2], HEX); Serial.print(", "); - Serial.print(data[3], HEX); Serial.print(", "); - Serial.print(data[4], HEX); Serial.print(" =? "); - Serial.println(data[0] + data[1] + data[2] + data[3], HEX); - */ - - // check we read 40 bits and that the checksum matches - if ((j >= 40) && - (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) { - return true; - } - - - return false; - -} diff --git a/version2/src/others/Temp-Sensor/DHT.h b/version2/src/others/Temp-Sensor/DHT.h deleted file mode 100644 index 5280f9c..0000000 --- a/version2/src/others/Temp-Sensor/DHT.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef DHT_H -#define DHT_H -#if ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - -/* DHT library - -MIT license -written by Adafruit Industries -*/ - -// how many timing transitions we need to keep track of. 2 * number bits + extra -#define MAXTIMINGS 85 - -#define DHT11 11 -#define DHT22 22 -#define DHT21 21 -#define AM2301 21 - -class DHT { - private: - uint8_t data[6]; - uint8_t _pin, _type, _count; - unsigned long _lastreadtime; - boolean firstreading; - - public: - DHT(uint8_t pin, uint8_t type, uint8_t count=6); - void begin(void); - float readTemperature(bool S=false); - float convertCtoF(float); - float convertFtoC(float); - float computeHeatIndex(float tempFahrenheit, float percentHumidity); - float readHumidity(void); - boolean read(void); - -}; -#endif diff --git a/version2/src/others/Temp-Sensor/Makefile b/version2/src/others/Temp-Sensor/Makefile deleted file mode 100644 index 9da3c7e..0000000 --- a/version2/src/others/Temp-Sensor/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -include common.mk - -all: compile - -# To run Particle, we need to install Particle CLI -# Please see: -# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli -monitor: - sudo chmod 666 /dev/ttyACM0 - particle serial monitor - -compile: - rm -f *.bin - particle compile photon - -flash3: - particle flash IoT-3 photon*.bin - -flash4: - particle flash IoT-4 photon*.bin - -flash5: - particle flash IoT-5 photon*.bin - -flash6: - particle flash IoT-6 photon*.bin - -flash7: - particle flash IoT-7 photon*.bin - -flash11: - particle flash IoT-11 photon*.bin - -flash12: - particle flash IoT-12 photon*.bin - -flash13: - particle flash IoT-13 photon*.bin - -PHONY += clean -clean: - rm -f *.bin - -PHONY += mrclean -mrclean: clean - rm -rf ../docs - -tabbing: - uncrustify -c C.cfg --no-backup *.cpp - uncrustify -c C.cfg --no-backup *.h - -wc: - wc *.cpp *.h - -.PHONY: $(PHONY) diff --git a/version2/src/others/Temp-Sensor/Temp-Sensor_Particle-Cloud.ino b/version2/src/others/Temp-Sensor/Temp-Sensor_Particle-Cloud.ino deleted file mode 100644 index 665d732..0000000 --- a/version2/src/others/Temp-Sensor/Temp-Sensor_Particle-Cloud.ino +++ /dev/null @@ -1,101 +0,0 @@ -#include "application.h" -#include "DHT.h" - -// System defines -// Arduino -#define DHTPIN 2 // Data pin -#define PWRPIN D5 // Power pin -#define ERRPIN D7 // Error pin -#define DHTTYPE DHT22 // DHT 22 (AM2302) -// IoTCloud -#define SLEEP_TIME 15 // Sleep time in seconds -#define RETRY_SLEEP_TIME 5 // Sleep time in seconds -#define RETRY_TIME 10000 // stop trying after 10 seconds -#define CONNECTION_DELAY 2100000 // Need to delay after connecting WiFi to wait for sensor - -// Initialize DHT sensor for normal 16mhz Arduino -DHT dht(DHTPIN, DHTTYPE); - -// Globals -// IoTCloud -char keyBuffer[80]; -char dataBuffer[80]; -int64_t machineId; - -void setup() { - // TODO: - // 1) This code reads from the sensor and publishes - // the results on the cloud. - // 2) If you want to use the Serial library, - // please install "screen" on your machine and run - // it on the serial port right after flashing the - // firmware onto the Particle board. - // e.g. sudo screen /dev/ttyACM0 - - // We use one I/O pin to power the sensor so - // that we can make it go to sleep when we go into - // deep sleep. - - // TODO: Profiling! - //Serial.begin(); - //Serial.print("Time begin setup: "); - //Serial.println(micros()); - // Turn on sensor - pinMode(PWRPIN, OUTPUT); - digitalWrite(PWRPIN, HIGH); - // Arduino DHT - dht.begin(); - - // Prepare device key from MAC (just last 2 of 6 digits) - byte mac[6]; - WiFi.macAddress(mac); - - // TODO: Uncomment the following block to print MAC - //for (int i=0; i<6; i++) { - // Serial.printf("%02x%s", mac[i], i != 5 ? ":" : ""); - //} - //Serial.println(); - // Prepare machine ID - int64_t mac4 = (int64_t) mac[4]; - int64_t mac5 = (int64_t) mac[5]; - machineId = (mac4 * 256) + mac5; - //machineId = (int64_t) mac[5]; // Shorter version of machine ID - - // TODO: Profiling - //Serial.print("Time end setup: "); - //Serial.println(micros()); -} - -void loop() { - // Wait until sensor is ready - delay(1500); - // TODO: Profiling - //Serial.print("Time begin loop: "); - //Serial.println(micros()); - // Read humidity - float humid = dht.readHumidity(); - // Read temperature as Fahrenheit - float tempF = dht.readTemperature(true); - // Check if any reads failed and exit early (to try again). - if (isnan(humid) || isnan(tempF)) - return; - - // Machine ID - sprintf(keyBuffer, "%04x", machineId); - // Humidity + Temperature - sprintf(dataBuffer, "%0.2f-%0.2f", humid, tempF); - - // Publish on PHOTON's cloud - Particle.publish(keyBuffer, dataBuffer); - delay(1000); - - // Turn off sensor - digitalWrite(PWRPIN, LOW); - - // TODO: Profiling - //Serial.print("Time end loop: "); - //Serial.println(micros()); - //while(true) { } - System.sleep(SLEEP_MODE_DEEP, SLEEP_TIME); -} - diff --git a/version2/src/others/Temp-Sensor/common.mk b/version2/src/others/Temp-Sensor/common.mk deleted file mode 100644 index 479a31c..0000000 --- a/version2/src/others/Temp-Sensor/common.mk +++ /dev/null @@ -1,16 +0,0 @@ -# A few common Makefile items - -CC := gcc -CXX := g++ - -UNAME := $(shell uname) - -LIB_NAME := iotcloud -LIB_SO := lib_$(LIB_NAME).so - -CPPFLAGS += -Wall -g -O0 - -# Mac OSX options -ifeq ($(UNAME), Darwin) -CPPFLAGS += -D_XOPEN_SOURCE -DMAC -endif diff --git a/version2/src/others/ino/IR-Sensor/Makefile b/version2/src/others/ino/IR-Sensor/Makefile new file mode 100644 index 0000000..f3ab16b --- /dev/null +++ b/version2/src/others/ino/IR-Sensor/Makefile @@ -0,0 +1,40 @@ +include common.mk + +all: compile + +# To run Particle, we need to install Particle CLI +# Please see: +# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli +monitor: + sudo chmod 666 /dev/ttyACM0 + particle serial monitor + +compile: + rm -f *.bin + particle compile photon + +flash8: + particle flash IoT-8 photon*.bin + +flash9: + particle flash IoT-9 photon*.bin + +flash10: + particle flash IoT-10 photon*.bin + +PHONY += clean +clean: + rm -f *.bin + +PHONY += mrclean +mrclean: clean + rm -rf ../docs + +tabbing: + uncrustify -c C.cfg --no-backup *.cpp + uncrustify -c C.cfg --no-backup *.h + +wc: + wc *.cpp *.h + +.PHONY: $(PHONY) diff --git a/version2/src/others/ino/IR-Sensor/common.mk b/version2/src/others/ino/IR-Sensor/common.mk new file mode 100644 index 0000000..479a31c --- /dev/null +++ b/version2/src/others/ino/IR-Sensor/common.mk @@ -0,0 +1,16 @@ +# A few common Makefile items + +CC := gcc +CXX := g++ + +UNAME := $(shell uname) + +LIB_NAME := iotcloud +LIB_SO := lib_$(LIB_NAME).so + +CPPFLAGS += -Wall -g -O0 + +# Mac OSX options +ifeq ($(UNAME), Darwin) +CPPFLAGS += -D_XOPEN_SOURCE -DMAC +endif diff --git a/version2/src/others/ino/Magnetic-Sensor/Makefile b/version2/src/others/ino/Magnetic-Sensor/Makefile new file mode 100644 index 0000000..978f5f6 --- /dev/null +++ b/version2/src/others/ino/Magnetic-Sensor/Makefile @@ -0,0 +1,43 @@ +include common.mk + +all: compile + +# To run Particle, we need to install Particle CLI +# Please see: +# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli +monitor: + sudo chmod 666 /dev/ttyACM0 + particle serial monitor + +compile: + rm -f *.bin + particle compile photon + +flash0: + particle flash IoT-0 photon*.bin + +flash1: + particle flash IoT-1 photon*.bin + +flash2: + particle flash IoT-2 photon*.bin + +flash14: + particle flash IoT-14 photon*.bin + +PHONY += clean +clean: + rm -f *.bin + +PHONY += mrclean +mrclean: clean + rm -rf ../docs + +tabbing: + uncrustify -c C.cfg --no-backup *.cpp + uncrustify -c C.cfg --no-backup *.h + +wc: + wc *.cpp *.h + +.PHONY: $(PHONY) diff --git a/version2/src/others/ino/Magnetic-Sensor/common.mk b/version2/src/others/ino/Magnetic-Sensor/common.mk new file mode 100644 index 0000000..479a31c --- /dev/null +++ b/version2/src/others/ino/Magnetic-Sensor/common.mk @@ -0,0 +1,16 @@ +# A few common Makefile items + +CC := gcc +CXX := g++ + +UNAME := $(shell uname) + +LIB_NAME := iotcloud +LIB_SO := lib_$(LIB_NAME).so + +CPPFLAGS += -Wall -g -O0 + +# Mac OSX options +ifeq ($(UNAME), Darwin) +CPPFLAGS += -D_XOPEN_SOURCE -DMAC +endif diff --git a/version2/src/others/ino/Temp-Sensor/Makefile b/version2/src/others/ino/Temp-Sensor/Makefile new file mode 100644 index 0000000..9da3c7e --- /dev/null +++ b/version2/src/others/ino/Temp-Sensor/Makefile @@ -0,0 +1,55 @@ +include common.mk + +all: compile + +# To run Particle, we need to install Particle CLI +# Please see: +# https://docs.particle.io/guide/getting-started/connect/photon/#install-the-particle-cli +monitor: + sudo chmod 666 /dev/ttyACM0 + particle serial monitor + +compile: + rm -f *.bin + particle compile photon + +flash3: + particle flash IoT-3 photon*.bin + +flash4: + particle flash IoT-4 photon*.bin + +flash5: + particle flash IoT-5 photon*.bin + +flash6: + particle flash IoT-6 photon*.bin + +flash7: + particle flash IoT-7 photon*.bin + +flash11: + particle flash IoT-11 photon*.bin + +flash12: + particle flash IoT-12 photon*.bin + +flash13: + particle flash IoT-13 photon*.bin + +PHONY += clean +clean: + rm -f *.bin + +PHONY += mrclean +mrclean: clean + rm -rf ../docs + +tabbing: + uncrustify -c C.cfg --no-backup *.cpp + uncrustify -c C.cfg --no-backup *.h + +wc: + wc *.cpp *.h + +.PHONY: $(PHONY) diff --git a/version2/src/others/ino/Temp-Sensor/common.mk b/version2/src/others/ino/Temp-Sensor/common.mk new file mode 100644 index 0000000..479a31c --- /dev/null +++ b/version2/src/others/ino/Temp-Sensor/common.mk @@ -0,0 +1,16 @@ +# A few common Makefile items + +CC := gcc +CXX := g++ + +UNAME := $(shell uname) + +LIB_NAME := iotcloud +LIB_SO := lib_$(LIB_NAME).so + +CPPFLAGS += -Wall -g -O0 + +# Mac OSX options +ifeq ($(UNAME), Darwin) +CPPFLAGS += -D_XOPEN_SOURCE -DMAC +endif