【Based on Gizwits AIoT development platform + Gokit】+ X-ray dose monitor
[Copy link]
I was lucky enough to be selected in the last event and had the opportunity to receive a sample for evaluation.
I have come into contact with Gizwits before. At first, I bought a socket solution from a third-party manufacturer, but it failed! After my own modification, I used the Gizwits platform to access it. There is no problem in using it.
Because I have been exposed to 8266, I originally planned to use the soc mode to make this small project. After looking through the manual, I found that the code was all in the esp-idf mode. It was too troublesome to build the environment, so I gave up! It is recommended to change the development platform to the platformio mode similar to vscode, which will be more user-friendly!
Then the specific steps are:
1. Register a developer account
https://dev.gizwits.com/
2. Create a product
3. Add data points required for the project
You can write them as needed first, and then add them again when needed for the project later. Note that you must click Apply after adding the data points
4. Then generate the code for arduinoUNOR3
Select the correct hardware platform (R3), and get the value of Product Secret in Product Information-Basic Information
5. Process the code downloaded from Arduino.
You can get the IDE of Arduino from the Internet. There are also some on the forum! Copy the library file to the library location of Arduino. The required routines can be obtained in examples.
The functions of the above two examples:
simpleTry.ino is the project of this project, which contains the program framework and tells the user where to fill in the code for accessing Gizwits; networkConfig.ino is a routine for configuring the network. Because common smart hardware products do not have keyboards and displays, a technology is needed to allow it to obtain the SSID and password of the router, and the first choice is to assist with the mobile phone APP. Here is a brief introduction to the method. Use a button to trigger the device to enter the network configuration mode, and then the mobile phone APP broadcasts the SSID and password to the device. For
specific codes, please refer to the uploaded file. Note that all the codes related to the serial port must be removed, because in the mcu mode, the serial port of R3 needs to communicate with esp8266.
As for the subsequent need for multiple serial port modes, please refer to: https://www.jianshu.com/p/eb846ce95806 The code is temporarily processed. Pay attention to selecting the arduino type when burning, compile without error, and then upload it!
6. Jump to the esp8266 network module for now, first download the firmware of GAgent for EPS8266 and burn it
Note for downloading the program: connect 3 wires to the USB to TTL converter, use the USB of the function board for power supply, turn the switch of the 8266 board to the GND download mode, and the BAUD in the burning tool in the above picture cannot be too high, I delayed it for a while here!
Wiring burning reference:
After the burning is completed, turn the dip switch back!
Pay attention here, if you are not sure whether the burning is normal, you can press the K2 button on the board, the middle one, and 8266 should create an AP with ssid XPG-GAgent-xxxx, and you can see it on the mobile wifi!
7. Download the official app, go to the official website, the QR code in the manual attached to the delivery has expired!
https://download.gizwits.com/zh-cn/p/98/99
8. Pay attention to the network configuration here
Press and hold the K2 button on the board, the middle button, you can enter the airlink configuration mode, and then use the Gizwits app to push the ssid and password to configure the network. After success, the device you created will appear in your Gizwits app
9. You can operate the button in the app, and then you can see the operation record in the setting log of the Gizwits official website developer center
10. Start writing system programs
The above picture is the pin diagram of Arduino R3, you can refer to it. Please note that when burning R3 program, the expansion board above needs to be unplugged, otherwise the program cannot be burned in!
11.First use rgb red to simulate the ray turn-on signal
#include <ChainableLED.h>
#define NUM_LEDS 1
ChainableLED leds(A5, A4, NUM_LEDS);
Introduce the rgb driver file and define a light
setup function to initialize leds.init();
In the loop function, the control data sent by the Gizwits platform will be received and analyzed. The function can be parsed and processed
bool varR_XRAY_ON = 0;
if(myGizwits.hasBeenSet(EVENT_XRAY_ON))
{
myGizwits.read(EVENT_XRAY_ON,&varR_XRAY_ON);//Address for storing data
// mySerial.println(F("EVENT_XRAY_ON"));
// mySerial.println(varR_XRAY_ON,DEC);
if(varR_XRAY_ON)
leds.setColorRGB(0,255,0,0);//Test red light, indicating that the x-ray is on
else
leds.setColorRGB(0,0,0,0);//Test red light off, indicating that the ray is off
}
After the above operation, a simulation of ray on is completed. Later, io can be used to drive the relay to control the ray source.
12. Because the glass tube of the Geiger counter of my dosimeter is broken, the data cannot be retrieved at present. Next, I will simulate a data in the program as the ray dose monitoring value, which will be reflected in the Gizwits platform
By the way, the data of dht11 is also connected to facilitate the observation of scheme verification. The value of Xray_data in the above figure is simulated by random numbers. The data of the radiation dosimeter will be connected later!
After using Gizwits, I concluded that the overall IoT system structure is relatively complete, and it is relatively easy for developers to connect their devices to the network. The
corresponding data organization can be optimized, and it is a bit difficult to find tutorials.
The Arduino code is attached, which is a simple test:
https://club.gizwits.com/thread-166363-1-1.html
|