LÀM MỘT BỘ SMS GATEWAY IOT, BẠN THỬ CHƯA?

Mô Tả Dự Án

Module nhắn tin,gọi điện thoại qua sim thì có lẽ đã quá quen thuộc với bạn rồi. Vậy có bao giờ các bạn nghĩ đến ngày chúng ta sẽ làm một cái giao diện web nhỏ để nhắn tin, gọi điện thoại ở bất cứ đâu mà không cần phải mang theo cái module sim chưa? Lấy một ví dụ cụ thể hơn nha, bạn làm một dự án lớn và sử dụng module sim để nhắn tin báo cáo về điện thoại của bạn, nhưng bạn chỉ biết được trong sim đó còn bao nhiêu tiền nếu bạn ở gần nó, vậy nếu bạn đi Hà Nôi du lịch mà dự án của bạn lại ở Bình Dương thì sao nhỉ? 

Hôm nay, mình sẽ hướng dẫn cho bạn cách làm một bộ SMS GateWay IOT với iNut cảm biến nha. Nhờ dự án nhỏ này, bạn có thể biết được tiền hiện tại trong tài khoản của mình, nạp tiền điện thoại hay nhắn tin từ xa thông qua internet mà không cần phải ở cạnh Board sim. Cùng bắt tay vô làm thôi.

I. Bạn Cần Chuẩn Bị Gì

Phần Cứng

  • INut Cảm Biến
  • Module Sim 800A
  • USB Type B (dây nạp code cho arduino uno đó)
  • Nguồn 5V - 2A

Kết Nối

Các bạn chỉ cần đặt iNut cảm biến lên phía trên Module Sim 800A là được vì nó cùng một kích cỡ.

Phần Mềm

  • Trên điện thoại di động:
    • iNut - Platform (các bạn search trong apple store hoặc google play từ khóa inut là ra). Tải về trên Apple Store, tải về ở Google Play.
  • Trên máy tính:

Tham Khảo bài viết này để cài đặt môi trường cho iNut Node - RED IDE trên máy tính:http://arduino.vn/i...

II. Các Cài Đặt Khác

  • Cài Đặt Mạng Cho INut Cảm Biến: nếu bạn là người lần đầu tiên tiếp xúc với INut Cảm Biến, tham khảo bài viết này nhé : http://arduino.vn/tutorial/5929-ra-m... (bạn nào đã tiếp xúc rồi có thể bỏ qua bước này nhe. ) 
  • Video Hướng Dẫn Cài Đặt Wifi Cho iNut Cảm Biến:  

III. Lập Trình

Bạn Cần Chuẩn Bị Thư Viện Cho iNut Cảm Biến Cho Arduino IDE: https://github.com/ngohuynhngockhanh... (tải nhanh)

Code Arduino

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "iNut.h"
#include "call.h";
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
//vietnammobile
/*#define MUL 1000
#define OFFSET_NUMBER 7
#define KEY_TKC F("TKC: ")*/

//viettel

  #define OFFSET_NUMBER 0
  #define KEY_TKC F("TK goc: ")

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to send and receive SMS.

int numdata;
boolean started = false;
iNut sensor;
String sdt;
void setup()
{
  sensor.setup(8);
  //Serial connection.
  Serial.begin(115200);
  Serial.println(F("GSM Shield testing."));
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)) {
    Serial.println(F("\nstatus=READY"));
    started = true;
  } else Serial.println(F("\nstatus=IDLE"));
  Serial.println(F("..."));
  if (started) {
    //Enable this two lines if you want to send an SMS.
    //if (sms.SendSMS("0972768491", "Arduino SMS"))
    //Serial.println("\nSMS sent OK");
  }
  sensor.setValue(0, 0.0f);
  sensor.addCommand("N", napCard);
  sensor.addCommand("M", nhanTin);
  sensor.addCommand("S", setSDT);
  sensor.addCommand("C", GoiDien);
  sensor.addCommand("ONLINE", onlineHandler);
  sensor.addCommand("OFFLINE", offlineHandler);
  sensor.setDefaultHandler(defaultHandler);
  
};
unsigned long lastCheckInutConnected = 0;
void onlineHandler() {
  lastCheckInutConnected = millis();
  Serial.println(F("Da ket noi voi internet"));
}

