Adding initial firmware.

Adding initial firmware.

#include <DMXSerial.h>

/*
    Basic Pin setup:
    ------------                                  ---u----
    ARDUINO   13|-> SCLK (pin 25)           OUT1 |1     28| OUT channel 0
              12|                           OUT2 |2     27|-> GND (VPRG)
              11|-> SIN (pin 26)            OUT3 |3     26|-> SIN (pin 11)
              10|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 13)
               9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
               8|                             .  |6     23|-> BLANK (pin 10)
               7|                             .  |7     22|-> GND
               6|                             .  |8     21|-> VCC (+5V)
               5|                             .  |9     20|-> 2K Resistor -> GND
               4|                             .  |10    19|-> +5V (DCPRG)
               3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
               2|                             .  |12    17|-> SOUT
               1|                             .  |13    16|-> XERR
               0|                           OUT14|14    15| OUT channel 15
    ------------                                  --------

    -  Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
         (cathode) in OUT(0-15).
    -  +5V from Arduino -> TLC pin 21 and 19     (VCC and DCPRG)
    -  GND from Arduino -> TLC pin 22 and 27     (GND and VPRG)
    -  digital 3        -> TLC pin 18            (GSCLK)
    -  digital 9        -> TLC pin 24            (XLAT)
    -  digital 10       -> TLC pin 23            (BLANK)
    -  digital 11       -> TLC pin 26            (SIN)
    -  digital 13       -> TLC pin 25            (SCLK)
    -  The 2K resistor between TLC pin 20 and GND will let ~20mA through each
       LED.  To be precise, it's I = 39.06 / R (in ohms).  This doesn't depend
       on the LED driving voltage.
    - (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
                  all the LEDs will turn off when the Arduino is reset.

    If you are daisy-chaining more than one TLC, connect the SOUT of the first
    TLC to the SIN of the next.  All the other pins should just be connected
    together:
        BLANK on Arduino -> BLANK of TLC1 -> BLANK of TLC2 -> ...
        XLAT on Arduino  -> XLAT of TLC1  -> XLAT of TLC2  -> ...
    The one exception is that each TLC needs it's own resistor between pin 20
    and GND.

    This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
    Do not use analogWrite(...) on these pins.

    This sketch does the Knight Rider strobe across a line of LEDs.

    Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */

#include "Tlc5940.h"

static int bright[3] = {0, 1224, 2650};

void setup()
{
  /* Call Tlc.init() to setup the tlc.
     You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
  Tlc.init();
  Tlc.set(0, 4095);
  digitalWrite(2, LOW);
  pinMode(2, OUTPUT);
  DMXSerial.init(DMXReceiver);
  Tlc.set(1, 4095);
  delay(500);
  Tlc.set(2, 4095);
}

/* This loop will create a Knight Rider-like effect if you have LEDs plugged
   into all the TLC outputs.  NUM_TLCS is defined in "tlc_config.h" in the
   library folder.  After editing tlc_config.h for your setup, delete the
   Tlc5940.o file to save the changes. */

void loop()
{
  for (int i = 0; i < 48; i++) {
    Tlc.set(i, DMXSerial.read(i+1) << 4);
  }
  Tlc.update();
}

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


initial ble impl, incomplete

initial ble impl, incomplete

#include <SPI.h>
#include <SD.h>
//#include <stdlib.h>
#include <RFduinoBLE.h>
#include <Wire.h>
#include <RTC_DS3231.h>

#include <OneWire.h> // http://forum.rfduino.com/index.php?topic=103.msg261#msg261

// Wire.beginOnPins(2, 3); // Starts the I2C interface with SCL on GPIO 2 and SDA on GPIO 3

#define LOGGING_FREQ_SECONDS   300

#define RTC_POWER_PIN          2u
RTC_DS3231 RTC;

#define TEMP_SIGNAL_PIN        6u
OneWire ds(TEMP_SIGNAL_PIN);

void setup() {

  RFduinoBLE.deviceName = "Hood-CS475";
  RFduinoBLE.advertisementData = "data";
  RFduinoBLE.advertisementInterval = 1000; // 1s
  RFduinoBLE.txPowerLevel = -20;
  RFduinoBLE.begin();

  Wire.beginOnPins(1u, 0u);
}

void loop() {
  // put your main code here, to run repeatedly:

  if (!RFduinoBLE.radioActive) {
    RFduino_ULPDelay(SECONDS(LOGGING_FREQ_SECONDS));
  }
}

void RFduinoBLE_onConnect(){
// Insert code
}

void RFduinoBLE_onDisconnect(){
// Insert code here
}

void RFduinoBLE_onReceive(char *data, int len){
  uint8_t myByte = data[0]; // store first char in array to myByte
  Serial.println(myByte); // print myByte via serial

  // GetStationIdentifier
  if (strcmp(data, "GetStationIdentifer") == 0) {
    getStationIdentifer()
  }
  // GetAllObservations
  else if (strcmp(data, "GetAllObservations") == 0) {
    getAllObservations()
  }
  // GetSystemState
  else if (strcmp(data, "GetSystemState") == 0) {
    getSystemState()
  }
}

void getStationIdentifer() {
  // RFduinoBLE.send(const char *data, int len);

}

void getAllObservations() {

}

void getSystemState() {

}

float getTemp() { //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if (!ds.search(addr)) {
    //no more sensors on chain, reset search
    ds.reset_search();
    return -1000;
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
    Serial.println("CRC is not valid!");
    return -1000;
  }

  if (addr[0] != 0x10 && addr[0] != 0x28) {
    Serial.print("Device is not recognized");
    return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1); // start conversion, with parasite power on at the end

  delay(750); // required wait time for parasitic power

  byte present = ds.reset();
  ds.select(addr);
  ds.write(0xBE); // Read Scratchpad

  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }

  ds.reset_search();

  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float temperatureSum = tempRead / 16;

  return temperatureSum;
}

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


