Is anyone working on a library for the adafruit MAX31855? There is an old thread that predates the Spark IDE library changes. It also relates to a multiple sensor board. Any help for a single or multiple sensor library would be greatly appreciated.
For reference it looks like that would be:
It didn’t look too scary on its face, might be an easy place to start for porting. It looks like Adafruit is out of stock on it now, anybody have an extra or know when it might be in stock again? Might be fun for a grill / oven thermometer amp…
Thanks!
David
I’ll take a stab at it and put it directly into the Spark Libraries… I’ll keep it simple for now and just make it SW SPI compatible.
BDub you are a star! Thank you.
Ok it’s up there! Please test it and let me know if it works… I’m flying blind here with no hardware. It compiles in the online IDE though.
This is a Software SPI implementation as well, so you can technically use whatever pins you want
https://www.spark.io/libs/53ab4a0a1422163daa0009cb/tab/Adafruit_MAX31855.cpp (can you hotlink to Spark Libraries? Can you see this?)
https://github.com/technobly/SparkCore-MAX31855 (repo just in case)
Hi BDub,
Thank you for your work on this. I ran the example serial code and could not work out why nothing was getting through to tera term.
Then I noticed this line // open serial terminal and press ENTER to start
Pressed ENTER and hey presto. I got some date through to the serial port monitor. The issue now is that the readings are all 0.
it reports
Internal Temp = 0.00
C = 0.00
The data sheet here
http://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX31855.html
suggests a 0.1 micro f capacitor to be placed between 3v3* and GND. I have not tried this yet.
Is there anything obviously wrong in the following code?
#include "math.h"
#include "Adafruit_MAX31855/Adafruit_MAX31855.h"
int thermoCLK = A3;
int thermoCS = A2;
int thermoDO = A4;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
// open serial terminal and press ENTER to start
Serial.begin(9600);
while(!Serial.available()) SPARK_WLAN_Loop();
Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
double c = thermocouple.readCelsius();
if (isnan(c)) {
Serial.println("Something wrong with thermocouple!");
} else {
Serial.print("C = ");
Serial.println(c);
}
//Serial.print("F = ");
//Serial.println(thermocouple.readFarenheit());
delay(1000);
}
I note that it doesn’t seem to print MAX31855 test to the serial port.
cheers,
Julian
shouldnt you be plugging in to digital pins?
CLK to digital 3, CS to digital 4 and DO to digital 5
according to this adafruit page: https://learn.adafruit.com/thermocouple/using-a-thermocouple
Yep, those (A4, A3, A2) are digital… all pins of the Spark Core can be used as digital inputs or outputs. I just happened to leave the example mapped to the SPI HW pins which are on the Analog pin side of the Spark Core… it’s only slightly confusing
@Julian let’s see a picture of your wiring… I don’t see an issue with the code.
The issue with setting up HW, i.e., pinMode in constructors was fixed as far as I can remember… that would be the only thing I can think of…
Hey BDub,
I will send you a picture of my birds nest / wiring as soon as I can.
Thank you for you continued support.
Hi @BDub,
I have done some pruning of the birds nest and… got it working. Yes i did the old IT professional trick of switching it off (unplugging everything) and restarting. It now works just fine. Thank you very much.
For the above code, please can you suggest how I would set the temperature reading to a spark variable?
That way I can pick it up in atomiot.
Hi @Julian,
You could add something like:
double temperature = 0;
void setup()
{
//...
// Register a Spark variable here
Spark.variable("temperature", &temperature, DOUBLE);
//...
}
void loop()
{
//...
temperature = thermocouple.readCelsius();
//...
}
Thanks!
David
Thanks David. Do you ever sleep!
I must admit that life, work, family etc… all seem to be getting in the way of my electronics fun !!
I slept once! It was great! Taking frequent breaks is good too
@Dave, that does sound a bit like the kids wii - “now take a break”!!.
I am getting the serial port moitor to work just fine now. I am using tera term. However the spark variable does not seem to be working. What have I done wrong?
the code is :-
#include "math.h"
#include "Adafruit_MAX31855/Adafruit_MAX31855.h"
int thermoCLK = A3;
int thermoCS = A2;
int thermoDO = A4;
double thermotemp = 0;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
//...
// Register a Spark variable here
Spark.variable("thermotemp", &thermotemp, DOUBLE);
//...
// open serial terminal and press ENTER to start
Serial.begin(9600);
while(!Serial.available()) SPARK_WLAN_Loop();
Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
double c = thermocouple.readCelsius();
double thermotemp = thermocouple.readCelsius();
if (isnan(c)) {
Serial.println("Something wrong with thermocouple!");
} else {
Serial.print("C = ");
Serial.println(c);
}
//Serial.print("F = ");
//Serial.println(thermocouple.readFarenheit());
delay(1000);
}
I have tried to pick up the variable thermotemp in
http://jflasher.github.io/spark-helper/
and it does not appear in atomiot automatically as it has previously. For these reasons I think the publishing bit is going wrong.
I appreciate that I have set up a “parallel” variable called thermotemp to be used specifically as a spark variable. I suspect i might be able to use c and set that up as a spark variable which would have been more code efficient. If you see what I mean.
What did I do wrong and what is the correct syntax for the inside the ()? I appreciate that there needs to be an & and how that is linked to the memory allocation. does the first variable name have to be in “” and does the variable after the & have to be the same as the on in “”?
I hope thoes questions makes some sense.
I am having great fun with this. Thank you for your help. It is much appreciated.
Hi @Julian,
Hmm, yeah, I would guess declaring another variable named thermotemp
inside your loop is maybe out-scoping your global thermotemp
variable that you passed to the Spark.variable function, try changing this line:
double thermotemp = thermocouple.readCelsius();
to
thermotemp = thermocouple.readCelsius();
When you’re calling Spark.variable
you’re saying you have a value stored at some memory address you want to make available. In this case saying &thermotemp
means: “Please look at the address of where thermotemp is for the value, it’ll look like a double”.
I hope that helps!
Thanks,
David
Hi @Dave,
Hey, all up and running. Interigated through Atomiot and the spark simple web interface and working well. thank you very much.
I am going to try to get it onto a google spreadsheet…so lots of reading to do.
I also notice that on the projects page there is some thing about an iOS app that shows a dial with the temperature. Have you or anyone looked / used that?
Thank you again for your help.
Julian
Hi David,
I dont’ want to do that Ghostbusters thing of crossing the streams but I notice that there is a thread regarding sending data to Xively. I have an iOS app called pitchfork that takes the data from a Xively stream and displays it on your iOS device of choice. It has worked for me in the past using an electric imp as the “collection/detection/sending data to the internet” device.
I wondered if you had some drop in code that I could use to send my MAX 31855 data to Xively?
On the xively tutorials page they have info for IMP and UNO users. Should Spark core “get on that trian” also? Might help to advertise the platform (do you see what I did there…platform…train…I am wasted here!!! lol)
Cheers
Julian
Hi @Julian,
There have been a bunch of Xively threads, I think this one hit success:
I hope that helps!
Thanks,
David
I just got this working on my Photon and had to use the digital pins
int thermoCLK = D3;
int thermoCS = D2;
int thermoDO = D4;
Some questions to this old thread
How to use two probes and MAX31855?
Is it possible to use Maverick probes with the MAX3185 and if yes, how to wire them, because I have only one wire in the probe and MAX needs two input wires?
Thank you in advance