The mechanism is simple to monitor the value of the water temperature sensor with the M5 stack, and the heater power is controlled by the relay to keep it at the set temperature.
Abridged general view
How to use low temperature cookers
It is salad chicken well seen in the convenience store. Although it was chicken meat, it was very juicy. It has become satisfactory.The setting was cooked at 60 degrees Celsius for 90 minutes.
Design drawings
Function
- Keeping water temperature at a set temperature
- When the temperature is reached, the heater is turned off and the heater is turned on when the temperature is lowered.
- Agitate water through the pump
- The shape of the container and the position of the heater might not need to pump, but it was necessary because the temperature unevenness was fine.
- Timer function
- I'll be notified by the buzzer in time.
- Temperature setting and timer settings can be set from the browser
- I made a web server in M5 stack, and set the temperature setting and timer setting from the browser such as sumaho in WiFi.
Source code
#include <OneWire.h>
#include <DS18B20.h>
#include <M5Stack.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#define ONE_WIRE_BUS 26
#define RELAY_PIN 2
// Wifi information
const char* host = "M5Stack";
const char* ssid = "*******";
const char* password = "******";
// Web page links
WebServer server(80);
const char* serverIndex = "<form method='POST' action='/regist' enctype='multipart/form-data'>Target Temp<input type='text' name='temp1'><br/>Re heat Temp<input type='text' name='temp2'><br />timer[min]<input type='text' name='timer'><br /><input type='submit' value='Regist'></form><a href= '../' >return top</a>";
// Temperature sensor
OneWire oneWire(ONE_WIRE_BUS);
DS18B20 sensor(&oneWire);
// Temperature control
float settei_temp = 63; // Set temperature
float saiKanetsu_temp = 62.5; // Reheating temperature
bool totatsu = false; // Have you reached the set temperature
unsigned long timer = 60 * 60 * 1000; // Timer [MS]
unsigned long targetTimer = 0; // Rise time [MS]
bool isStart = false; // Timer to start
bool relay = false; // Whether the relay is turned on
void setup(void)
{
M5.begin();
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(3);
M5.Lcd.printf("Wake up!");
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("DS18B20 Library version: ");
Serial.println(DS18B20_LIB_VERSION);
sensor.begin();
pinMode(RELAY_PIN, OUTPUT);// RELAY Pin setting
// WiFi connection
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() == WL_CONNECTED) {
Serial.println(WiFi.localIP());
M5.Lcd.printf("IP:%d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3] );
MDNS.begin(host);
// Temperature setting screen
server.on("/", HTTP_GET, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/html", serverIndex);
});
// Temperature input reception
server.on("/regist", HTTP_POST, []() {
String message = "Parameter received.";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
if (server.argName(i) == "temp1")
{
settei_temp = server.arg(i).toFloat();
}
else if (server.argName(i) == "temp2")
{
saiKanetsu_temp = server.arg(i).toFloat();
}
else if (server.argName(i) == "timer")
{
timer = (unsigned long)(server.arg(i).toInt()) * 60 * 1000; // min -> msec
}
isStart = false;
}
Serial.println(message);
server.sendHeader("Connection", "close");
server.send(200, "text/html", "<br /><a href= '../' >return top</a>");
});
server.begin();
MDNS.addService("http", "tcp", 80);
Serial.printf("Ready! Open http://%s.local in your browser\n", host);
M5.Lcd.printf("Ready!");
} else {
Serial.println("WiFi Failed");
M5.Lcd.printf("WiFi Failed.");
}
delay(5000);
}
// Beep
void beep()
{
for (int i = 0; i < 5; i ++)
{
M5.Speaker.tone(990, 500);
M5.update();
delay(500);
M5.update();
delay(100);
M5.update();
delay(100);
M5.update();
delay(100);
M5.update();
delay(100);
M5.update();
delay(100);
M5.update();
}
}
void loop(void)
{
M5.update();
server.handleClient(); //Web request
sensor.requestTemperatures();
while (!sensor.isConversionComplete()); // wait until sensor is ready
float temp = sensor.getTempC(); // Temperature acquisition
Serial.print("Temp: ");
Serial.println(temp);
M5.Lcd.clear(0x0000);
M5.Lcd.setCursor(10, 10);
M5.Lcd.printf("Temp:%.2f",temp);
// Temperature control
bool kanetsu = false; // Can it be heated
if (temp < saiKanetsu_temp)
{
totatsu = false;
kanetsu = true;
}
else if (temp < settei_temp)
{
if (totatsu)
{
kanetsu = false;
}
else
{
kanetsu = true;
}
}
else
{
totatsu = true;
kanetsu = false;
}
// Relay controlled heating
if (kanetsu)
{
if (relay == false)
{
digitalWrite(RELAY_PIN, HIGH);// RELAY Unit work
Serial.println("HIGH");
relay = true;
}
M5.Lcd.setCursor(10, 50);
M5.Lcd.printf("Heat");
}
else
{
if (relay)
{
digitalWrite(RELAY_PIN, LOW);// RELAY Unit stop work
Serial.println("LOW");
relay = false;
}
}
// Timer control
int rhour = 0;
int rmin = 0;
int rsec = 0;
if (isStart)
{
if (targetTimer <= millis())
{
// Completed
isStart = false;
beep();
}
// Calculating remaining time
else
{
unsigned long remain = targetTimer - millis();
rhour = (int)(remain / 1000 / 60 / 60);
rmin = (int)(remain % (1000 * 60 * 60) / 1000 / 60);
rsec = (int)(remain % (1000 * 60) / 1000);
}
}
// If the timer is not started, set the time
else
{
rhour = (int)(timer / 1000 / 60 / 60);
rmin = (int)(timer % (1000 * 60 * 60) / 1000 / 60);
rsec = (int)(timer % (1000 * 60) / 1000);
}
M5.Lcd.setCursor(10, 90);
M5.Lcd.printf("%dh%dm%ds", rhour, rmin, rsec);
// Set temperature indication
M5.Lcd.setCursor(10, 130);
M5.Lcd.printf("Target:%.2f",settei_temp);
M5.Lcd.setCursor(10, 170);
M5.Lcd.printf("Re-heat:%.2f",saiKanetsu_temp);
M5.Lcd.setCursor(40, 210);
M5.Lcd.printf("v Start");
// buttonA start
if (M5.BtnA.wasReleased()) {
isStart = true;
targetTimer = millis() + timer; // Set up time
Serial.println("Pushed Start.");
M5.Speaker.beep();
}
// Press B to release the prompt tone
else if (M5.BtnB.wasReleased())
{
beep();
}
delay(1000);
}
moritakuya
Comments