Hi everyone,
I’m fairly new to coding, and I was wondering if there is anything I have to do to make a code that originated in Arduino work in Spark. The project I am working on is supposed to be able to tell when a machine is on (by sensing a temperature increase) and send that data to a website. It does this by having two thermocouples (One measuring ambient temperature of the room, and the other against the wire to the machine) and send data through the amplifiers, then to the spark and so on.
The actual electronics in this “package” include two lengths of K-type thermocouple, which in turn are attached to two MAX31855 amplifiers (These amplifiers are not connected to each other!). The amplifiers are connected to the Spark Core in this arrangement:
Amp 1 (Amplifier’s port on left, Spark’s on the right)
Vin > 3v3
GND> 3v3
DO> D5
CS> D4
CLK> D3
Amp 2
Vin > 3v3
GND> 3v3
DO> D2
CS> D1
CLK> D0
(The Vin and GND ports on the Amplifier go to one 3v3 port on the Spark, as the wiring is in a “Y”)
Now for the programming:
Is there any right way of adding a library? When I selected a library in the Build page, I just clicked on “libraries” then found the MAX31855 file and clicked add to application. Is this the correct way of doing this?
Also, how should I reconfigure my program (And possibly design) to account for the different ports on the spark, as originally, this project was prototyped on a Arduino Uno, connected to a wifi shield and DIY amplifier (Too bulky, in other words).
Finally, what method and how can I send this data to a website? I’ll copy/paste my program below.
(Couldn’t paste library, but it’s inside the library tab on the build page. Sorry!)
int thermoDO = 6;
int thermoCS1 = 2;
int thermoCS2 = 3;
int thermoCLK = 5;
Adafruit_MAX31855 thermocouple1(thermoCLK, thermoCS1, thermoDO);
Adafruit_MAX31855 thermocouple2(thermoCLK, thermoCS2, thermoDO);
void setup() {
Serial.begin(9600);
Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(750);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("Internal Temp1 = ");
Serial.println(thermocouple1.readInternal());
Serial.print("Internal Temp2 = ");
Serial.println(thermocouple2.readInternal());
double c = thermocouple1.readCelsius();
double c2 = thermocouple2.readCelsius();
if (isnan(c)) {
Serial.println("Something wrong with thermocouple!");
}
else {
Serial.print("C1 = ");
Serial.println(c);
Serial.print("C2 = ");
Serial.println(c2);
}
//Serial.print("F = ");
//Serial.println(thermocouple.readFarenheit());
delay(4000);
}
As you can see, the program is still incomplete, so feel free to suggest ideas, or change/add to it. While based on the arduino, it did take the temperatures correctly but could only transmit data to a terminal via a wired connection. Once again, any help is appreciated and I apologize on the n00biness. Thanks!