deleted the GUI, change a bit

deleted the GUI, change a bit

#define outputPIN P1_5
#define inPIN P1_4
#define basePIN P2_1
#define acidPIN P2_2

unsigned long int timeSend = 0;
unsigned long int timeSinceMotorRun = 1000000;
boolean shutDown = false;
boolean motorRunning = false;
int PHtarget = 1200;      // will be updated by interface
int PHmargin = 50;        //
int output = 0;
int input = 0;

void setup()
{
  Serial.begin(9600);
  Serial.setTimeout(50);
  pinMode(outputPIN, INPUT);
  pinMode(inPIN, INPUT);
  pinMode(basePIN, OUTPUT);
  pinMode(acidPIN, OUTPUT);
  digitalWrite(basePIN, LOW);
  digitalWrite(acidPIN, LOW);
}

void loop()
{

  if(millis() - timeSend > 1000)  // function to run every 0.25s
  {
  // read the input on analog pin P1.5:
  output = analogRead(outputPIN)*2.9;  // this include a gain of 11
  input = analogRead(inPIN)*2.9;

  // print out the value we have read to the interface:
  Serial.print("PHoutputex:");
  Serial.print(output);
  Serial.print("\r\n");
  Serial.print("PHinputes:");
  Serial.print(input);
  Serial.print("\r\n");
  Serial.print("PHtarget:");
  Serial.print(PHtarget);
  Serial.print("\r\n");

  PHmaintain();  // activate motors if required;

  timeSend = millis();
  }

  PHcommandListen();  // listen for commands NOTE; THIS SECTION MUST BE COMBINED WITH OTHER SUBSYSTEMS

}

  void PHmaintain(){

   int difference = PHtarget - output;
   Serial.print("difference:");
   Serial.println(difference);

   if(motorRunning && (millis() - timeSinceMotorRun > 2000))  // if we've been running the motor for more than 2s
   {
     digitalWrite(basePIN, LOW);
     digitalWrite(acidPIN, LOW);
     // turn both motors off
     motorRunning = false;
     Serial.println("Shutting motor down");
   }

   if(abs(difference) > PHmargin)  // if the PH is outside the margin
   {
     Serial.println("PH outside margin");

     if(difference > 0 && (millis() - timeSinceMotorRun) > 5000)  // if solution is too acidic and we havn't run a motor for 10s
     {
      if(!shutDown){  // if we havn't shut the motors down.
         timeSinceMotorRun = millis();
         motorRunning = true;
         digitalWrite(basePIN, HIGH);  // run base motor
         Serial.println("Runnng base motor");
       }
     }

     if(difference < 0 && (millis() - timeSinceMotorRun) > 5000)  // if solution is too alkalie and we havn't run a motor for 10s
     {
       if(!shutDown){  // if we havn't shut the motors down.
         timeSinceMotorRun = millis();
         motorRunning = true;
          digitalWrite(acidPIN, HIGH); // run acid motor;
          Serial.println("Runnng acid motor");
       }
     }
   }

  }

  void PHcommandListen()  // listen and reactor to commands from the interface
  {

       while (Serial.available() > 0) {

         String inString = Serial.readString();
         inString.trim();
         Serial.println(inString);  //DEBUG ONLY

         if(inString.equals("S")){
         Serial.println("PH is in shutdown");
         shutDown = true;
             digitalWrite(basePIN, LOW);
             digitalWrite(acidPIN, LOW);
             // turn both motors off
             motorRunning = false;
         }
         if(inString.equals("XS")){
         Serial.println("PH has resumed");
         shutDown = false;
         }
         if((inString.substring(0,11)).equals("PHcommanded"))  // if we see a command
         {
           PHtarget = inString.substring(12).toInt();  // change the target PH
         }
         }

  }

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