void offlineHandler() {
  lastCheckInutConnected = millis();
  Serial.println(F("MAT ket noi voi internet"));
}
CallGSM call;
void GoiDien() {
  Serial.println(F("Goi dien"));
  char *arg = sensor.next();
  Serial.println(arg);
  call.Call(arg);
  delay(5000);
  call.HangUp();
}

void ResetBoard()
{
  asm volatile ( "jmp 0");  
}

void setSDT() {
  Serial.println(F("Napcard function"));
  char *dt = sensor.next();
  if (dt == NULL) {
    Serial.println(F("No sdt"));
    return;
  } else {
    Serial.println(F("sdt"));
    Serial.println(dt);
  }
  sdt = dt;
}

//Nếu nhận được lệnh không phải từ những lệnh được đăng ký trước thì sẽ ghi ra ở đây
void defaultHandler(const char *command) {
  Serial.print(F("---Not found handler: "));
  Serial.println(command);


  //Đoạn chương trình dưới chỉ dùng để debug, để các bạn biết chương trình của mình ở lỗi ở đâu để khắc phục, cũng không cần hiểu nha.
  int idx = 0;
  char *arg;
  while ((arg = sensor.next()) != NULL) { //còn tham số nào thì in ra
    Serial.print(F("-----> Gia tri thu #"));
    Serial.print(idx);
    Serial.print(F(": "));
    Serial.println(arg);
    idx++;
  }
}
String tinNhan = "";
void nhanTin() {
  Serial.print(F("Tin nhan: "));
  Serial.println();


  //Đoạn chương trình dưới chỉ dùng để debug, để các bạn biết chương trình của mình ở lỗi ở đâu để khắc phục, cũng không cần hiểu nha.
  int idx = 0;
  char *arg;
  while ((arg = sensor.next()) != NULL) { //còn tham số nào thì in ra
    Serial.print(F("-----> Gia tri thu #"));
    Serial.print(idx);
    Serial.print(F(": "));
    Serial.println(arg);
    if (strcmp(arg, "!OK") == 0) {
      Serial.println(F("Final"));
      Serial.println(tinNhan);
      char *_sdt = sdt.c_str();
      char *_tn = tinNhan.c_str();
      if (sms.SendSMS(_sdt, _tn)) {
        Serial.println(F("\nSMS sent OK"));
        delay(1000);
      }
      tinNhan = "";
    } else {
      tinNhan += arg;
      tinNhan += " ";
    }
    idx++;
  }
}
void napCard() {
  Serial.println(F("Napcard function"));
  char *card = sensor.next();
  if (card == NULL) {
    Serial.println(F("No card"));
    return;
  } else {
    Serial.println(F("Card"));
    Serial.println(card);
  }
  String str = String(F("AT+CUSD=1,\"*100*"));
  str += card;
  str += String(F("#\""));
  Serial.println(str);

  gsm.SimpleWriteln(str.c_str());
  delay(5000);
}

