Sitemap / Advertise

Introduction

Monitor and track temperature remotely while cooking foods with pots, pans, saucepans, woks, etc., on Tuya Cloud compatible w/ Android and iOS.


Tags

Share

IoT Wireless Infrared Kitchen (Cooking) Thermometer

Advertisement:


read_later

Read Later



read_later

Read Later

Introduction

Monitor and track temperature remotely while cooking foods with pots, pans, saucepans, woks, etc., on Tuya Cloud compatible w/ Android and iOS.

Tags

Share





Advertisement

Advertisement




    Components :
  • [1]Arduino Nano
  • [1]NodeMCU V3 LoLin ESP8266
  • [1]DFRobot TS01 Non-contact IR Temperature Sensor
  • [1]5mm Common Anode RGB LED
  • [1]Button (6x6)
  • [3]220Ω Resistor
  • [1]DC Female Power Jack Connector
  • [1]External Battery
  • [2]Mini Breadboard
  • [1]Jumper Wires

Description

I am fond of cooking and trying different recipes to expand my knowledge about foods. And, as an electronics enthusiast, I enjoy tinkering with gadgets to get more precise measurements while cooking. In that way, I ensure delicious and consistent outcomes with little effort. To measure the internal temperature of foods (roasts, steaks, etc.), I utilize a meat thermometer while cooking. Although meat thermometers can easily monitor the internal temperature to avoid overcooking and serving dried-out food, they lack the ability to measure the surface temperature. Thus, I decided to develop a wireless infrared kitchen thermometer from scratch.

An infrared kitchen thermometer can be employed to verify:

I decided to use the Tuya IoT Platform in this project because it allowed me to develop a mobile application interface compatible with various operating systems (Android and iOS). In the following steps, I will explain how I benefited from the Tuya IoT Platform to improve this project in detail.

To get accurate temperature measurements, I utilized a DFRobot TS01 IR temperature sensor. This sensor can measure the surface temperature from -70°C to 380°C while providing a maximum accuracy of 0.5°C.

Finally, I added a 5mm common anode RGB LED to show the connection status between the infrared thermometer and the Tuya Cloud.

On the thermometer's mobile application interface supported by the Tuya Cloud, the user can monitor two different data points regarding the surface temperature:

Huge thanks to DFRobot for sponsoring this project.

Sponsored products by DFRobot:

⭐ DFRobot TS01 Non-contact IR Temperature Sensor | Inspect

project-image
Figure - 68.1


project-image
Figure - 68.2

Step 1: Creating a new product on the Tuya IoT Platform

Tuya Smart is a global IoT platform that enables smart home products to come to life for brands, OEMs, manufacturers, and retail chains. But, Tuya is not providing its services and APIs for companies only. Tuya has established an IoT cloud platform that delivers a full suite of offerings to developers, including Platform-as-a-Service (PaaS), Software-as-a-Service (SaaS), and other cloud-based services. Tuya Cloud Platform has built a thriving ecosystem providing more than 410,000 product SKUs in over 1,100 categories, covering over 220 countries and regions.

Tuya IoT Platform lets the user develop a smart product from scratch and provides built-in functions for different product types. Furthermore, Tuya SDKs allow controlling a registered and authorized product with a development board via serial communication. You can get more information about Tuya SDKs from the Tuya Developer Platform.

project-image
Figure - 68.3

While employing the Tuya IoT Platform to create a custom product for this project, I decided to convert a NodeMCU V3 LoLin ESP8266 to a registered and authorized Tuya product. Then, I used an Arduino Nano to communicate with the authorized product (ESP8266). With Tuya's official Arduino library, the Arduino Nano can communicate with the authorized product via serial communication to send data to the Tuya Cloud and receive commands from the Tuya Cloud when connected to the Tuya Smart app.

project-image
Figure - 68.4

⭐ First of all, go to the Tuya account registration page and create a developer account.

⭐ Then, go to the Tuya IoT Platform and click:

Create ➡ Can't find the category?

⭐ Enter the required product information:

project-image
Figure - 68.5


project-image
Figure - 68.6

⭐ After creating the product, select the features you want to add to your product from Standard functions or create new ones (Custom) if not supported by Standard functions.

Standard functions indicate the functions provided by Tuya for their product categories. Since there are lots of built-in products, it is easy to find the functions you need. Also, you can create your specialized functions named Custom functions, depending on your project.

The data point (DP) is the abstract representation of a function, and each function has an ID and data type.

Data Point ID (DP ID): indicates the code of a data point (function). Tuya Cloud sends or receives data through data point IDs.

