Programming

When in came to programming my board, the first thing I needed to do was to understand how I wnated the kiln to function. My idea was to make a kiln that can regulate the temperature. To do that what I wanted was to take temperature of kiln using the temperature sensor and programme my board in such a way that the temperature within the kiln is constantly maintained.
The following code is what I used in my final project.

                                        // this example is public domain. enjoy!
                                        // https://learn.adafruit.com/thermocouple/
                                        
                                        #include <max6675.h>
                                        #include <LiquidCrystal_I2C.h>
                                        #include <Wire.h>
                                        int thermoSO = 8;
                                        int thermoCS = 10;
                                        int thermoSCK = 13 ;
                                        int t;
                                        
                                        MAX6675 thermocouple(thermoSCK, thermoCS, thermoSO);
                                        
                                        LiquidCrystal_I2C lcd(0x27,16,2);
                                        
                                        // make a cute degree symbol
                                        
                                        uint8_t degree[8]  = {140,146,146,140,128,128,128,128};
                                        
                                        void setup() {
                                        
                                          pinMode(5, OUTPUT);
                                          
                                          // use Arduino pins 
                                         // pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
                                         // pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
                                          
                                          lcd.init();  // Print a message to the LCD.
                                          lcd.backlight();
                                           lcd.print("MAX6675 test");
                                           lcd.setCursor(0,1);
                                           lcd.print("Sonam");
                                          
                                          Serial.begin(9600);
                                          Serial.println("Test MAX6675");
                                        
                                          // wait for MAX chip to stabilize
                                          delay(500);
                                        }
                                        
                                        void loop() {
                                          // basic readout test, just print the current temp
                                          Serial.print("Temperature in Celsius = ");
                                          float temp= thermocouple.readCelsius();
                                          Serial.println(thermocouple.readCelsius());
                                          Serial.print("Temperature in Fahrenheit = ");
                                          Serial.println(thermocouple.readFahrenheit());
                                         
                                          lcd.clear();
                                          lcd.setCursor(0, 0);
                                          lcd.print("Temperature ");
                                          
                                          // go to line #1
                                          //LCD display temp in Celsius
                                          lcd.setCursor(0,1);
                                          lcd.print(thermocouple.readCelsius());
                                          lcd.setCursor(5,1);
                                          lcd.print((char)223);
                                          lcd.setCursor(6,1);
                                          lcd.print("C");
                                        
                                        //LCD display temp in Farenhiet
                                          lcd.setCursor(7,1);
                                          lcd.print(" ");
                                          lcd.setCursor(8,1);
                                          lcd.print(thermocouple.readFahrenheit());
                                          lcd.setCursor(14,1);
                                          lcd.print((char)223);
                                          lcd.setCursor(15,1);
                                          lcd.print("F");
                                          delay(1000);
                                        
                                          if (temp>80)
                                          {
                                          
                                            digitalWrite(5,LOW);
                                          }
                                          else
                                          {
                                            digitalWrite(5,HIGH);
                                          }
                                        }
                                        
                                        
                                        

As shown in the above code, I had to add a couple of libraries since I was working with 2 modules namely, I2C module for LCD and the MAX6675 module for k-type thermocouple. Next I define the pins of the MAX6675 module and also define the I2C LCD. In the code when I2C LCD is defined, the 0x27 is the address of the LCD and the (16,2) is the number of characters that can be displayed on the LCD meaning the LCD has 16 columns and 2 rows.
This code is used to create the degree sign for display on LCD

Next, I had to define the output pin. The output pin 5 is connected to the relay. Next, I wrote a couple of codes for displaying a messange when the LCD gets turned on.


The foloowing code is for reading the temperature of the kiln using the k-type thermocouple and displaying the temperature read on the LCD screen. The temperature is displayed in real time.


The final block of code is what controls the kiln temperature. Here, when the temperature goes above 80 degrees, the coil is automatically turned off and when the temperature goes below 80, the coil gets turned on. Hence the temperature is maintained at the defined temperature requirement.

Testing

After I had finished the programming, I tested to check if the code was working properly. I defined the require temperature at 25 degrees. Then, I kept 2 cups, one filled with cold water and another with hot water. After connecting all the part and loading the program to my board, I dipped the thermocouple in the cold and hot water alternatively to check if the relay responds to the temperature change read by the thermocouple as programmed.
The following video show the testing phase.