/*************************************************** This is an example for the Adafruit Thermocouple Sensor w/MAX31855K Designed specifically to work with the Adafruit Thermocouple Sensor and ledunia ----> https://www.adafruit.com/products/269 ----> http://www.ledunia.de Author: Christian Zeh ****************************************************/ #include #include "Adafruit_MAX31855.h" // Version 1.0.3 #include #include #include #include #include // Customized version, see attachment #define OLED_RESET 4 byte mac[] = { 0x18, 0xFE, 0x34, 0xEE, 0x40, 0xBF }; //physical mac address String readString; extern "C" { #include "user_interface.h" } #define MAXDO 3 // ledunia (GPIO-3) -> D0 #define MAXCS 14 // ledunia (GPIO 14)-> CS #define MAXCLK 2 // ledunia (GPIO 2) -> CLK // initialize the Thermocouple Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO); Adafruit_SSD1306 display(OLED_RESET); //define your wifi credentials: const char* ssid = "YOUR_SSID"; // Don't forget to change it const char* password = "YOUR_PASSWORD"; // Don't forget to change it const char* DNSNAME = "YOUR_DNS_NAME"; // Don't forget to change it MDNSResponder mdns; // Create an instance of the server // specify the port to listen on as an argument WiFiServer server(80); //save the tiny bbq icon as array const unsigned char PROGMEM bbq [] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x18, 0x00, 0x00, 0x01, 0xF8, 0xF0, 0x38, 0x00, 0x00, 0x03, 0xF0, 0xF8, 0x78, 0x00, 0x00, 0x03, 0xF0, 0xFF, 0xF8, 0x00, 0x00, 0x03, 0xF0, 0xFF, 0xF8, 0x00, 0x00, 0x03, 0xF0, 0x7E, 0x78, 0x00, 0x00, 0x03, 0xF0, 0x18, 0x78, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x0E, 0x7F, 0xFF, 0xFC, 0x00, 0x00, 0x0C, 0x1F, 0xFF, 0xFC, 0x00, 0x00, 0x0C, 0x1F, 0xFF, 0xFC, 0x00, 0x00, 0x04, 0x0F, 0xFF, 0xFC, 0x00, 0x00, 0x06, 0x0F, 0xFF, 0xF8, 0x00, 0x00, 0x03, 0x07, 0xFF, 0xF8, 0x00, 0x00, 0x03, 0x83, 0xFF, 0xF0, 0x00, 0x00, 0x01, 0xC1, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x71, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x18, 0xC3, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC3, 0x80, 0x00, 0x00, 0x00, 0x60, 0xC1, 0x80, 0x00, 0x00, 0x00, 0x60, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x60, 0x00, 0x00, 0x01, 0x80, 0xC0, 0x60, 0x00, 0x00, 0x01, 0x80, 0xC0, 0x30, 0x00, 0x00, 0x01, 0x00, 0xC0, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x2B, 0x4F, 0x67, 0x42, 0x38, 0x7B, 0xEA, 0x86, 0xB2, 0x28, 0xC7, }; void setup() { Serial.begin(115200); Wire.begin(12, 5); //Wire changing because of LED SDA from 4 to 12 while (!Serial) delay(1); // wait for Serial on Leonardo/Zero, etc Serial.println("MAX31855 test"); // wait for MAX chip to stabilize delay(500); WiFi.begin(ssid, password); //WiFi.config(ip, gateway, subnet); while (WiFi.status() != WL_CONNECTED) { delay(500); //WiFi.begin(ssid, password); Serial.print("."); } if (mdns.begin((DNSNAME), WiFi.localIP())) { Serial.println("MDNS responder started"); } Serial.println(""); Serial.println("WiFi connected"); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.println(WiFi.localIP()); display.begin(SSD1306_SWITCHCAPVCC, 0x78 >> 1); //display.display(); display.clearDisplay(); display.drawBitmap( 40, 0, bbq, 48, 48, 1); display.display(); delay(3000); display.clearDisplay(); } void loop() { // basic readout test, just print the current temp digitalWrite(LED_BUILTIN, HIGH); Serial.print("Internal Temp = "); Serial.println(thermocouple.readInternal()); double temperatureC = thermocouple.readCelsius(); if (isnan(temperatureC)) { Serial.println("Something wrong with thermocouple!"); } else { Serial.print("C = "); Serial.println(temperatureC); } Serial.print("F = "); Serial.println(thermocouple.readFarenheit()); //get free heap size String heap = String(system_get_free_heap_size() / 10); // Signalstrength in dBm int32_t rssi = wifi_station_get_rssi(); display.clearDisplay(); display.setTextSize(1); display.setCursor(5, 1); display.println(" PRTG BBQ Meter"); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(10, 20); display.print((char)248); display.print("C:"); display.print(temperatureC); display.setCursor(5, 40); display.setTextSize(1); display.print("IP: "); display.println(WiFi.localIP()); display.setCursor(5, 50); display.setTextSize(1); display.print("dbm: "); display.println(rssi); display.setCursor(60, 50); display.setTextSize(1); display.print((char)248); display.print("F: "); display.println(thermocouple.readFarenheit()); display.display(); display.clearDisplay(); delay(100); // Create a client connection WiFiClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read(); //read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') { client.println("HTTP/1.1 200 OK"); client.println("Content-Type: application/json;charset=utf-8"); client.println("Server: Arduino"); client.println("Connnection: close"); client.println(); client.print("{"); client.print("\"Temperature_C\": "); client.print(temperatureC); client.print(", "); client.print("\"Temperature_F\": "); client.print(thermocouple.readFarenheit()); client.print(", "); client.print("\"rssi\": "); client.print(rssi); client.print(", "); client.print("\"heap\": "); client.print(heap); client.print("}"); client.println(); //stopping client client.stop(); delay(100); } ///c=n } //client available } //client connected } //if client } //loop