forked from giljr/Ardu_Serie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_13_arduSerie_ThermoKitchen_Final.ino
262 lines (217 loc) · 7.39 KB
/
_13_arduSerie_ThermoKitchen_Final.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/*
Project name:
Arduino 1-Wire Thermocouple in the kitchen- 13 # arduSerie
Flavour I
Hex File: _13_arduSerie_ThermoKitchen_Final.ino
Revision History:
20160627:
Description:
This serie makes several experiments with thermocouple in the home kitchen.
The purpose is to record the temperature over time. We will experiment with
cheese bread, sandwich cheese, gelatin and more. Here we will make the
thermocouple works without any components. Get on!!! Check it over !!!
MCU: Arduino v.1.6.7 - @16MHz http://www.arduino.cc/
IC Chip: MAX31850K
https://www.adafruit.com/products/1727
Library: Adafruit_MAX31855_lib
https://github.com/adafruit/Adafruit-MAX31855-library
Connections:
See you.tube vid:
Based on https://learn.adafruit.com/thermocouple/using-a-thermocouple
Tutorial - Adafruit Learning System
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License v3 as published by
the Free Software Foundation
*/
/***************************************************
This is an example for the Adafruit Thermocouple Sensor w/MAX31855K
Designed specifically to work with the Adafruit Thermocouple Sensor
----> https://www.adafruit.com/products/269
These displays use SPI to communicate, 3 pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <Wire.h>
#include "Adafruit_MAX31855.h"
#include <LiquidCrystal.h>
#include "RTClib.h"
#include <SD.h>
RTC_DS1307 RTC;
// Example creating a thermocouple instance with software SPI on any three
// digital IO pins.
#define MAXDO 3
#define MAXCS 4
#define MAXCLK 5
#define LCD_LIGHT_PIN A2
// Initialize the Thermocouple
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);
// initialize the library with the numbers of the interface pins
//LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif
#define BACKLIGHT_PIN 13
int but = 2; // button to control when to display in LCD data
double c, i; // temperature in ºC and internal (for compensation on MAX31855 ic)
File myFile;
//LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7); // 0x27 is the I2C bus address for an unmodified backpack
LiquidCrystal lcd(A0, A1, 10, 9, 8, 7, 6);
//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
};
void setup()
{
Wire.begin();
RTC.begin();
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
}
if (!SD.begin(A3)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// Check to see if the file exists:
if (SD.exists("thermo.csv")) {
Serial.println("thermo.csv exists.");
// delete the file:
// Serial.println("Removing thermo.csv...");
// SD.remove("thermo.csv");
} else {
Serial.println("thermo.csv doesn't exist.");
}
// Set the lcd display backlight anode pin as an output.
pinMode(LCD_LIGHT_PIN, OUTPUT);
digitalWrite(LCD_LIGHT_PIN, LOW);
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
// Switch on the backlight
//lcd.setBacklightPin(3, NEGATIVE);
//lcd.setBacklight(LOW);
lcd.begin(16, 2); // initialize the lcd
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}
lcd.home (); // go home
lcd.print("Firmware v 0.1 ");
//lcd.setCursor ( 0, 1 ); // go to the next line
//lcd.print (" Date - jun 2016 ");
#ifndef ESP8266
while (!Serial); // will pause Zero, Leonardo, etc until serial console opens
#endif
Serial.begin(9600);
// set up the LCD's number of columns and rows:
//lcd.begin(16, 2);
//lcd.clear();
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("MAX31855 setup");
// wait for MAX chip to stabilize
delay(500);
delay ( 4000 );
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("thermo.csv", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
myFile.println("date/time, probe temp");
// close the file:
myFile.close();
}
}
void loop()
{
// Switch on the backlight
lcd.home ();
// Do a little animation by writing to the same location
for ( int i = 0; i < 2; i++ )
{
for ( int j = 0; j < 16; j++ )
{
lcd.print (char(random(7)));
}
lcd.setCursor ( 0, 1 );
}
delay (200);
if (digitalRead(but) == HIGH) // if you push the button to show the maximum rpm
{ // basic readout test, just print the current temp
// Switch on the backlight
//lcd.setBacklightPin(3, POSITIVE);
//lcd.setBacklight(LOW);
digitalWrite(LCD_LIGHT_PIN, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Int Temp = ");
lcd.println(thermocouple.readInternal());
Serial.print("Int. Temp = ");
i = thermocouple.readInternal();
Serial.println(i);
c = thermocouple.readCelsius();
lcd.setCursor(0, 1);
if (isnan(c))
{
lcd.print("T/C Problem");
}
else
{
lcd.print("C = ");
lcd.print(c);
lcd.print(" ");
//Serial.print("Thermocouple Temp = *");
//Serial.println(c);
}
delay(1000);
}
//lcd.setBacklightPin(3, NEGATIVE);
//lcd.setBacklight(HIGH);
digitalWrite(LCD_LIGHT_PIN, LOW);
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("thermo.csv", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
//Serial.print("Writing to thermo.csv...");
DateTime now = RTC.now();
myFile.print(now.year(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.day(), DEC);
myFile.print(' ');
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.print(now.second(), DEC);
myFile.print(" , ");
//delay(3000);
// myFile.print(i);
// myFile.print(" , ");
myFile.println(c);
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening thermo.csv");
}
delay(700);
}