I recently bought a photon maker kit for a school project. I am new to the photon and programming in general. I have a project for school. I would like to adapt a thermocouple to the photon, publish the data to the cloud to record for iot and read the temperature in fahrenheit on the OLED screen that comes in the kit. I have done some small projects such as leds and hooked the OLED display up with the “hello world” code. I have also used code that turned it into a clock. Both display projects were in SPI I believe. I was wondering what I would need for coding and hardware. I saw that adafruit has a MAX31855 opamp circuit. Would this work with the photon for what I need?
@jhypes, Particle provides both the web IDE and a local Particle CLI for developing your code in C++. If you are familiar with Arduino, you will have no problems programming for the Photon. The IDE provides the editor and compiler and lets you program your device wirelessly (OTA). With the CLI you use your own editor but you can program wirelessly or directly via USB. I suggest you start with the web IDE.
The MAX31855 thermocouple interface is great for K-type thermocouples. There is also a new MAX31856 board with internal linearization for any thermocouple type. Both boards use 3-wire SPI and are super simple to use. There is already a MAX31855 library available for the photon on the IDE. I have used both boards and they work very well.
As for the OLED, you will need to tell us which model you intend to use. Some are SPI, others are I2C. There are a number of OLED display libraries on the IDE.
This project will be very simple and fun to put together. This community will be more than happy to assist you.
Thanks for your quick reply. The kit contents dont give a model # on the display. It just says: This is a 128x64 pixel graphic OLED screen that can be either controlled via the SPI (default) or I2C. I saw a few codes that are for the MAX31855 but wasnt sure which one I needed. One published to the cloud and the other looked like it was for a core and just went to a display. Im going to order my a 31855 or 31856 later today. Should be a fun project. I hope to learn alot.
@jhypes, I missed the “photon maker kit” part! Kind of funny that one of the suggested library is from my github repo! I’ll be publishing a new library for the display in the next few days. The existing ones are more than suitable as well. The libraries for both the MAX31855 and MAX31856 on the IDE are all good as well.
With the Photon, you will be able to display and publish your temperatures. You could use Blynk with your mobile device or send data to Ubidots. Your biggest problem will be having so many choices!
That display is an SSD1306 which can be used as SPI and I2C.
So I found the code below and was trying to get it to compile. It has the serial.prints turned off. But im getting the errors pictured below.
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_MAX31855/Adafruit_MAX31855.h"
#include "math.h"
int thermoCLK = D2;
int thermoCS = D3;
int thermoDO = D4;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
while(!Serial);
Serial.begin(9600);
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
// basic readout test, just print the current temp
double temp = thermocouple.readCelsius();
double int_temp = thermocouple.readInternal();
//double c = thermocouple_0.readCelsius();
// Serial.print("Internal Temp = ");
// Serial.println(thermocouple.readInternal());
//Serial.print("Internal Temp 0= ");
//Serial.println(int_temp0);
//Serial.print("Internal Temp 1= ");
//Serial.println(int_temp1);
Particle.publish("internaltemperature", String(int_temp), 1, PRIVATE);
if (isnan(temp)) {
//Serial.println("Something wrong with thermocouple 0!");
Particle.publish("thermocouple0", "Something wrong with thermocouple!", 1, PRIVATE);
}
else {
//Serial.print("C 0= ");
//Serial.println(temp0);
Particle.publish("thermocouple0", String(temp), 1, PRIVATE);
}
//Serial.print("F = ");
//Serial.println(thermocouple.readFarenheit());
delay(2000);
}
Hmm, can you try removing the first line comment?
I tried that but it still would not compile.
Try this code that builds as is on my Web IDE
#include <Adafruit_MAX31855.h>
#include "math.h"
int thermoCLK = D2;
int thermoCS = D3;
int thermoDO = D4;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
void setup() {
Serial.begin(9600);
delay(500);
}
void loop() {
double temp = thermocouple.readCelsius();
double int_temp = thermocouple.readInternal();
Particle.publish("internaltemperature", String(int_temp), 1, PRIVATE);
if (isnan(temp)) {
Particle.publish("thermocouple0", "Something wrong with thermocouple!", 1, PRIVATE);
}
else {
Particle.publish("thermocouple0", String(temp), 1, PRIVATE);
}
delay(2000);
}
@jhypes, did you add the Adafruit_MAX31855 library to your project?
do you just choose use this example or add to project once you find the library?
@jhypes, if you want to use one of the examples, it will automatically add the library. Otherwise, with your own app, you will need to add it to the project (after which you chose your application and confirm).
I found the max31855 library and included them in the project but it still gave the same errors.
What system version are you targeting?
There are two MAX31855 libraries. You need to import the one with the higher usage count (Adafruit_MAX31855
and not Adafruit-MAX31855
) for the code I provided to build.
Could you also provide a screenshot of your Web IDE with the code drawer (<>
) open?
Nevermind. I got it to compile. It had a “>” at the beginning of every command. Deleted those and it compiled.