Data Types: Boolean, Value (Integer), Enum, Fault, Char, and RAW.

Since there are built-in functions (Standard) provided by Tuya for cooking thermometers, I did not have to create custom functions for my product:

project-image
Figure - 68.7


project-image
Figure - 68.8


project-image
Figure - 68.9

⭐ Then, go to the Hardware Development and select the TYWE3S Wi-Fi Module under the Tuya Standard Module SDK. It has an indistinguishable pinout to the ESP-12E (ESP8266) module.

project-image
Figure - 68.10


project-image
Figure - 68.11

Step 1.1: Developing a mobile application interface (Device Panel)

⭐ After creating the product successfully, go to the Device Panel. Then, click the Create Blank Panel under the Visualized DIY Panel.

project-image
Figure - 68.12

⭐ Now, design the panel (mobile application interface) with the drag-and-drop components. It is similar to the MIT App Inventor.

project-image
Figure - 68.13

⭐ After designing the panel, click the Release button and enter the required information.

project-image
Figure - 68.14

⭐ Finally, download the Tuya Smart app on Android or iOS and sign up.

I will show you how to use the Tuya Smart app to connect to the authorized product (ESP8266) in the following steps.

project-image
Figure - 68.15

Step 2: Registering and authorizing the ESP8266 as a Tuya product

To be able to use the NodeMCU V3 LoLin ESP8266 as a Tuya product for this project, you need to flash and authorize it with the required firmware.

To authorize the ESP8266, you have to elicit a Token ID for your product. After sending the product ID (PID) with your Tuya IoT account name (e-mail) to dev@tuya.com, Tuya developers will provide you with the Token ID. Then, follow the steps below:

⭐ First of all, go to the Tuya Smart PMS system and create a developer account.

project-image
Figure - 68.16


project-image
Figure - 68.17

⭐ Then, go to Production Manage ➡ Work Order Management ➡ Activation Code Verification. To activate the production certificate for the product, enter the Token ID. When the Token ID is confirmed, the ESP8266 is ready to be flashed and authorized.

project-image
Figure - 68.18


project-image
Figure - 68.19

⭐ After confirmation, download the latest version of the Cloud Module Test Platform from Knowledge Base Management ➡ Software Download. You can find a copy in the Downloads.

project-image
Figure - 68.20

⭐ After downloading the Cloud Module, open it and log in. Then, go to File ➡ Set Up and enter the required settings as shown below:

project-image
Figure - 68.21

⭐ Click Enter Token ➡ Token and paste the Token ID under the Burning Authorization. Do not forget to select Firmware Download.

project-image
Figure - 68.22

⭐ Now, connect the NodeMCU V3 LoLin ESP8266 to the computer via a USB cable and select its port number, such as COM5. If you did not use it with the Arduino IDE or other compilers before, you may need to install its driver.

project-image
Figure - 68.23

⭐ Finally, click Run to flash and authorize the ESP8266 as a Tuya product.

project-image
Figure - 68.24

Step 3: Pairing the ESP8266 with the Tuya Smart app compatible w/ Android and iOS

After flashing and authorizing the ESP8266 as a Tuya product, it is easy to connect it to the Tuya Cloud via the Tuya Smart app to send and receive data.

The product (ESP8266) must be in the network connection mode to establish a connection with the Tuya Smart app. As explained in the following steps, I assigned a button on the device to deploy the network connection mode when pressed.

⭐ First of all, press the network connection button on the device until the RGB LED blinks green.

project-image
Figure - 68.25

⭐ Then, open the Tuya Smart app and log in.

project-image
Figure - 68.26

⭐ Go to Add Device ➡ Add Manually ➡ Others ➡ Others (Wi-Fi).

project-image
Figure - 68.27


project-image
Figure - 68.28


project-image
Figure - 68.29

⭐ Connect to a Wi-Fi Network (2.4 GHz).

project-image
Figure - 68.30


project-image
Figure - 68.31

⭐ When the Tuya Smart app finds a product on the network with the given settings, the app adds that product and connects it to the Tuya Cloud automatically.

project-image
Figure - 68.32


project-image
Figure - 68.33


project-image
Figure - 68.34

⭐ Once connected, open the mobile application interface (device panel) to monitor temperature measurements produced by the infrared kitchen thermometer via the TS01 IR temperature sensor.

project-image
Figure - 68.35


project-image
Figure - 68.36

Step 4: Programming the Arduino Nano and sending temperature measurements to the Tuya Cloud