void readMoney() {
  static float money = 9999999.0;
  static int8_t state = 0;
  static unsigned long timer = 0;
  static unsigned long number = 0;
  switch (state) {
    case 0: {
        state = 1;
        gsm.SimpleWriteln(String(F("AT+CUSD=1,\"*101#\"")).c_str());
        timer = millis();
        break;
      }
    case 1: {
        if (millis() - timer > 5000UL) {
          state = 2;
          timer = millis();
        }
        break;
      }
    case 2: {
        char resp[100];//khoi tao xau cho noi dung tra ve
        gsm.read(resp, 100); //lay no
        Serial.println(resp);//in ra lan 2
        String str = resp;
        int index2 = str.indexOf(String(F("\"")));
        if (index2 <= 0)
          index2 = 0;
        String numStr = str.substring(index2 + 3 + OFFSET_NUMBER, index2 + 12 + OFFSET_NUMBER);
        Serial.println(numStr);
        number = atol(numStr.c_str());
        int index = str.indexOf(String(KEY_TKC)) ;
        if (index > -1) {
          String substr = str.substring(index + String(KEY_TKC).length());
          Serial.println(substr);
          money = atof(substr.c_str());
          Serial.println(money);
#ifdef MUL
          money *= MUL;
#endif
        }
        Serial.println(number);
        state = 3;
        break;
      }
    case 3: {

        if (millis() - timer > 60000UL) {
          timer = millis();
          state = 0;
        }
        break;
      }
  }
  sensor.setValue(1, money);
  sensor.setValue(2, number);
}
void loop()
{
  if (millis() - lastCheckInutConnected > 30000UL) {
    ResetBoard();
  }
  sensor.setValue(0, started);
  sensor.loop();
  if (started) {
    readMoney();
    //Read if there are messages on SIM card and print them.
    /**  deprecated method
      if(gsm.readSMS(smsbuffer, 160, n, 20)) {
           Serial.println(n);
           Serial.println(smsbuffer);
      }
      **/
    //get 1st sms
    /*sms.GetSMS(3, n, 20, smsbuffer, 160);
      Serial.println(n);
      Serial.println(smsbuffer);

      delay(1000);
      if (started)
      {


      //tt=1;//cho dung chuong trinh
      }*/
  }
};

Code iNut Node RED IDE