Added hvac monitor arduino

Added hvac monitor arduino

#include <OneWire.h>
#include <PubSubClient.h>
#include <ESP8266WiFi.h>

// Add missing definitions for WIFI and mq information here
#include "config.h"
#define SECONDS_DS(seconds)  ((seconds)*1000000UL)
#define AMOUNT_SENSORS 20
const char* mqtt_server = SERVERADDRESS;
int numSensors = AMOUNT_SENSORS;
float  sensorValues[AMOUNT_SENSORS];
byte* sendsensors[8];
int sendSensors = 0;
OneWire  ds(ONEWIREPIN);

WiFiClient espClient;
PubSubClient client(espClient);

void setup_wifi() {
  WiFi.begin(WIFIHOTSPOT, WIFIKEY);
  client.setServer(mqtt_server, 1883);
}

void setup() {
  byte addr[8];

  //Serial.begin(9600);
  Serial.println("Starting search now");
  while (ds.search(addr)) {
    Serial.println("Found Sensor.. Addindg it");
    byte *byteArray;
    byteArray = (byte*) malloc (8 * sizeof(byte));
    memcpy(byteArray, addr, 8);
    sendsensors[sendSensors] = byteArray;
    sendSensors++;
    Serial.print("Address:");
    Serial.write(addr, 8);
    Serial.println("");
  }
  Serial.println("setup wifi");
  setup_wifi();
  Serial.print("init done");
}

void readAllSensorsData() {
  byte data[12];
  byte present = 0;
  byte type_s = 0;
  byte first;
  char msg[30];
  char str_temperature[10];

  for (int i = 0; i < sendSensors; i++) {

    Serial.print("Iterating one sensor");
    ds.reset();
    ds.select(sendsensors[i]);
    ds.write(0x44, 1);
    //wait for conversion ready
    delay(1000);
    present = ds.reset();
    ds.select(sendsensors[i]);
    ds.write(0xBE);
    Serial.print("P=");
    Serial.print(present, HEX);
    Serial.print(" ");
    for (int j = 0; j < 9; j++) {           // we need 9 bytes
      data[j] = ds.read();
      Serial.print(data[j], HEX);
      Serial.print(" ");
    }
    Serial.print(" CRC=");
    Serial.print( OneWire::crc8( data, 8), HEX);
    Serial.println();
    int16_t raw = (data[1] << 8) | data[0];
    if (type_s) {
      raw = raw << 3; // 9 bit resolution default
      if (data[7] == 0x10) {
        // "count remain" gives full 12 bit resolution
        raw = (raw & 0xFFF0) + 12 - data[6];
      }
    } else {
      byte cfg = (data[4] & 0x60);
      // at lower res, the low bits are undefined, so let's zero them
      if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
      else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
      else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
      //// default is 12 bit resolution, 750 ms conversion time
    }

    float   celsius = (float)raw / 16.0;
    float  fahrenheit = celsius * 1.8 + 32.0;
    Serial.print("  Temperature = ");
    Serial.print(celsius);
    Serial.print(" Celsius, ");
    Serial.print(fahrenheit);
    Serial.println(" Fahrenheit");
    dtostrf(celsius, 1, 2, str_temperature);
    snprintf (msg, 30, "%d,%s",i,str_temperature);
    client.publish("HVACData", msg);

  }

}

void reconnect() {
  while (!client.connected()) {
    String clientId = "ESP8266Client-";
    clientId += String(random(0xffff), HEX);
    // Attempt to connect
    if (client.connect(clientId.c_str())) {
      //good connection just spew the data and continue
    readAllSensorsData();
    delay(3000);
    ESP.deepSleep(SECONDS_DS(55));
    } else {
      delay(2000);
    }
  }
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }

}

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