Commit 8229ce0d authored by BigOto2's avatar BigOto2
Browse files

ScienceStationBoardCode (UNFINISHED)

Separataed the science station code into separate files. Need to add
code to convert integers to bytes before sending them over I2C. Also,
getting lots of errors when trying to upload the code to the arduino Uno
with the sensor interface shield (someone try pushing the code on their
computer?).
parent 2a92e9a6
#include "sciencestationDefine.h"
#include "humidityReading.h"
#include "sendReadings.h"
#include "phReading.h"
#include <Wire.h>
void setup() {
// initialize serial communications:
Wire.begin();
}
void loop() {
sendReadings(humidityReading(), phReading());
delay(TimeBetweenReadings);// delay in between reads for stability
}
int humidityReading()
{
// read the value from the pin
double humReading = 0;
double sensorRH = 0;
humReading = analogRead(humPin);
// calculate the sensor humidity
if(humcalibrated){
sensorRH = humReading/humcalibratedValue*100.0;
}
return sensorRH*10; //multiply percentage before 10 before converting to int to preserve sig figs
}
int phReading()
{
float Count;
float Voltage;
float pH;
Count = analogRead(pHPin);
Voltage = Count / 1023 * 5.0;// convert from count to raw voltage
pH = Voltage/0.36;
//Serial.print("Voltage: ");
//Serial.println(Voltage);
//Serial.print("pH: ");
//Serial.println(pH);
return pH*1000; //multiply by 1000 before converting to int so that all sig figs are preserved
}
#include "Arduino.h"
const int humPin = A0;
boolean humcalibrated = true;
double humcalibratedValue = 640.0;
int TimeBetweenReadings = 500;
const int pHPin = A1;
#include <Wire.h>
void sendReadings(int humidity, int pH)
{
Wire.beginTransmission(4);
// Need to insert code to convert the ints to bytes before they can be sent via I2C.
//Wire.write(humidity);
//Wire.write(" ");
//Wire.write(pH);
Wire.endTransmission();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment