Project tutorial
IoT Wireless Infrared Kitchen (Cooking) Thermometer

IoT Wireless Infrared Kitchen (Cooking) Thermometer © CC BY

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

  • 1,317 views
  • 1 comment
  • 6 respects

Components and supplies

Ard nano
Arduino Nano R3
×1
Espressif NodeMCU V3 LoLin ESP8266
×1
DFRobot TS01 Non-contact IR Temperature Sensor
×1
5mm Common Anode RGB LED
×1
Button (6x6)
×1
4415447 jg5sklyzsj
Resistor 220 ohm
×3
DC Female Power Jack Connector
×1
External Battery
×1
12702 01
SparkFun Solder-able Breadboard - Mini
×2
11026 02
Jumper wires (generic)
×1

Necessary tools and machines

Hy gluegun
Hot glue gun (generic)

Apps and online services

About this project

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:

  • food and beverage temperatures,
  • the oven temperature,
  • refrigerator and freezer temperatures,
  • boiling and cooled milk temperatures while making yogurt,
  • hot oil temperature while deep frying.

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:

  • Cook_Temperature - Unit: °C
  • Cook_Temperature_F - Unit: °F

Huge thanks to DFRobot for sponsoring this project.

Sponsored products by DFRobot:

⭐ DFRobot TS01 Non-contact IR Temperature Sensor | Inspect

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['7b0e89bbe2'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357196/image_1iMT0CBYdL.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['783ec9432d'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357197/image_8FhUuMz633.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['45dd311a74'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357198/image_asAwpNe9Xe.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['b38feefccf'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357199/image_Xc8BceT2x0.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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:

  • Protocol ➡ Wi-Fi
  • Power Type ➡ Standard Power Consumption
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['ffc546526c'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357200/image_FwOemAVnRV.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['0d24583c43'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357201/image_XjyTf131xI.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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:

  • Cook_Temperature - 101 - Value
  • Cook_Temperature_F - 102 - Value
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['df2bed5c81'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357202/image_LBBe9eopYW.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['d1c20ec582'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357203/image_qngj28DdnN.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['bb7d6b4192'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357204/image_qywJlqUhmt.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['fc1994f1ca'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357206/image_ofvuRJkXPl.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['fdf8c86a40'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357207/image_mPf62gfstg.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['e6aa74a49e'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357209/image_GfhgbSsIvZ.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['bba6292619'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357210/image_oUeiDYjgis.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['a3e80a5be1'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357211/image_tkpIY6CVxv.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['b292e16752'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357212/image_mVQ1AYCMnP.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['9fba577e3f'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357213/image_DDOQE8AJSZ.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['a96fc7afa8'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357214/image_FODDWGHx9B.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['4ade7ed443'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357217/image_S3YlUWcU3N.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['1faf068f72'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357218/image_4ZgFetwQo9.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['596fde7160'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357221/image_O76UaCMv8Y.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

  • Burning Baud ➡ 921600
  • Test Baud ➡ 9600
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['55ecb2b5c7'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357222/image_vuYBcwxw7w.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['705979535b'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357223/image_1vcC2jPzzg.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['d4f08712bc'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357224/image_GZMSlXUjxF.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['2c85f18309'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357225/image_m3jRvDHm7H.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['69d44caff2'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357226/image_naBFsQbpyV.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['33b0ccae2c'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357228/image_4IRnvXlvTj.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['2f1187a0a2'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357230/image_PQQuFzVOEy.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['86285c57e3'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357231/image_EjfpAobXNG.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['c11466740f'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357232/image_DhEWKLBX2Q.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['3b6c24e108'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357233/image_1VxPbZw0ua.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['1b3318f07f'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357234/image_024Hf1GXGS.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['9aec6dbf17'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357236/image_riDmwhaibF.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['bdc46ec91d'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357237/image_0xUO4v2WBn.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['b68381421d'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357238/image_PKIOuyQwXI.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

⭐ 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['7673164244'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357239/image_txercmpe3J.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['173a6539e1'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357240/image_qtMhEUOTj6.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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);
}
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['77cad4660e'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357241/image_9cReTKFk7v.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['7f2e85d138'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357243/image_qkMom8eEIo.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['d11df0e718'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357244/image_ZO69qubrjT.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['2ca6b89359'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357245/image_YE4qjxUjZn.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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).

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['607d9e3732'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357248/image_nZpcJeMwwY.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['825f40dbc4'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357250/image_fiOwDHNeuJ.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['08309df680'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357251/image_d7TJlGqmbw.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['eb1b57c1e9'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357252/network_connection_Dpws1qpgFD.gif?auto=compress&gifq=35&w=1280&h=960&fit=max', caption: '', type: 'image' }];

🥘🍳 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.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['f342e0e3c4'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357253/image_QAUF7CTYvs.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

🥘🍳 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):

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['65691283ac'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357254/image_F1cGCfnLIS.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['a931ea2724'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357255/image_1XT6JQHx8d.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['9d37958833'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357256/image_vOOvzWApr6.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['ef0f6a1213'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357257/image_iTMHhZ01xZ.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

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

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['df932b1147'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/1357258/image_M2UyEn9qY4.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

Videos and Conclusion


Code

Wireless_Infrared_Kitchen_Thermometer.inoArduino
         /////////////////////////////////////////////  
        //     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));
}

Custom parts and enclosures

Fritzing
fritzing_f8OxQY9MGL.fzz
Tuya TYDA Install V2.7.2
tuya_tyda_install_v2_7_2_22DpNvuQ8e.zip

Schematics

Connections
Schematic stppdjo4rr

Comments

Similar projects you might like

Telegram-Enabled Thermal Printer w/ Arduino Nano 33 IoT

Project tutorial by Kutluhan Aktar

  • 12,363 views
  • 1 comment
  • 25 respects

IoT | TensorFlow Weather Station Predicts Rainfall Intensity

Project tutorial by Kutluhan Aktar

  • 8,361 views
  • 12 comments
  • 22 respects

IoT Using ESP8266-01 and Arduino

Project tutorial by Ahmed Ibrahim Ahmed

  • 52,030 views
  • 25 comments
  • 67 respects

IoT Thermometer Using Python

Project tutorial by Luigi Francesco Cerfeda

  • 14,058 views
  • 5 comments
  • 29 respects

Vegetables and Fruits Ripeness Detection by Color w/ TF

Project tutorial by Kutluhan Aktar

  • 4,437 views
  • 4 comments
  • 15 respects

IoT Interactive New Year Gift Card on Localhost

Project tutorial by Kutluhan Aktar

  • 1,793 views
  • 1 comment
  • 1 respect
Add projectSign up / Login