Ardino case with k type thermo for P1S temps pegb
Print Profile(1)

Description
Ardino case with k type thermo for P1S accurate chamber temp for PEG BOARD, reporting through MQTT into home assistant
also printed a simple lid to “stick on” using ESP8266
ardino code - rough and ready … modify as you see fit
#include <max6675.h>
#include<Arduino.h>
#include<Wire.h>
#include <U8g2lib.h>
#include "ESP8266WiFi.h"
#include "max6675.h"
#include <PubSubClient.h>
U8G2_SSD1306_128X64_NONAME_F_SW_I2C
u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
// WiFi parameters to be configured
const char* ssid = ""; // Write here your router's username
const char* password = ""; // Write here your router's passward
const char* mqtt_broker = "HERE"; //your MQTT host
const int mqtt_port = 1883;
const char* topic = "temp/3dprint";
const int clockPin = 5; //D1
const int selectPin = 4; //D2
const int dataPin = 0; //D3
MAX6675 thermocouple(clockPin, selectPin, dataPin);
long temp = 00.00;
char result[8]; // Buffer big enough for 7-character float
//dtostrf(resistance, 6, 2, result);
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// Connect to WiFi
WiFi.begin(ssid, password);
u8g2.begin();
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_7x14B_tr);
// while wifi not connected yet, print '.'
// then after it connected, get out of the loop
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
u8g2.drawStr(0,15,"CONNECTION FAILED");
}
//print a new line, then print WiFi connected and the IP address
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
//WiFi.localIP()
//u8g2.drawStr(0,15,WiFi.localIP().isValid());
u8g2.sendBuffer();
delay(1000);
client.setServer(mqtt_broker, mqtt_port);
client.connect("ESP8266","","");
}
void loop() {
// put your main code here, to run repeatedly:
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_inb38_mf);
temp = thermocouple.readCelsius();
Serial.println(temp);
dtostrf(temp, 6, 3, result);
u8g2.drawStr(0,60,result);
Serial.print("C = ");
// Serial.println(thermocouple.readCelsius());
Serial.println(temp);
//Serial.print("status :");
//Serial.println(thermocouple.);
Serial.println(WiFi.localIP());
u8g2.sendBuffer();
client.publish(topic, result);
if (!client.connected()) {
Serial.println("MQTT not connected");
}
delay(1000);
}






Comment & Rating (0)