<commit_before>
#include "OneWire.h"

//analog pins
#define plantLight A0
#define aquaLight A3
#define waterTurbSensor A1
#define ovenTempSensor A4

//digital pins  
OneWire  ds(2); //water temp sensor
#define RELAY1 3

bool powerIsOn = true;

uint8_t incomingByte;

//run once on start
void setup() {
  Serial.begin(9600);
  pinMode(RELAY1, OUTPUT);
  digitalWrite(RELAY1, HIGH);
}

//main program loop.
void loop() {
  SendData();
  GetInput();
}

/*these will be raw readings, converting from voltage to 
 * degrees or light etc should most likly done in a seperate 
 * function or even in the data logger.
 */
void SendData(){
  String mystr = "['data', {'station': 'aquaponicStation', 'sensors': [";
  mystr += "{'sensor': 'aquaLight', 'type': 'lightsensor', 'value': ";
  mystr += analogRead(aquaLight) ;
  mystr += "},{'sensor':'ovenTemp', 'type': 'temperature', 'value':";
  mystr += analogRead(ovenTempSensor);  
  mystr += "},{'sensor':'plantLight', 'type': 'lightsensor', 'value':";
  mystr += analogRead(plantLight);
  mystr += "},{'sensor':'waterTurb', 'type': 'cleanliness', 'value':";
  mystr += analogRead(waterTurbSensor);
  
  mystr += "},{'sensor':'waterTemp', 'type': 'temperature', 'value':";
  mystr += ReadTemp();
  mystr += "},{'sensor':'lightSwitch', 'type': 'lightswitch', 'value':";
  mystr += powerIsOn;
  
  mystr += "}]}]";
  Serial.println(mystr);
}

//read input via serial
void GetInput(){
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    //light schduling 
    //turn lights off
    Serial.println(incomingByte);
    if(incomingByte == 48){     //being sent 1
       digitalWrite(RELAY1,0);
       powerIsOn = false;
    }
    //turn lights on
    if(incomingByte == 49){     //being sent 0
       digitalWrite(RELAY1,1);
       powerIsOn = true;
    }
  }
}

//Script I found online and modifed using the OneWire library, returns the temperature in fahrenheit.
float ReadTemp(){
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;<commit_msg>updating firmware to include relay<commit_after>
#include "OneWire.h"

//digital pins  
OneWire ds1(2); //water temp sensor
OneWire ds2(3); //living room temp sensor

#define RELAY1 10

bool powerIsOn = true;

uint8_t incomingByte;

//run once on start
void setup() {
  Serial.begin(9600);
  pinMode(RELAY1, OUTPUT);
  digitalWrite(RELAY1, HIGH);
}

//main program loop.
void loop() {
  SendData();
  GetInput();
}

void SendData(){
  String mystr = "['data', {'station': 'aquaponicStation', 'sensors': [";
  mystr += "{'sensor':'waterTemp', 'type': 'temperature', 'value':";
  mystr += ReadTemp(ds1);
  mystr += "},{'sensor':'livingRoomTemp', 'type': 'temperature', 'value':";
  mystr += ReadTemp(ds2);
  mystr += "},{'sensor':'lightSwitch', 'type': 'lightswitch', 'value':";
  mystr += powerIsOn;
  mystr += "}]}]";
  Serial.println(mystr);
}

//read input via serial
void GetInput(){
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    //light schduling 
    //turn lights off
    Serial.println(incomingByte);
    if(incomingByte == 48){     //being sent 1
       digitalWrite(RELAY1,0);
       powerIsOn = false;
    }
    //turn lights on
    if(incomingByte == 49){     //being sent 0
       digitalWrite(RELAY1,1);
       powerIsOn = true;
    }
  }
}

//Script I found online and modifed using the OneWire library, returns the temperature in fahrenheit.
float ReadTemp(OneWire ds){
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
{'fraction_non_alphanumeric': 0.163957399103139, 'fraction_numerical': 0.016816143497757848, 'mean_word_length': 3.7146631439894318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2750027', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1213, 'n_words': 341}