`Bạn Cần Chuẩn Bị Thư Viện Cho iNut Cảm Biến Cho Arduino :https://github.com/ngohuynhngockhanh/iNut-Arduino-library
CODE ARDUINO
#includeiNut sensor; int VaneValue;// raw analog value from wind vane int Direction;// translated 0 - 360 direction int CalDirection;// converted value with offset applied int LastValue; #define Offset 0; void setup() { Serial.begin(9600); LastValue = 1; Serial.println("Vane Value\tDirection\tHeading"); sensor.setup(3); } void loop() { VaneValue = analogRead(A2); Direction = map(VaneValue, 0, 1023, 0, 360); CalDirection = Direction + Offset; if(CalDirection > 360) CalDirection = CalDirection - 360; if(CalDirection 5) { Serial.print(VaneValue); Serial.print("\t\t"); Serial.print(CalDirection); Serial.print("\t\t"); getHeading(CalDirection); LastValue = CalDirection; } } // Converts compass direction to heading void getHeading(int direction) { if(direction
Trên APP INUT
Bạn theo dõi link này để cài đặt app, tạo tài khoản và đăng nhập vào, chọn thiết bị: http://arduino.vn/cc
Bạn đang đọc: ĐỌC GIÁ TRỊ CỦA CẢM BIẾN ĐO TỐC ĐỘ GIÓ, HƯỚNG GIÓ VÀ ĐƯA CÁC GIÁ TRỊ HIỂN THỊ LÊN INTERNET | Cộng đồng Arduino Việt Nam
Bước 1: Mở app iNut, chọn vào phần cài đặt -> chọn iNut Cảm Biến
Bước 2: Xem thông tin hiển thị trên iNut
TRÊN INUT NODE RED IDE
Các bạn xem cách setup iNut Node Red Ide theo link : http://arduino.vn/ccCác bạn vào phần import, copy paste đoạn code này vào theo hướng dẫn : http://arduino.vn/bai-viet/6797-huong-dan-su-dung-inut-cam-bien-va-node-red-ide-de-hien-thi-bieu-do-thoi-tiet
[ { "id": "e6aa6a4d.549c08", "type": "subflow", "name": "Lấy dữ từ iNut", "info": "", "in": [ { "x": 50, "y": 30, "wires": [ { "id": "b2696ea9.2b3d6" } ] } ], "out": [ { "x": 1000, "y": 180, "wires": [ { "id": "9fe08818.572a48", "port": 0 } ] }, { "x": 1000, "y": 260, "wires": [ { "id": "9fe08818.572a48", "port": 1 } ] }, { "x": 980, "y": 320, "wires": [ { "id": "9fe08818.572a48", "port": 2 } ] } ], "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": "b2696ea9.2b3d6", "type": "json", "z": "e6aa6a4d.549c08", "name": "", "property": "payload", "action": "", "pretty": false, "x": 165, "y": 84, "wires": [ [ "4da8cac2.24acf4" ] ] }, { "id": "9fe08818.572a48", "type": "switch", "z": "e6aa6a4d.549c08", "name": "Phân luồn", "property": "relayId", "propertyType": "msg", "rules": [ { "t": "eq", "v": "0", "vt": "num" }, { "t": "eq", "v": "1", "vt": "num" }, { "t": "eq", "v": "2", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 825.9869575500488, "y": 288.1562738418579, "wires": [ [], [], [] ] }, { "id": "4da8cac2.24acf4", "type": "function", "z": "e6aa6a4d.549c08", "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": [ [ "fb3946a3.9ccf78" ] ] }, { "id": "fb3946a3.9ccf78", "type": "function", "z": "e6aa6a4d.549c08", "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": [ [ "4da8cac2.24acf4", "9fe08818.572a48" ] ] }, { "id": "2ca49b8.92f0764", "type": "ui_gauge", "z": "edde96c.5e59968", "name": "", "group": "900c0194.8d7a9", "order": 1, "width": "6", "height": "3", "gtype": "gage", "title": "Hướng Gió", "label": "", "format": "{{value}}", "min": 0, "max": "360", "colors": [ "#1f964f", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "x": 790, "y": 360, "wires": [] }, { "id": "9b857a7b.7c7b4", "type": "ui_gauge", "z": "edde96c.5e59968", "name": "", "group": "ec123a3f.3570f8", "order": 1, "width": "6", "height": "3", "gtype": "gage", "title": "Gió", "label": "m/s", "format": "{{value}}", "min": 0, "max": "10", "colors": [ "#1f964f", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "x": 730, "y": 180, "wires": [] }, { "id": "f398e233.c33db8", "type": "subflow:e6aa6a4d.549c08", "z": "edde96c.5e59968", "name": "", "x": 380, "y": 300, "wires": [ [ "b7eadbd9.cf44a8" ], [ "a958973.76e2de8" ], [ "2ee5cd9c.c01b1a" ] ] }, { "id": "9889a59d.5e737", "type": "ui_gauge", "z": "edde96c.5e59968", "name": "", "group": "2df6fcf.9ea0804", "order": 1, "width": "6", "height": "3", "gtype": "gage", "title": "Hiệu Điện Thế", "label": "V", "format": "{{value}}", "min": 0, "max": "12", "colors": [ "#1f964f", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "x": 760, "y": 420, "wires": [] }, { "id": "b7eadbd9.cf44a8", "type": "change", "z": "edde96c.5e59968", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Gió", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 550, "y": 180, "wires": [ [ "9b857a7b.7c7b4", "f125cd8c.b65ff8" ] ] }, { "id": "f125cd8c.b65ff8", "type": "ui_chart", "z": "edde96c.5e59968", "name": "", "group": "ec123a3f.3570f8", "order": 2, "width": "6", "height": "6", "label": "Biểu Đồ Gió", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "Biểu Đồ Gió", "dot": false, "ymin": "-5", "ymax": "10", "removeOlder": "2", "removeOlderPoints": "2000", "removeOlderUnit": "60", "cutout": 0, "useOneColor": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "useOldStyle": false, "outputs": 1, "x": 830, "y": 40, "wires": [ [ "d8137742.96b5c" ] ] }, { "id": "2ee5cd9c.c01b1a", "type": "change", "z": "edde96c.5e59968", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Lưu Lượng Mưa", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 550, "y": 420, "wires": [ [ "2f5c0ef.76a0072", "9889a59d.5e737" ] ] }, { "id": "2f5c0ef.76a0072", "type": "ui_chart", "z": "edde96c.5e59968", "name": "", "group": "2df6fcf.9ea0804", "order": 2, "width": "6", "height": "6", "label": "Biểu Đồ Dòng điện", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "Biểu Đồ Lưu Lượng Mưa", "dot": false, "ymin": "0", "ymax": "12", "removeOlder": "2", "removeOlderPoints": "2000", "removeOlderUnit": "60", "cutout": 0, "useOneColor": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "useOldStyle": false, "outputs": 1, "x": 750, "y": 480, "wires": [ [ "659c6d2b.43b72c" ] ] }, { "id": "a958973.76e2de8", "type": "change", "z": "edde96c.5e59968", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Hướng Gió", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 570, "y": 300, "wires": [ [ "2ca49b8.92f0764", "82551c31.606ae", "bcbd9e0f.e899d8" ] ] }, { "id": "82551c31.606ae", "type": "ui_gauge", "z": "edde96c.5e59968", "name": "", "group": "900c0194.8d7a9", "order": 2, "width": "6", "height": "5", "gtype": "compass", "title": "La Bàn", "label": "NEWS", "format": "{{value}}", "min": "0", "max": "16", "colors": [ "#00b500", "#e6e600", "#ca3838" ], "seg1": "", "seg2": "", "x": 780, "y": 240, "wires": [] }, { "id": "bcbd9e0f.e899d8", "type": "function", "z": "edde96c.5e59968", "name": "Set Hướng Theo Yêu Cầu", "func": "var huong;\nif (msg.payloadGIAO DIỆN LÀM VIỆC
Xem thêm: Bảng giá
Source: https://dichvubachkhoa.vn
Category : Linh Kiện Và Vật Tư