[
    {
        "id": "a6683ea7.c9a4d",
        "type": "subflow",
        "name": "Lấy dữ từ iNut",
        "info": "",
        "in": [
            {
                "x": 50,
                "y": 30,
                "wires": [
                    {
                        "id": "6b5d7766.3f0508"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 859.0000343322754,
                "y": 98.00000190734863,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 0
                    }
                ]
            },
            {
                "x": 968.0000343322754,
                "y": 102.00000286102295,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 1
                    }
                ]
            },
            {
                "x": 1048.9999732971191,
                "y": 101.00000381469727,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 2
                    }
                ]
            },
            {
                "x": 1059,
                "y": 253,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 3
                    }
                ]
            },
            {
                "x": 1102,
                "y": 318,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 4
                    }
                ]
            },
            {
                "x": 1116,
                "y": 399,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 5
                    }
                ]
            },
            {
                "x": 1108,
                "y": 444,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 6
                    }
                ]
            },
            {
                "x": 1006,
                "y": 489,
                "wires": [
                    {
                        "id": "6896ae68.8512f",
                        "port": 7
                    }
                ]
            }
        ],
        "inputLabels": [
            "Nhận đầu vào MQTT IN từ iNut cảm biến"
        ],
        "outputLabels": [
            "Luồng cảm biến 1",
            "Luồng cảm biến 2",
            "Luồng cảm biến 3",
            "Luồng cảm biến 4",
            "Luồng cảm biến 5",
            "Luồng cảm biến 6",
            "Luồng cảm biến 7",
            "Luồng cảm biến 8"
        ]
    },
    {
        "id": "b1ab7c75.0d54a",
        "type": "function",
        "z": "a6683ea7.c9a4d",
        "name": "Lấy trạng thái thiết bị",
        "func": "msg.relayId = msg.i\nmsg.payload = msg.states[msg.i].state\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 477.89060974121094,
        "y": 183.33600330352783,
        "wires": [
            [
                "e36217c1.703c58",
                "6896ae68.8512f"
            ]
        ]
    },
    {
        "id": "6896ae68.8512f",
        "type": "switch",
        "z": "a6683ea7.c9a4d",
        "name": "Phân luồn",
        "property": "relayId",
        "propertyType": "msg",
        "rules": [
            {
                "vt": "num",
                "v": "0",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "1",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "2",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "3",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "4",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "5",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "6",
                "t": "eq"
            },
            {
                "vt": "str",
                "v": "7",
                "t": "eq"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 8,
        "x": 825.9869575500488,
        "y": 288.1562738418579,
        "wires": [
            [],
            [],
            [],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "6b5d7766.3f0508",
        "type": "json",
        "z": "a6683ea7.c9a4d",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 165,
        "y": 84,
        "wires": [
            [
                "e36217c1.703c58"
            ]
        ]
    },
    {
        "id": "e36217c1.703c58",
        "type": "function",
        "z": "a6683ea7.c9a4d",
        "name": "Lặp",
        "func": "if (!msg.states) {\n    msg.states = msg.payload\n    msg.i = 0\n    return msg;\n} else {\n    msg.i++\n    if (msg.states[msg.i])\n        return msg;\n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 327.89060974121094,
        "y": 83.33600330352783,
        "wires": [
            [
                "b1ab7c75.0d54a"
            ]
        ]
    },
    {
        "id": "1c712147.d1267f",
        "type": "ui_gauge",
        "z": "702bee55.f9a75",
        "name": "",
        "group": "4615abf8.c0cd24",
        "order": 2,
        "width": "3",
        "height": "3",
        "gtype": "gage",
        "title": "Số tiền trong tài khoản",
        "label": "",
        "format": "{{value}}",
        "min": 0,
        "max": "100000",
        "colors": [
            "#1f964f",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 1200,
        "y": 540,
        "wires": []
    },
    {
        "id": "106c0c85.cdf633",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lệnh C",
        "func": "msg.payload = \"C \" + msg.payload.number\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 280,
        "y": 480,
        "wires": [
            [
                "a4e16a95.5fa1f8"
            ]
        ]
    },
    {
        "id": "713e33b6.cf955c",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lấy độ dài chuỗi",
        "func": "\nmsg.payload =  msg.payload.length;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 921.2654800415039,
        "y": 420.4344816207886,
        "wires": [
            [
                "728db61b.2731a8"
            ]
        ]
    },
    {
        "id": "973201b4.115f",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lệnh N",
        "func": "msg.payload = \"N \" + msg.payload.card\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 240,
        "y": 380,
        "wires": [
            [
                "a4e16a95.5fa1f8"
            ]
        ]
    },
    {
        "id": "f2326ed8.3d6b9",
        "type": "ui_form",
        "z": "702bee55.f9a75",
        "name": "",
        "label": "Nạp card",
        "group": "e4e6ca67.c26488",
        "order": 1,
        "width": 0,
        "height": 0,
        "options": [
            {
                "value": "card",
                "type": "text",
                "required": true,
                "label": "Mã thẻ cào"
            }
        ],
        "formValue": {
            "card": ""
        },
        "payload": "",
        "submit": "submit",
        "cancel": "cancel",
        "topic": "",
        "x": 80,
        "y": 380,
        "wires": [
            [
                "973201b4.115f"
            ]
        ]
    },
    {
        "id": "d60c6471.0c6a88",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lệnh S",
        "func": "msg.payload = \"S \" + msg.payload.number\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 300,
        "y": 160,
        "wires": [
            [
                "a4e16a95.5fa1f8"
            ]
        ]
    },
    {
        "id": "66cc681d.f32e88",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Chuẩn bị lệnh trước khi gửi đến iNut cảm biến",
        "func": "var json = {\"id\": 0, \"command\": msg.payload};\nmsg.payload = json;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1020,
        "y": 340,
        "wires": [
            [
                "e80854d2.2b4aa8"
            ]
        ]
    },
    {
        "id": "93d17088.1436",
        "type": "ui_form",
        "z": "702bee55.f9a75",
        "name": "",
        "label": "Nhắn tin",
        "group": "e4e6ca67.c26488",
        "order": 1,
        "width": 0,
        "height": 0,
        "options": [
            {
                "value": "text",
                "type": "text",
                "required": true,
                "label": "Nội dung"
            },
            {
                "value": "number",
                "type": "text",
                "required": true,
                "label": "SĐT"
            }
        ],
        "formValue": {
            "number": "",
            "text": ""
        },
        "payload": "",
        "submit": "submit",
        "cancel": "cancel",
        "topic": "",
        "x": 160,
        "y": 180,
        "wires": [
            [
                "66f08b8a.ddb544",
                "d60c6471.0c6a88"
            ]
        ]
    },
    {
        "id": "5a03b0aa.60473",
        "type": "ui_form",
        "z": "702bee55.f9a75",
        "name": "",
        "label": "Gọi điện",
        "group": "e4e6ca67.c26488",
        "order": 1,
        "width": 0,
        "height": 0,
        "options": [
            {
                "value": "number",
                "type": "text",
                "required": true,
                "label": "SĐT"
            }
        ],
        "formValue": {
            "number": ""
        },
        "payload": "",
        "submit": "submit",
        "cancel": "cancel",
        "topic": "",
        "x": 140,
        "y": 480,
        "wires": [
            [
                "106c0c85.cdf633"
            ]
        ]
    },
    {
        "id": "5e3adebb.b47ac",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lấy đoạn chuỗi mà Arduino nhận được",
        "func": "\nmsg.payload =  msg.payload.substr(0, 32);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 989.3855209350586,
        "y": 379.06986141204834,
        "wires": [
            [
                "eff65e2.1ab66a"
            ]
        ]
    },
    {
        "id": "79ce3cde.142464",
        "type": "ui_gauge",
        "z": "702bee55.f9a75",
        "name": "",
        "group": "4615abf8.c0cd24",
        "order": 3,
        "width": "3",
        "height": "3",
        "gtype": "gage",
        "title": "Số điện thoại ",
        "label": "",
        "format": "{{value}}",
        "min": 0,
        "max": "999999999",
        "colors": [
            "#1f964f",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 1168.09126663208,
        "y": 582.124960899353,
        "wires": []
    },
    {
        "id": "a4e16a95.5fa1f8",
        "type": "ui_text_input",
        "z": "702bee55.f9a75",
        "name": "",
        "label": "Gửi lệnh xuống iNut cảm biến",
        "group": "4615abf8.c0cd24",
        "order": 5,
        "width": "4",
        "height": "1",
        "passthru": true,
        "mode": "text",
        "delay": "0",
        "topic": "",
        "x": 490,
        "y": 380,
        "wires": [
            [
                "123b95bd.ee772a"
            ]
        ]
    },
    {
        "id": "d3edf92d.f5b328",
        "type": "subflow:a6683ea7.c9a4d",
        "z": "702bee55.f9a75",
        "name": "",
        "x": 940,
        "y": 580,
        "wires": [
            [
                "7a886600.ef9b98"
            ],
            [
                "1c712147.d1267f"
            ],
            [
                "79ce3cde.142464"
            ],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "728db61b.2731a8",
        "type": "ui_numeric",
        "z": "702bee55.f9a75",
        "name": "Độ dài chuỗi",
        "label": "",
        "group": "4615abf8.c0cd24",
        "order": 6,
        "width": "2",
        "height": "1",
        "passthru": true,
        "topic": "",
        "format": "{{value}}",
        "min": 0,
        "max": "32",
        "step": 1,
        "x": 1094.3591995239258,
        "y": 417.88762855529785,
        "wires": [
            []
        ]
    },
    {
        "id": "eff65e2.1ab66a",
        "type": "ui_text",
        "z": "702bee55.f9a75",
        "group": "e4e6ca67.c26488",
        "order": 5,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Đã gửi lệnh",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 1222.5385131835938,
        "y": 378.9340410232544,
        "wires": []
    },
    {
        "id": "66f08b8a.ddb544",
        "type": "function",
        "z": "702bee55.f9a75",
        "name": "Lệnh M",
        "func": "var data = msg.payload;\ndata = data.text;\ndata = data.split(\" \")\nvar interval = setInterval(function() {\n    var cmd = \"M \" \n    node.error(data)\n    while (data.length > 0) {\n        var cnt = data[0]\n        if (cmd.length + 1 + cnt.length <= 32) {\n            cmd += \" \"\n            cmd += cnt\n            data.shift()\n        }  else {\n            break;\n        }\n    }\n    node.error(cmd)\n    if (data.length === 0) {\n        if (cmd.length + 4 <= 32) {\n            cmd += \" !OK\"\n            clearInterval(interval)\n            \n        }\n    }\n    node.send({payload: cmd});\n}, 400);",
        "outputs": 1,
        "noerr": 0,
        "x": 300,
        "y": 200,
        "wires": [
            [
                "a4e16a95.5fa1f8"
            ]
        ]
    },
    {
        "id": "7a886600.ef9b98",
        "type": "ui_gauge",
        "z": "702bee55.f9a75",
        "name": "",
        "group": "4615abf8.c0cd24",
        "order": 1,
        "width": "6",
        "height": "3",
        "gtype": "gage",
        "title": "\bĐÃ KHỞI ĐỘNG",
        "label": "mưa",
        "format": "{{value}}",
        "min": 0,
        "max": "1",
        "colors": [
            "#1f964f",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 1179.09126663208,
        "y": 499.2916479110718,
        "wires": []
    },
    {
        "id": "123b95bd.ee772a",
        "type": "change",
        "z": "702bee55.f9a75",
        "name": "",
        "rules": [],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 380,
        "wires": [
            [
                "66cc681d.f32e88",
                "5e3adebb.b47ac",
                "713e33b6.cf955c"
            ]
        ]
    },
    {
        "id": "7d0c4670.7e0d88",
        "type": "mqtt in",
        "z": "702bee55.f9a75",
        "name": "[MQTT-IN]iNut cảm biến - iNut M1",
        "topic": "request/yMisF8dOPBcleTkKVD4iiV1kfAG3/H1adzYzCV/6db614b732921cc8eeb6872414dbb334119689198251",
        "qos": "2",
        "broker": "f408576b.9612a",
        "x": 580,
        "y": 600,
        "wires": [
            [
                "d3edf92d.f5b328"
            ]
        ]
    },
    {
        "id": "e031d021.817278",
        "type": "http request",
        "z": "702bee55.f9a75",
        "name": "[REST][GET]iNut cảm biến - iNut M1",
        "method": "GET",
        "ret": "txt",
        "url": "https://connect.mysmarthome.vn/api/1.0/request/yMisF8dOPBcleTkKVD4iiV1kfAG3/H1adzYzCV/6db614b732921cc8eeb6872414dbb334119689198251/req_device",
        "tls": "",
        "x": 1350,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "e80854d2.2b4aa8",
        "type": "http request",
        "z": "702bee55.f9a75",
        "name": "[REST][POST]iNut cảm biến - iNut M1",
        "method": "POST",
        "ret": "txt",
        "url": "https://connect.mysmarthome.vn/api/1.0/request/yMisF8dOPBcleTkKVD4iiV1kfAG3/H1adzYzCV/6db614b732921cc8eeb6872414dbb334119689198251/req_device_toggle",
        "tls": "",
        "x": 1390,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "4615abf8.c0cd24",
        "type": "ui_group",
        "z": "",
        "name": "Thứ nhất",
        "tab": "303d207b.ad8f1",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": true
    },
    {
        "id": "e4e6ca67.c26488",
        "type": "ui_group",
        "z": "",
        "name": "Thứ 2",
        "tab": "303d207b.ad8f1",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": true
    },
    {
        "id": "f408576b.9612a",
        "type": "mqtt-broker",
        "name": "",
        "broker": "mqtt.mysmarthome.vn",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": ""
    },
    {
        "id": "303d207b.ad8f1",
        "type": "ui_tab",
        "z": "",
        "name": "Kiểm thử iNut cảm biến",
        "icon": "dashboard",
        "order": 1
    }
]

Giao Diện Block Của iNut Node RED IDE

Giao Diện Làm Việc

IV. Hướng Dẫn Import Code iNut Node RED IDE

Bước 1: bạn click vào 3 gạch ngang góc phải trên

Bước 2: Bạn vào Import -> Clipboard

Bước 3: Code iNut Node - RED IDE copy đoạn code và paste vào clipboard ở vị trí này

Bước 4: sau khi paste vào clipboard rồi thì bạn click vào Import

Bước 5: khi đã import xong, bạn sắp xếp các block lại cho đẹp bắt rồi bấm deploy là xong.

 

V. Hướng Dẫn Quét Mã QrCode Để Chia Sẻ Các Khối Lệnh

Bước 1:  Mở app iNut, chọn vào phần tài khoản

Bước 2: Chọn vào mục chia sẻ thiết bị

Bước 3: Chọn thiết bị cần chia sẻ

Bước 4: Chọn quét mã Qrcode để chia sẻ

Bước 5:  Trên máy tính, click vào icon 3 gạch góc phải trên

Bước 6: Sau khi hiện ra bảng chọn, click vào mục Import from iNut

Bước 7: Sau khi hiện lên một mã Qrcode trên máy tính, bạn đưa điện thoại lên quét, thế là xong.

Sau khi Import vào sẽ hiện ra 3 khối lệnh như hình phía dưới, các bạn thay các khối lệnh tương tự có sẵn thành các khối lệnh mới này nha (kéo thả thôi mà).

Nếu các bạn gặp khó khăn khi thực hiện dự án nãy, hãy liên hệ mình để nhận được sự trợ giúp (sđt: 037 3998 468).

VI. Kết Quả Của Ngày Hôm Nay

Chúc các bạn thành công.

lên
2 thành viên đã đánh giá bài viết này hữu ích.
Các dự án được truyền cảm hứng

Select any filter and click on Apply to see results

Các bài viết cùng tác giả

Hướng Dẫn Test Gửi Từ iNut-Node-RED-IDE Đến MQTT Broker Trên Raspberry

Chào các bạn, ở bài trước mình đã hướng dẫn các bạn cách setup 1 MQTT-Broker trên con raspberry-Pi rồi, qua đó các bạn cũng đã nắm được các thao tác setup cơ bản cũng như cách sử dụng remote cho pi. Các bạn xem lại ở đây nha.

Ở bài viết này mình sẽ hướng dẫn các bạn cách gửi data từ iNut-Node-RED-IDE để xem nó hoạt động như thế nào nhé, mình sẽ chỉ các bạn cách setup và lấy thông số có sẵn để test luôn nha. Bắt tay vào làm thôi.

lên
4 thành viên đã đánh giá bài viết này hữu ích.

SỬ DỤNG INUT CẢM BIẾN LÀM 1 BỘ ACCESS CONTROL DỄ HAY KHÓ?

Để điều khiển từ xa và đồng bộ dữ liệu trong thời gian thực qua internet dễ hay khó? đối với newbie thì thực sự rất khó, không biết nên bắt đầu từ đâu. Nhưng với iNut cảm biến thì mọi chuyện sẽ dễ hơn rất nhiều, nó là công cụ sẽ giúp bạn quyết định thành bại cho một dự án IOT dù nhỏ dù lớn. Hôm nay, mình sẽ cùng bạn làm một bộ access control cho chính cánh cửa trong phòng mình. Mình sẽ hướng dẫn bạn không chỉ điều khiển trên máy tính mà cũng có thể điều khiển trực tiếp trên điện thoại thông minh thông qua web app (nâng cao hơn sẽ là tự làm app riêng bằng app inventor hay thunkable - cái này sẽ có bài hướng dẫn lần sau). Các bạn có thể tùy chọn điều khiển trực tiếp qua localhost, điều khiển qua 3/4G v.v.. 

 

Nói nãy giờ cũng hơi dài rồi, cùng nhau bắt tay vô làm thôi.

lên
6 thành viên đã đánh giá bài viết này hữu ích.