Download the Tuya MCU SDK Arduino Library to communicate with the Tuya Device (ESP8266):

Tuya MCU SDK Arduino Library | Library

⭐ Include the required libraries and define the Tuya Device (ESP8266) with its connection settings.


// Include the required libraries.
#include <TuyaWifi.h>
#include <SoftwareSerial.h>

// Define the Tuya Device:
SoftwareSerial conn(8, 9); // RX, TX
TuyaWifi my_device(&conn);

// Define Tuya Device connection status settings:
unsigned char led_state = 0;
int wifi_key_pin = 7;

⭐ Define the data points (DPs) of the Tuya Device (ESP8266).

⭐ Enter the PID (product ID) and MCU software version of the Tuya Device.


// Define data points (DPs) of the Tuya Device:
#define DPID_Cook_Temperature 101
#define DPID_Cook_Temperature_F 102

// Stores all DPs and their types. PS: array[][0]:dpid, dp type(TuyaDefs.h) : DP_TYPE_RAW, DP_TYPE_BOOL, DP_TYPE_VALUE, DP_TYPE_STRING, DP_TYPE_ENUM, DP_TYPE_BITMAP
unsigned char dp_array[][2] =
{
  {DPID_Cook_Temperature, DP_TYPE_VALUE},
  {DPID_Cook_Temperature_F, DP_TYPE_VALUE},
};

// Define the Tuya Device Information:
unsigned char pid[] = {"Enter_PID"};
unsigned char mcu_ver[] = {"3.1.4"};

⭐ Define the TS01 IR temperature sensor and RGB LED pins:


// Define the IR Temperature Sensor pin:
#define IR_Sensor A0

// Define RGB pins:
#define redPin 3
#define greenPin 5
#define bluePin 6

⭐ Initialize networking keys and set the required functions for the Tuya Device.


  // Initialize networking keys.
  pinMode(wifi_key_pin, INPUT_PULLUP);
  // Enter the PID and MCU software version:
  my_device.init(pid, mcu_ver);
  // Incoming all DPs and their types array, DP numbers:
  my_device.set_dp_cmd_total(dp_array, 2);
  // Register DP download processing callback function:
  my_device.dp_process_func_register(dp_process);
  // Register upload all DP callback function:
  my_device.dp_update_all_func_register(dp_update_all);
  // Define the last time:
  last_time = millis();

⭐ Start the serial communication (software serial) with the Tuya Device.

⭐ Activate the network connection mode when the network connection button (Wi-Fi Key Pin) is pressed.

⭐ RGB LED blinks green while the Tuya Device is attempting to connect to the Wi-Fi network.

⭐ If the Tuya Device (ESP8266) is connected successfully to the cloud server (Tuya Cloud), RGB LED turns blue.


  // Start the serial communication with the Tuya Device:
  my_device.uart_service();
  // Activate the network connection mode when the network connection button (WiFi Key Pin) is pressed.
  if (digitalRead(wifi_key_pin) == LOW) {
    delay(80);
    if (digitalRead(wifi_key_pin) == LOW) {
      my_device.mcu_set_wifi_mode(SMART_CONFIG);
    }
  }
  // RGB LED blinks green when the Tuya Device is attempting to connect to the network:
  if((my_device.mcu_get_wifi_work_state() != WIFI_LOW_POWER) && (my_device.mcu_get_wifi_work_state() != WIFI_CONN_CLOUD) && (my_device.mcu_get_wifi_work_state() != WIFI_SATE_UNKNOW)) {
    if(millis()- last_time >= 500){
      last_time = millis();
      // Adjust:
      if(led_state == LOW){ led_state = HIGH; adjustColor(0,255,0); } else{ led_state = LOW; adjustColor(0,0,0); }
    }
  }
  // If the Tuya Device (ESP8266) is connected to the cloud server:
  if(my_device.mcu_get_wifi_work_state() == WIFI_CONN_CLOUD){
    adjustColor(0,0,255);
  }
  delay(10);

⭐ Elicit temperature measurements generated by the TS01 IR sensor.

⭐ Then, update Cook_Temperature (°C) and Cook_Temperature_F (°F) data points of the Tuya Device.


  // Get temperature measurements from the IR sensor and update the Tuya Cloud.
  get_data_from_IR_sensor();
  my_device.mcu_dp_update(DPID_Cook_Temperature, tem_celsius, 1);
  my_device.mcu_dp_update(DPID_Cook_Temperature_F, tem_fahrenheit, 1);

⭐ In the get_data_from_IR_sensor function, get the signal value (ADC) produced by the TS01 IR sensor and elicit the temperature measurement in Celsius with this formula:

