【IoT Development】Zhengdian Atom STM32 Battleship v3+Gizwits AIoT+APP Control
[Copy link]
Step 1: Go to the Gizwits Developer Center, register a developer account, and start creating a new product.
Figure 1 Creating a new product
Figure 2 Creating new products and product categories
After setting, click Save. This will jump to the development wizard interface and allow you to choose to add data points.
Figure 3 Development Wizard
Figure 4 Adding data points
We create three data nodes, which are used to turn on LED1, LED2, and buzzer. Select writable as the read/write type because we want to control these lights. The data type defaults to Boolean value, and you can write any comments below.
After saving, remember to click Apply, and the final result will be as shown below.
Figure 5 Application data points
Then click the Development Wizard on the left to enter MCU development.
Figure 6 MCU development
The default here is the stm32f103 series. Next, fill in the productsecret serial number of the device. This serial number can be found in the basic information on the left. You need to enter the password of the Gizwits developer account to see all of it, and then copy it.
Figure 7 Generate code package
After filling in, click Generate Code Package in MCU Development to generate the code required for our development board, and then click Download to download the code package.
Step 2: Modify the code
Figure 8 Modified code
Open the project, as shown in the figure, and add the initialization files of LED and beep by yourself. You can refer to the battleship routine.
/*****gizwits_product.c******/ The places that need to be modified are: LED1_ON and LED1_OFF are implemented by themselves, and the same is true for LED2 and BEEP
Figure 9 Structure diagram
/*****gizwits_product.h******/
#defineUART_BAUDRATE9600
#defineUART_PORT3
#defineUARTUSART3
#defineUART_IRQUSART3_IRQn
#defineUART_IRQ_FUNUSART3_IRQHandler
#if(UART_PORT==3)
#defineUART_GPIO_CmdRCC_APB2PeriphClockCmd
#defineUART_GPIO_CLKRCC_APB2Periph_GPIOB
#defineUART_AFIO_CmdRCC_APB2PeriphClockCmd
#defineUART_AFIO_CLKRCC_APB2Periph_AFIO
#defineUART_CLK_CmdRCC_APB1PeriphClockCmd
#defineUART_CLKRCC_APB1Periph_USART3
#defineUART_GPIO_PORTGPIOB
#defineUART_RxPinGPIO_Pin_11
#defineUART_TxPinGPIO_Pin_10
/*******main.c*******/
Modify the keyInit function and set it to the initialization of key0 and key1 on the development board
singleKey[0]=keyInitOne(RCC_APB2Periph_GPIOE,GPIOE,GPIO_Pin_4,key1ShortPress,key1LongPress);
singleKey[1]=keyInitOne(RCC_APB2Periph_GPIOE,GPIOE,GPIO_Pin_3,key2ShortPress,key2LongPress);
And add the initialization function of led and beep in the main function, comment out the interrupt function of usart3 in stm32f10x_it.c, and comment out Open_Uart3 in hal_uart.h
At this point, the code modification is complete. Download it to the board.
Step 3: Burn the Gizwits firmware to the Atomic ESP8266
How to wire:
Figure 10 Atomic STM32 Battleship v3
Remove the jumper cap in the first red box (counting from left to right) in the figure, and then use a jumper wire to connect the RXD pin to the TXD of ESP8266, and the TXD pin to the RXD of ESP8266.
Jump up the two jumpers in the second red box. At the third red box, use a jumper to connect the 3.3V pin to the VCC of ESP8266, the GND to the GND of ESP8266, and the other GND to IO_0 of ESP8266.
After connecting, power on and follow the Gizwits method to burn the ESP8266 firmware. ESP8266 module flashing GAgent and verification guide (latest) - other MCUs - open source projects and events - Gizwits, link: https://club.gizwits.com/forum.php?mod=viewthread&tid=3551&extra=page%3D1&page=1
After the burning is completed, unplug the cable and plug the jumper cap at the first red frame back in. Plug the ESP8266 into the interface below the third red frame.
Step 4: Download the test APP, because I don’t know how to write an APP. Please go to the Gizwits Download Center to download it, link:
https://download.gizwits.com/zh-cn/p/92/93
Open the APP and click Skip. The login operation and demonstration of the Gizwits public version APP are shown in Figures 11-16 below.
Fig.11
Fig.12
Fig.13
Fig.14
At this time, long press the KEY0 button of the development board to restart ESP8266, open the atomic serial port debugging assistant, and after seeing the restart is successful, check the above operations have been completed on the mobile phone, click Next, and wait for the mobile phone to automatically search for the device.
Fig.15
Figure 16 Gizwits Cloud APP demonstration
At this point, the development board has been connected to Gizwits Cloud. You can see that the device is online in the developer center of Gizwits Cloud's official website. You can also control the development board with a mobile phone using 4G network. If you want to control other peripherals on the development board, you can expand it yourself.
|