Water Heater Controller Using ESP8266 Module

Publisher:电子设计探索者Latest update time:2023-06-19 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This article will share with you how to implement the code running on ESP8266. In other words, it uses ESP8266 to send the data of hardware devices to the Gizwits AIoT platform through the MQTT protocol, write it to the cloud, and then pass it to the data. Users can remotely control the hardware devices through the mobile phone APP.


The steps to achieve this are as follows: 1. Register a Gizwits account

Register your own account on the Gizwits self-service development platform, and any IoT devices you design in the future can be placed on this account.

2. Create a new device and generate source code

First create a new device

Water Heater Controller Using ESP8266 Module

Then add the data points

Water Heater Controller Using ESP8266 Module

The data point is light_onoff, and the name can be other letters defined by yourself.

Water Heater Controller Using ESP8266 Module

You will see the basic information of this data point in the basic information. Note that if you want to see the complete Secret, you need a second password verification.

Water Heater Controller Using ESP8266 Module

Select MCU Development

Water Heater Controller Using ESP8266 Module

Then choose the SOC solution

Water Heater Controller Using ESP8266 Module

Then enter the secret to generate a code package

Water Heater Controller Using ESP8266 Module

After downloading I found that the structure of this code package is similar to that of Espressif (this sentence is for friends who have used Espressif's official code)

Water Heater Controller Using ESP8266 Module

3. Compile ESP8266 source code

The source code generated in the previous step runs inside the ESP8266 module. How to compile and burn it?

The following document explains:

https://dwz.date/fpVy

Water Heater Controller Using ESP8266 Module

About the development environment construction:

Water Heater Controller Using ESP8266 Module

About ESP8266 platform file description:

Water Heater Controller Using ESP8266 Module

The content is similar to the previous compilation learning. Just like Espressif, a new VM folder is created on the D drive.

Then put all the files in this folder. I named the folder SoC_ESP8266, which is shorter and easier to type.

First, let Linux and Windows share folders

Enter the user password: "espressif", press Enter to confirm.

Water Heater Controller Using ESP8266 Module

At this time, you can see that the sharing has been successful through the folder manager in the VM VirtualBOX virtual machine.

Water Heater Controller Using ESP8266 Module

The purpose of this article is to control this module with a mobile phone APP to realize the switch of GPIO12, that is, the conversion of high and low levels.

The source code generated by the above steps cannot realize the control of specific pins. In order to realize the control of this pin, the code needs to be modified.

The modification steps are to find the corresponding .c or .h file under the VM folder, open it with Notepad or other software and edit it.

Only modified a little bit.

In the keyinit function in user_main.c, add the code to initialize GPIO12.

Water Heater Controller Using ESP8266 Module

Then in gizwits_product.c, add the code to flip the light.

Water Heater Controller Using ESP8266 Module

Yes, it is that simple, just like the 51 single-chip microcomputer , initialize the pin, and then make it high or low level in the function.

4. Compile the source code and burn it into ESP8266

Next, start compiling this source code.

Next, enter the app directory. The following interface is the LX client running in the VM VirtualBOX virtual machine. The simulation is the Linux operating system .

The cd command is used to enter a directory.

Water Heater Controller Using ESP8266 Module

Run the compilation script: ./gen_misc.sh

Compile very fast

Water Heater Controller Using ESP8266 Module

Next, start burning

There is a picture in the code automatically generated by Gizwits, which shows which address to program into.

Water Heater Controller Using ESP8266 Module

Now start burning.

Water Heater Controller Using ESP8266 Module

To make it easier for beginners to understand, here is a brief introduction to the hardware connection. The ESP8266 module consists of two parts, the upper one is the ESP8266 function board, and the lower one is actually a USB -to- serial board. The chip is CH340, but it is made the same size as the ESP8266 function board. In fact, its function is the same as the USB-to-serial module you buy. Use a micro USB data cable, which is the charging/data cable commonly used by mobile phones. Note that it is not a TYPE-C data cable. After connecting to the computer , the driver will be automatically installed. Of course, make sure that the computer is connected to the Internet. After the driver is successfully installed, the current serial port will be displayed in the device manager as COM number. Write down the serial port number and select this serial port number when burning.

Click the burning software START on the computer, then press the FLASH button on the board and hold it, then press the RST button, release it, and then release the FLASH button. Generally, the burning can be successful in one time. If it fails, please click the burning START again and follow the FLASH and RST button steps to burn again.

After burning, the module can be used.


Reference address:Water Heater Controller Using ESP8266 Module

Previous article:Application of WTK6900H voice recognition chip in rice cooker
Next article:What are the uses of bone conduction headphones? What are the better bone conduction headphones?

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号