tem_celsius = ((double)ADC_Value*450/614.4-70)

⭐ Then, convert Celsius to Fahrenheit and print the temperature measurement (°C) on the serial monitor.

tem_fahrenheit = (tem_celsius * 1.8) + 32


void get_data_from_IR_sensor(){
  unsigned int ADC_Value = analogRead(IR_Sensor);
  tem_celsius = ((double)ADC_Value*450/614.4-70);
  tem_fahrenheit = (tem_celsius * 1.8) + 32;
  Serial.print("Temperature: ");
  Serial.print(tem_celsius);
  Serial.println("\u2103");
  delay(100); 
}

⭐ In the dp_update_all function, update all data points (DPs) with default values - 1, 50:


void dp_update_all(void){
  // Update all DPs with default values:
  my_device.mcu_dp_update(DPID_Cook_Temperature, 1, 1);
  my_device.mcu_dp_update(DPID_Cook_Temperature_F, 50, 1);
}

project-image
Figure - 68.37


project-image
Figure - 68.38


project-image
Figure - 68.39


project-image
Figure - 68.40

Connections and Adjustments


// Connections
// Arduino Nano :  
//                                NodeMCU V3 LoLin ESP8266
// D8  --------------------------- TX 
// D9  --------------------------- RX
//                                DFRobot TS01 Non-contact IR Temperature Sensor
// A0  --------------------------- S     
//                                5mm Common Anode RGB LED
// D3  --------------------------- R
// D5  --------------------------- G
// D6  --------------------------- B
//                                Network Connection Button
// D7  --------------------------- S

First of all, I connected all components to the Arduino Nano by using jumper wires and two mini breadboards, including the NodeMCU V3 LoLin ESP8266 (Tuya Device). I utilized a 12V external battery to supply the device (infrared kitchen thermometer).

project-image
Figure - 68.41

Then, I placed the Arduino Nano and the ESP8266 in a raspberry-shaped ceramic sugar bowl to hide abundant wirings.

project-image
Figure - 68.42

Finally, I fastened all parts with a hot glue gun.

project-image
Figure - 68.43

Modes and Features

🥘🍳 The device activates the network connection mode if the network connection button is pressed. Then, the RGB LED blinks green while the NodeMCU V3 LoLin ESP8266 (Tuya Device) is attempting to connect to the Wi-Fi network via the Tuya Smart app.

project-image
Figure - 68.44

🥘🍳 If the NodeMCU V3 LoLin ESP8266 (Tuya Device) connects to the Tuya Cloud via the Tuya Smart app successfully, the device turns the RGB LED to blue.

project-image
Figure - 68.45

🥘🍳 Once initiated, the device updates the data points in the Tuya Cloud automatically. Then, the Tuya Smart app allows the user to observe the temperature measurements in Celsius and Fahrenheit on the mobile application interface (Device Panel):

project-image
Figure - 68.46


project-image
Figure - 68.47


project-image
Figure - 68.48


project-image
Figure - 68.49

🥘🍳 Also, the device displays the temperature measurements (°C) on the serial monitor.

project-image
Figure - 68.50

Videos and Conclusion


Code

Wireless_Infrared_Kitchen_Thermometer.ino

Download



         /////////////////////////////////////////////  
        //     IoT Wireless Infrared Kitchen       //
       //          (Cooking) Thermometer          //
      //             ---------------             //
     //         (Arduino Nano & ESP8266)        //           
    //             by Kutluhan Aktar           // 
   //                                         //
  /////////////////////////////////////////////

//
// Monitor and track temperature remotely while cooking foods with pots, pans, saucepans, woks, etc., on Tuya Cloud compatible w/ Android and iOS.
//
// For more information:
// https://www.theamplituhedron.com/projects/IoT_Wireless_Infrared_Kitchen_(Cooking)_Thermometer/
//
//
// Connections
// Arduino Nano :  
//                                NodeMCU V3 LoLin ESP8266
// D8  --------------------------- TX 
// D9  --------------------------- RX
//                                DFRobot TS01 Non-contact IR Temperature Sensor
// A0  --------------------------- S     
//                                5mm Common Anode RGB LED
// D3  --------------------------- R
// D5  --------------------------- G
// D6  --------------------------- B
//                                Network Connection Button
// D7  --------------------------- S


// Include the required libraries.
#include <TuyaWifi.h>
#include <SoftwareSerial.h>

// Define the Tuya Device:
SoftwareSerial conn(8, 9); // RX, TX
TuyaWifi my_device(&conn);

