Home > other >  Implementation Easy IoT configuration and implementation Easy IoT MQTT on news communications
Implementation Easy IoT configuration and implementation Easy IoT MQTT on news communications

Time:09-25

a, the experiment purpose and requirements of
A [the experiment] implementation Easy IoT configuration,
[results] implementation Easy IoT MQTT on news communication,

2, the experimental principle and content
Realize the mind under + Easy IoT MQTT on news communication,

3, the hardware and software environment
Hardware:
control boardSoftware: Mind +

4, experimental process (experimental procedures, records, data, analysis)

1. Sign up for an account on http://iot.dfrobot.com.cn, click on the workshop after registering successfully, and click on add new equipment


In Mind + 2. To connect the WIFI, then connect the MQTT (MQTT is based on the news of the client-server publish/subscribe transfer protocol)
(1) set up in accordance with the "A" when connect the WIFI, if the connection is successful in the first line display "WIFI connection success";
(2) connection MQTT when set in accordance with the "B", the process of connecting the MQTT:
(1) the initialization MQTT, fill in account the lot_id and lot_pwd, given topic and add two device;


(2) initiated an MQTT connection;
(3) if an MQTT connection is successful, then the "1" lights up and "MQTT connection success", the second line of the screen at the same time, if you accept to Topic_0 sent message, show on the third row of the screen, and a reply message to Topic_1, and display of the content of the reply in the fourth row,

3. run in Mind + :

//main program start 
Void setup () {
MPython. The begin ();
MyIot. SetMqttCallback (msgHandles);
}
Void loop () {
while (! (buttonA isPressed ())) {yield (); }
Dyj myIot. WifiConnect (" ", "12345678");
while (! MyIot. WifiStatus ()) {yield (); }
Display. SetCursorLine (1);
The display. The printLine (" Wifi connection success ");
If ((buttonB isPressed ())) {
MyIot. Init (" iot.dfrobot.com.cn ", "KL7o5mFMR", ""," FL7TcmKGgz ", switchable viewer, 1883);
MyIot. The connect ();
while (! MyIot. Connected ()) {yield (); }
RGB. Write (1, 0 xff0000);
Display. SetCursorLine (2);
The display. The printLine (" MQTT connection success ");
}
}


Concurrent threads:


 
//event callback functionVoid obloqMqttEventT0 (String& Message) {
Display. SetCursorLine (3);
The display. The printLine (message);
MyIot. The publish (topic_1, "I 'm fine");
RGB. Write (2, 0 x33cc00);
}


4. Run results:
(1) the WiFi connection is successful:


(2) an MQTT connection is successful and communicate with each other


5, the experimental conclusion and experience
This experiment is about to realize Easy IoT configuration and implementation Easy IoT MQTT on news communication, after the teacher's explanation is a bit puzzled, but for themselves, according to the teacher to train of thought, is a lot better, but still met some problems, connected to the WIFI using computer hot at the beginning, but I don't know why the connection is not on, then the hot spot of the use of mobile phones, finally connected, but each time to upload the "plant", after the first click disconnect the WIFI again, click the second successful connection; Has good MQTT connection is successful, in aggregate is smooth,
  • Related