// Define Tuya Device connection status settings:
unsigned char led_state = 0;
int wifi_key_pin = 7;

// Define data points (DPs) of the Tuya Device:
#define DPID_Cook_Temperature 101
#define DPID_Cook_Temperature_F 102

// Stores all DPs and their types. PS: array[][0]:dpid, dp type(TuyaDefs.h) : DP_TYPE_RAW, DP_TYPE_BOOL, DP_TYPE_VALUE, DP_TYPE_STRING, DP_TYPE_ENUM, DP_TYPE_BITMAP
unsigned char dp_array[][2] =
{
  {DPID_Cook_Temperature, DP_TYPE_VALUE},
  {DPID_Cook_Temperature_F, DP_TYPE_VALUE},
};

// Define the Tuya Device Information:
unsigned char pid[] = {"Enter_PID"};
unsigned char mcu_ver[] = {"3.1.4"};

// Define the IR Temperature Sensor pin:
#define IR_Sensor A0

// Define RGB pins:
#define redPin 3
#define greenPin 5
#define bluePin 6

// Define the data holders:
unsigned long last_time = 0;
int tem_celsius, tem_fahrenheit;

void setup() {
  Serial.begin(9600);
  conn.begin(9600);
  
  // RGB:
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  adjustColor(0,0,0);
    
  // Initialize networking keys.
  pinMode(wifi_key_pin, INPUT_PULLUP);
  // Enter the PID and MCU software version:
  my_device.init(pid, mcu_ver);
  // Incoming all DPs and their types array, DP numbers:
  my_device.set_dp_cmd_total(dp_array, 2);
  // Register DP download processing callback function:
  my_device.dp_process_func_register(dp_process);
  // Register upload all DP callback function:
  my_device.dp_update_all_func_register(dp_update_all);
  // Define the last time:
  last_time = millis();

}

void loop() {
  // Start the serial communication with the Tuya Device:
  my_device.uart_service();
  // Activate the network connection mode when the network connection button (WiFi Key Pin) is pressed.
  if (digitalRead(wifi_key_pin) == LOW) {
    delay(80);
    if (digitalRead(wifi_key_pin) == LOW) {
      my_device.mcu_set_wifi_mode(SMART_CONFIG);
    }
  }
  // RGB LED blinks green when the Tuya Device is attempting to connect to the network:
  if((my_device.mcu_get_wifi_work_state() != WIFI_LOW_POWER) && (my_device.mcu_get_wifi_work_state() != WIFI_CONN_CLOUD) && (my_device.mcu_get_wifi_work_state() != WIFI_SATE_UNKNOW)) {
    if(millis()- last_time >= 500){
      last_time = millis();
      // Adjust:
      if(led_state == LOW){ led_state = HIGH; adjustColor(0,255,0); } else{ led_state = LOW; adjustColor(0,0,0); }
    }
  }
  // If the Tuya Device (ESP8266) is connected to the cloud server:
  if(my_device.mcu_get_wifi_work_state() == WIFI_CONN_CLOUD){
    adjustColor(0,0,255);
  }
  delay(10);

  // Get temperature measurements from the IR sensor and update the Tuya Cloud.
  get_data_from_IR_sensor();
  my_device.mcu_dp_update(DPID_Cook_Temperature, tem_celsius, 1);
  my_device.mcu_dp_update(DPID_Cook_Temperature_F, tem_fahrenheit, 1);

}

unsigned char dp_process(unsigned char dpid,const unsigned char value[], unsigned short length){
  /* all DP only report */
  return SUCCESS;
}

void dp_update_all(void){
  // Update all DPs with default values:
  my_device.mcu_dp_update(DPID_Cook_Temperature, 1, 1);
  my_device.mcu_dp_update(DPID_Cook_Temperature_F, 50, 1);
}

void get_data_from_IR_sensor(){
  unsigned int ADC_Value = analogRead(IR_Sensor);
  tem_celsius = ((double)ADC_Value*450/614.4-70);
  tem_fahrenheit = (tem_celsius * 1.8) + 32;
  Serial.print("Temperature: ");
  Serial.print(tem_celsius);
  Serial.println("\u2103");
  delay(100); 
}

void adjustColor(int r, int g, int b){
  analogWrite(redPin, (255-r));
  analogWrite(greenPin, (255-g));
  analogWrite(bluePin, (255-b));
}


Schematics

project-image
Schematic - 68.1

Downloads

Fritzing

Download


Tuya TYDA Install V2.7.2

Download