산업 제조
산업용 사물 인터넷 | 산업자재 | 장비 유지 보수 및 수리 | 산업 프로그래밍 |
home  MfgRobots >> 산업 제조 >  >> Manufacturing Technology >> 제조공정

홈 스마트 홈

구성품 및 소모품

라즈베리 파이 2 모델 B
오렌지색 PI도 가능
× 1
Xbee
× 1
Arduino UNO
× 1

앱 및 온라인 서비스

Microsoft Azure

이 프로젝트 정보

소개

MediaTek Linkit을 사용하여 스마트 홈 시스템을 설정하는 데 필요한 사항을 살펴보겠습니다. 여기에 센서 데이터를 읽기 위한 하드웨어 연결에 대해 안내하는 전문가가 많이 있기 때문에 api를 만들고 모든 센서 데이터를 캡처하기 위한 초저가 $15 로컬 서버를 설정하는 데 집중할 것입니다. 선택적으로 데이터를 Azure에 기록합니다.

설정

센서는 xbee 또는 저렴한 트랜시버를 사용하여 MediaTek LinkIt에 무선 신호를 통해 데이터를 전송합니다. MediaTek linkIt은 모든 원시 센서 데이터를 수신하고 adruinojson 라이브러리를 사용하여 json 객체로 패키징하고 로컬 서버에 POST 요청을 합니다. 그러면 로컬 서버가 nodejs 웹 애플리케이션을 호스팅하고 모든 센서 데이터를 json 객체로 수신합니다.

로컬 서버는 전처리기로 사용되고 utc 시간과 서명을 추가합니다. 모든 데이터 유효성 검사, 변환 및 필터링은 여기에서 처리할 수 있습니다. 로컬 서버는 우리의 경우 azure 스토리지 서비스의 클라우드 서비스에 모든 데이터를 기록합니다. 또는 MediaTek linkIt은 json 개체를 Azure 스토리지 서비스에 직접 게시할 수 있습니다. 15달러짜리 PC가 우리 데이터를 처리하기에 충분히 강력할 수 있다는 것을 증명하기 위해 로컬 서버를 설정했습니다. 우리는 외부 클라우드 스토리지의 필요성을 완전히 제거한 로컬 서버에서도 모든 no-sql db에 데이터를 기록할 수 있습니다. 이 모든 것은 여러분에게 맡깁니다.

데모

<사전><코드>

전제 조건

arduino 또는 mediaTek과 같은 센서 및 마이크로 컨트롤러를 사용하여 센서 데이터를 읽는 방법을 알고 있다고 가정합니다. 이 프로젝트의 범위를 제한하기 위해 MediaTek Link It에서 센서 데이터를 사용할 수 있다고 가정하겠습니다. 낮은 캐스트 라디오 트랜시버 또는 Xbee를 사용하여 MediaTek과 같은 마이크로 컨트롤러에 부착된 센서에서 라디오 신호를 송수신할 수 있습니다. 초보자는 MediaTek linkIt 그루브 스타터 키트를 사용하여 온도, 습도, 조명 등과 같은 외부 환경 데이터를 읽을 수 있습니다.

제이슨 제이슨

Json은 iot의 사실상 표준이 되었으며 널리 채택되었습니다. 전제 조건에 대해 말했으므로 먼저 센서 데이터 모델링을 시작하겠습니다. 주요 목적은 가능한 한 많은 데이터를 캡처하여 서버에 전달하는 것입니다. 서버는 분석, 데이터 변환, 머신 러닝 등과 같은 모든 무거운 작업을 수행할 수 있습니다.

'원하는' json 객체는 센서 데이터의 원하는 상태가 됩니다. 예를 들어 온도를 기록할 때 원하는 값 24는 값을 24로 클라우드에 동기화해야 함을 의미합니다. 웹 앱이나 모바일 앱과 같은 클라이언트는 이 값으로 업데이트됩니다.

조명을 켜고 싶을 때 원하는 상태를 on이라고 합니다. 불이 켜져 있거나 켜질 것임을 의미합니다. 모든 클라이언트 애플리케이션은 이 상태를 사용하여 사용자에 대한 변경 사항을 반영합니다. 즉, 웹 앱의 아이콘이 켜지거나 꺼집니다.

이것은 국제 표준이 아니며 방금 생각해 낸 것입니다. 따라서 자신의 편리한 형식을 자유롭게 사용하십시오.

온도

{ "deviceid" :"iot/myhome/livingroom/thermostat""desired" :{ "온도" :"24", "습도":"80"}, "timeutc":"2015-11 -23T00:41:48.824Z", "singedBy":"로컬 서버"} 

마이크

{ "deviceid" :"iot/myhome/livingroom/mic""desired" :{"intensity" :"66"}, "timeutc":"2015-11-23T00:41:48.824Z" , "singedBy" :"로컬 서버"} 

거리

{ "deviceid" :"iot/myhome/livingroom/obstacle""desired" :{"proximity" :"150"}, "timeutc":"2015-01-01", "singedBy" :"로컬 서버"} 

PIR

{ "deviceid" :"iot/myhome/livingroom/pir""desired" :{"모션 시작" :"2500", "모션 종료" :"5345"}, "timeutc":"2015 -11-23T00:41:48.824Z", "singedBy":"로컬 서버"} 

GPS

{"deviceid":"iot/mydevice/location""desired":{"lat":"25.5", "long":"32.2"},"timeutc":"2015-11-23T00 :41:48.824Z","singedBy" :"로컬서버"} 

수분

{"deviceid" :"/iot/myhome/garden/moisture""desired" :{"moisture":"20"},"timeutc":"2015-11-23T00:41:48.824Z ","singedBy" :"로컬 서버"} 

가스

{"deviceid" :" /iot/myhome/kitchen/gas""desired" :{"leak":"아니요"},"timeutc":"2015-11-23T00:41:48.824Z ","singedBy" :"로컬 서버"} 

{"deviceid" :" /iot/myhome/livingroom/light""desired" :{"intensity":"60"},"timeutc":"2015-11-23T00:41:48.824Z ","singedBy" :"로컬 서버"} 

또는 이것을 사용하십시오.

거실

{"deviceid" :"/iot/myhome/livingroom""desired" :{ "온도" :"25", "습도" :"80", 창문을 열다 ":"닫힘", "밝음":"80", "잡음":"낮음"}} 

침실

{"deviceid" :"/iot/myhome/bedroom""desired" :{ "온도" :"24", "습도" :"70", "창문" 닫기 ":"닫힘", "light":"80", "ac":"on" "noise":"low"}} 

MediaTek - 수신기

로컬 서버에 데이터를 기록하려면 소프트웨어 섹션에 첨부된 ino 파일을 참조하십시오. 센서 데이터가 시뮬레이션되며 실제 판독값을 각 json 객체에 전달할 수 있습니다.

로컬 서버

로컬 서버는 오버헤드를 추가하지만 여러 면에서 도움이 될 것입니다. iot 데이터를 출력하기 위한 전처리기로 로컬 서버를 사용할 수 있습니다. 데이터 필터링, 타임스탬프 및 서명 가능

작은 PC와 nodejs는 로컬 서버에 탁월한 선택입니다. 라즈베리 파이, odriod, 바나나 파이, 비글 본 등과 같은 작은 PC를 선택할 수 있습니다. 저는 이 프로젝트에 주황색 파이($15)를 선택했습니다.

설정

nodejs 5를 지원하는 모든 종류의 Linux OS가 있는 Raspberry pi 2 또는 Orange Pi. arm7용으로 아치 Linux가 있는 오렌지 파이를 선택했습니다. nodejs와 npm을 설치했습니다. github에서 내 iotapp을 다운로드하고 /your/local/path/iotapp으로 이동하여 npm install을 실행합니다. 기본 expressjs 앱은 포트 3000에서 수신 대기하기 시작합니다.

your-local-ip:3000으로 이동하여 기본 expressjs 보기가 렌더링되는지 확인합니다. 센서 데이터를 게시하기 위해 이 API를 만들었습니다.

/iot/myhome/livingroom/thermostat - 온도 API

/iot/myhome/livingroom/mic - 사운드 API

/iot/myhome/livingroom/pir - 존재 센서 API

/iot/myhome/livingroom/distance - 거리 센서 API

/iot/myhome/mydevice/location - GPS 추적기 API

/iot/myhome/garden/moisture - 토양 수분 센서 API

/iot/myhome/kitchen/gas - 가스 누출 센서 API

/iot/myhome/livingroom/light - 광 센서 API

/iot/myhome/livingroom - 거실용 기타 API

/iot/myhome/bedroom - 침실용 기타 API


로컬 서버를 설정하려면. 내 github에서 소스 코드 iotapp을 복제합니다. aspnet5 애플리케이션이 Azure에서 호스팅되는 클라우드 IP 주소 또는 도메인 이름을 입력하도록 index.js를 수정합니다.

원격 서버

클라우드에 데이터를 게시하는 것이 이제 인기를 얻었습니다. amazon, azure, spark fun, pubnub, 초기 상태 및 기타 많은 것과 같은 iot 데이터 제공에서 구독을 구입할 수 있습니다. 이 데모에서는 하늘색을 선택했습니다. 데이터 분석, 데이터 마이닝 및 기계 학습 알고리즘을 개발하여 데이터를 처리할 수 있습니다.

내 github에서 iotwebapp을 다운로드하십시오. asp.net5를 대상으로 하는 Visual Studio 2015를 사용하여 만들었습니다. 이 API는 iot 데이터를 게시하도록 설정되었습니다. api는 azure 스토리지 테이블에 iot를 기록합니다.

deviceid 매개변수는 센서 위치를 식별하도록 설정할 수 있습니다.

이 API가 설정되었습니다.

api/iot/myhome/thermostat - 모든 온도 조절기 데이터를 기록하는 asp.net5 웹 API

모든 마이크 데이터를 기록하는 api/iot/myhome/microphone-asp.net5 웹 API

api/iot/myhome/pir - 모든 pir 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/distance - 모든 거리 센서 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/device/location - GPS 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/moisture - 수분 센서 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/gas - 가스 센서 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/light - 모든 조도 센서 데이터를 기록하는 asp.net5 웹 API

api/iot/myhome/livingroom - 모든 거실 속성/센서 데이터를 기록하는 asp.net5 웹 API 이 하나의 API를 사용하여 모든 센서 값을 푸시할 수 있습니다.

api/iot/myhome/bedroom - 위와 동일하게 침실에 대한 세부 정보를 기록하기 위해 만들었습니다.

원격 서버를 설정하려면. 내 github에서 소스 코드 iotwebapp를 복제합니다. Azure 스토리지 테이블을 만듭니다. IoTController.cs를 수정하고 Azure 스토리지 테이블 계정 이름과 키를 입력합니다. 로컬 서버에서 이 도메인 이름 또는 IP 사용

결론

코드에서 리팩토링해야 할 영역이 많이 있습니다. 자유롭게 수정하고 공격을 당하면 알려주십시오.

<섹션 클래스="섹션 컨테이너 섹션 축소 가능" id="코드">

코드

<울>
  • MediaTekRx
  • nodejs - 로컬 서버
  • ThermoStatController.cs
  • PIRController.cs
  • MoistureController.cs
  • LivingRoomController.cs
  • LightController.cs
  • GPSController.cs
  • GasController.cs
  • DistanceController.cs
  • BedRoomController.cs
  • MediaTekRxC/C++
    Media Tek을 수신기로 사용합니다. 로컬 서버에 로컬 데이터로 스케치
    /* 웹 클라이언트 이 스케치는 MediaTek LinkIt 플랫폼에서 Wi-Fi 기능을 사용하여 웹사이트에 연결합니다. 매크로 WIFI_AP, WIFI_PASSWORD, WIFI_AUTH 및 SITE_URL을 적절히 변경합니다. 2010년 7월 13일 dlf(Metodo2 srl)에 의해 수정됨 Tom Igoe에 의해 2012년 5월 31일 수정됨 MediaTek Inc.에 의해 2014년 8월 20일 수정됨 */#include #include #include #include #define WIFI_AP "귀하의 ap#define WIFI_PASSWORD "암호#define WIFI_AUTH LWIFI_WPA // LWIFI_OPEN, LWIFI_WPA 또는 LWIFI_WEP 중에서 선택합니다.#define SITE_URL "귀하의 IP" //노드js 또는 하늘빛 IP 주소 또는 도메인 이름LWiFiClient c;void setup(){ LWiFi.begin(); Serial.begin(115200); // AP에 연결될 때까지 계속 재시도 Serial.println("Connecting to AP"); 동안 (0 ==LWiFi.connect(WIFI_AP, LWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) { 지연(1000); } // 웹사이트에 연결될 때까지 계속 재시도 Serial.println("Connecting to WebSite"); while (0 ==c.connect(SITE_URL, 3000)) { Serial.println("웹사이트에 다시 연결 중"); 지연(1000); }}boolean disconnectedMsg =false;void loop(){ // 연결되었는지 확인하고 응답 내용을 Serial에 덤프합니다. while (!c) { Serial.println(" Server disconnected.."); // 웹사이트에 연결될 때까지 계속 재시도 Serial.println("Connecting to WebSite"); while (0 ==c.connect(SITE_URL, 3000)) { Serial.println("웹사이트에 다시 연결 중"); 지연(1000); } } Serial.println(" 읽기 온도.."); 업데이트 온도(); 지연(3000); Serial.println("소리 감지.."); 업데이트음(); 지연(3000); Serial.println("사람 움직임 감지.."); 업데이트PIR(); 지연(3000); Serial.println("장애물 감지.."); 업데이트 거리(); 지연(3000); Serial.println("장치 위치 업데이트 중.."); 업데이트GPSTracker(); 지연(3000); Serial.println("토양 수분 계산.."); 업데이트 수분(); 지연(3000); Serial.println("가스 누출 감지.."); 업데이트가스누설(); 지연(3000); Serial.println("빛의 세기를 기록 중입니다.."); updateLightIntensity(); 지연(3000); 업데이트거실속성(); 지연(3000); 업데이트침실속성(); delay(3000);}void writeToConsole(){ // 연결되었는지 확인하고 응답 내용을 직렬로 덤프합니다. while (c) { int v =c.read(); if (v !=-1) { Serial.print((char)v); } } 직렬.println(); Serial.println("서버 연결이 끊겼습니다.."); // 웹사이트에 연결될 때까지 계속 재시도 Serial.println("Connecting to WebSite"); while (0 ==c.connect(SITE_URL, 3000)) { Serial.println("웹사이트에 다시 연결 중"); 지연(1000); } } 무효 updatePIR(){ long unsigned int s; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); root["deviceid"] ="/iot/myhome/livingroom/pir"; //기본 단위 ms로 가정합니다. desired["motionstart"] =String(random(0,1000)); 원하는["모션엔드"]=문자열(랜덤(1000,10000)); 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom/pir HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); // 느린 서버 응답을 감지하고 죽은 응답을 기다리지 않고 요청을 다시 게시하는 논리 s =millis(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); }void updateDistance(){ long unsigned int s; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); root["deviceid"] ="/iot/myhome/livingroom/distancesensor"; //기본 단위 cm로 가정합니다. desired["obstacle"]=String(random(50,450)); 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom/distance HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateGPSTracker(){ long unsigned int s; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); root["deviceid"] ="/iot/mydevice"; 원하는["위도"] =String(임의(20,25)); 원하는["long"]=String(random(22,27)); 문자열 len =문자열(root.measureLength()); c.println("POST /iot/mydevice/location HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole();} 무효 updateMoisture(){ long unsigned int s; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); root["deviceid"] ="/iot/myhome/garden/moisture"; //기본 단위로 가정합니다. desired["moisture"] =String(random(40,60)); 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/garden/moisture HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateGasLeak(){ DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); 원하는["누수"] ="아니요"; root["deviceid"] ="/iot/myhome/주방/가스"; 긴 unsigned int s; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/kitchen/gas HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateLightIntensity(){ DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); 원하는["강도"] ="80"; root["deviceid"] ="/iot/myhome/livingroom/light"; 긴 unsigned int s; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom/light HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateLivingroomAttributes(){ DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); root["deviceid"] ="/iot/myhome/거실"; JsonObject&원하는 =root.createNestedObject("원하는"); //거실 속성 로그인을 위한 대체 API 한 번에 모두 원하는["window"] ="open"; 원하는["문"] ="닫힘"; 원하는["ac"] ="꺼짐"; 원하는["온도"] =String(random(24,28)); 원하는["습도"] =String(random(60,65)); 긴 unsigned int s; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateBedroomAttributes(){ DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); root["deviceid"] ="/iot/myhome/침실"; JsonObject&원하는 =root.createNestedObject("원하는"); //거실 속성 로그인을 위한 대체 API 한 번에 모두 원하는["window"] ="open"; 원하는["문"] ="닫힘"; 원하는["ac"] ="꺼짐"; 원하는["온도"] =String(random(22,23)); 원하는["습도"] =String(random(75,80)); 긴 unsigned int s; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/bedroom HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); } 무효 updateSound(){ long unsigned int s; long unsigned int e; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); 원하는["강도"] =String(random(40,80)); root["deviceid"] ="/iot/myhome/거실/마이크"; 루트["timeutc"] =""; 루트["서명"]=""; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom/mic HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole();} 무효 updateTemperature(){ long unsigned int s; long unsigned int e; DynamicJsonBuffer jsonBuffer; JsonObject&루트 =jsonBuffer.createObject(); JsonObject&원하는 =root.createNestedObject("원하는"); 원하는["온도"] =String(random(20,40)); 원하는["습도"]=String(random(60,80)); root["deviceid"] ="/iot/myhome/livingroom/thermostat"; 루트["timeutc"] =""; 루트["서명"]=""; 문자열 len =문자열(root.measureLength()); c.println("POST /iot/myhome/livingroom/thermostat HTTP/1.1"); c.println("호스트:" SITE_URL); c.println("콘텐츠 유형:애플리케이션/json"); c.println("캐시 제어:캐시 없음"); c.print("내용 길이:"); c.println(len); c.println("연결:닫기"); c.println(); root.printTo(c); root.printTo(직렬); s =밀리(); // 서버 응답을 기다리는 중 Serial.println("HTTP 응답을 기다리는 중:"); 동안 (!c.available()) { 지연(100); if((millis() - s> 3000)) { Serial.println(); Serial.println("서버가 응답하지 않습니다.."); 부서지다; } } Serial.println("콘솔에 쓰기를 호출합니다.."); writeToConsole(); }
    nodejs - 로컬 서버자바스크립트
    Media Tek에서 데이터를 수신하는 경로가 있는 index.js
    var express =require('express');var router =express.Router();var buf =require('buffer');var request =require("요청");//your-ip-or-domain-name을 실제 IP 주소 또는 도메인 이름으로 바꿉니다.//example iot.azurewebsites.com//example yourdomainname.com//example 47.12.67.16// accept 홈페이지의 POST 요청 console.log(상태); var 옵션 ={ 메소드:'POST', URL:'http://your-ip-or-domain-name/api/iot/myhome/livingroom/thermostat', 헤더:{ '캐시 -control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; request(옵션, 함수(오류, 응답, 본문) { if (error) throw new Error(error); console.log(body); }); res.send('거실 온도 기록됨');});// POST 요청 수락 microuter.post('/iot/myhome/livingroom/mic' , 재미있는 동작(요청, 해상도) { var 상태 =요청.바디; state.timeutc =새로운 날짜(); state.signedby ="오렌지파이"; console.log(상태); var 옵션 ={ 방법:'POST', URL:'http://your-ip-or-domain-name/api/iot/myhome/livingroom/microphone', 헤더:{ '캐시 제어':'아니요- 캐시', '콘텐츠 유형':'응용 프로그램/json' }, 본문:상태, json:true }; 요청(옵션, 함수(오류, 응답, 본문) { if (오류) throw new Error(error); console.log(body); }); res.send('거실 소리 강도 기록됨');});// POST 요청 수락 pirrouter.post('/iot/myhome/livingroom/pir', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ 메소드:'POST', url:'http://your-ip-or-domain-name /api/iot/myhome/livingroom/pir', 헤더:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; 요청 (옵션, 기능(오류, 응답, 본문) { if (error) throw new Error(error); console.log(body); }); res.send('거실 pir 움직임 ​​기록됨');});/ / POST 요청 수락 distancerouter.post('/iot/myhome/livingroom/distance', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ 메소드:'POST', URL:'http://your-ip-or-domain-name/api/iot/myhome/livingroom/distance', 헤더:{ '캐시 -control':'캐시 없음', '콘텐츠 유형':'application/json' }, 본문:상태, js 켜짐:참 }; 요청(옵션, 함수(오류, 응답, 본문) { if (오류) throw new Error(error); console.log(body); }); res.send('거실 장애물 기록');});// POST 요청 수락 gpsrouter.post('/iot/mydevice/location', function (req, res) { var state =req.body; state.timeutc =새로운 날짜(); state.signedby ="오렌지피"; console.log(상태); var 옵션 ={ 메소드:'POST', URL:'http://your-ip-or-domain-name/api/ iot/mydevice/location/gps', 헤더:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; 요청(옵션, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('장치 위치 기록');});// POST 요청 수락 습기 라우터 .post('/iot/myhome/garden/moisture', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state ); var options ={ method:'POST', url:'http://your-ip-or-domain-name/api/iot/myhome/garden/moisture', headers:{ 'cache-control':' no-cache', 'content-type':'application/json' }, body:state, json:true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('Garden moisture level recorded');});// accept POST request gasrouter.post('/iot/myhome/kitchen/gas', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ method:'POST', url:'http://your-ip-or-domain-name/api/iot/myhome/kitchen/gas', headers:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('Gas leak information recorded');});// accept POST request lightrouter.post('/iot/myhome/livingroom/light', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ method:'POST', url:'http://your-ip-or-domain-name/api/iot/myhome/livingroom/light', headers:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; request(optio ns, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('Light intensity recorded');});// accept POST request livingroomrouter.post('/iot/myhome/livingroom', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ method:'POST', url:'http://your-ip-or-domain-name/api/iot/myhome/room/livingroom', headers:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('Livingroom attributes recorded');});// accept POST request bedroomrouter.post('/iot/myhome/bedroom', function (req, res) { var state =req.body; state.timeutc =new Date(); state.signedby ="orangepi"; console.log(state); var options ={ method:'POST', url:'http://your-ip-or-domain-name/api/iot/myhome/room/bedroom', headers:{ 'cache-control':'no-cache', 'content-type':'application/json' }, body:state, json:true }; request(options, fu nction (error, response, body) { if (error) throw new Error(error); console.log(body); }); res.send('Bedroom attributes recorded');});// accept PUT request at /userrouter.put('/user', function (req, res) { res.send('Got a PUT request at /user');});// accept DELETE request at /user//router.delete('/user', function (req, res) {// res.send('Got a DELETE request at /user');//});/* GET home page. */router.get('/', function(req, res, next) { res.render('index', { title:'Express' });});module.exports =router;
    ThermoStatController.csC#
    api to log temperature data to the cloud
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Newtonsoft.Json;using Microsoft.WindowsAzure.Storage;using Microsoft.WindowsAzure.Storage.Auth;using Microsoft.WindowsAzure.Storage.Table;// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/livingroom/[Controller]")] public class ThermoStatController :IoTController { // GET:// public IActionResult Index() { return View(); } [HttpPost] public IActionResult Post([FromBody]IotTemperature iotTemperature) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotTemperature.PartitionKey ="thermostat"; iotTemperature.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotTemperature); // Execute the insert operation. table.Execute(insertOperation); return Ok("Temperature data logged to azure cloud.."); } } public class IotTemperature :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string temperature { get; 세트; } public string humidity { get; 세트; } } }}
    PIRController.csC#
    api to log presence sensor data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/livingroom/[Controller]")] public class PIRController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotPIR iotPIR) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotPIR.PartitionKey ="pir"; iotPIR.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotPIR); // Execute the insert operation. table.Execute(insertOperation); return Ok("PIR data logged to azure cloud.."); } } public class IotPIR :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string motionstart { get; 세트; } public string motionend { get; 세트; } } }}
    MoistureController.csC#
    api to log soil moisture data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/garden/[Controller]")] public class MoistureController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotMoisture iotMoisture) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotMoisture.PartitionKey ="moisture"; iotMoisture.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotMoisture); // Execute the insert operation. table.Execute(insertOperation); return Ok("Moisture data logged to azure cloud.."); } } public class IotMoisture :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string moisture { get; 세트; } } }}
    LivingRoomController.csC#
    api to log all living room sensor data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/room/[controller]")] public class LivingRoomController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotLivingRoom iotLivingRoom) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotLivingRoom.PartitionKey ="livingroom"; iotLivingRoom.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotLivingRoom); // Execute the insert operation. table.Execute(insertOperation); return Ok("Living room attributes logged to azure cloud.."); } } public class IotLivingRoom :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string window { get; 세트; } public string door { get; 세트; } public string ac { get; 세트; } public string temperature { get; 세트; } public string humidity { get; 세트; } } }}
    LightController.csC#
    api to log light sensor data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/livingroom/[Controller]")] public class LightController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotLight iotLight) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotLight.PartitionKey ="light"; iotLight.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotLight); // Execute the insert operation. table.Execute(insertOperation); return Ok("Light intensity logged to azure cloud.."); } } public class IotLight :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string intensity { get; 세트; } } }}
    GPSController.csC#
    api to log gps data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/mydevice/location/[Controller]")] public class GPSController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotGPS iotGPS) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotGPS.PartitionKey ="gps"; iotGPS.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotGPS); // Execute the insert operation. table.Execute(insertOperation); return Ok("GPS data logged to azure cloud.."); } } public class IotGPS :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string lat { get; 세트; } [JsonProperty("long")] public string longitude { get; 세트; } } }}
    GasController.csC#
    api to log gas leakage data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/kitchen/[Controller]")] public class GasController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotGas iotGas) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotGas.PartitionKey ="gas"; iotGas.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotGas); // Execute the insert operation. table.Execute(insertOperation); return Ok("Gas leak information logged to azure cloud.."); } } public class IotGas :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string leak { get; 세트; } } }}
    DistanceController.csC#
    api to log ultrasonic distance sensor data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/livingroom/[Controller]")] public class DistanceController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotDistance iotDistance) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotDistance.PartitionKey ="distance"; iotDistance.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotDistance); // Execute the insert operation. table.Execute(insertOperation); return Ok("Obstacle data logged to azure cloud.."); } } public class IotDistance :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string obstacle { get; 세트; } } }}
    BedRoomController.csC#
    api to log all bedroom sensor data to azure
    using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNet.Mvc;using Microsoft.WindowsAzure.Storage.Table;using Newtonsoft.Json;// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860namespace iotwebapp.Controllers{ [Route("api/iot/myhome/room/[controller]")] public class BedRoomController :IoTController { [HttpPost] public IActionResult Post([FromBody]IotBedRoom iotBedRoom) { // Create the table client. CloudTableClient tableClient =storageAccount.CreateCloudTableClient(); // Create the CloudTable object that represents the "people" table. CloudTable table =tableClient.GetTableReference("iot"); iotBedRoom.PartitionKey ="bedroom"; iotBedRoom.RowKey =Guid.NewGuid().ToString(); // Create the TableOperation object that inserts the customer entity. TableOperation insertOperation =TableOperation.Insert(iotBedRoom); // Execute the insert operation. table.Execute(insertOperation); return Ok("Bed room attributes logged to azure cloud.."); } } public class IotBedRoom :TableEntity { public string deviceid { get; 세트; } public string timeutc { get; 세트; } public string signedby { get; 세트; } public string state { get { return JsonConvert.SerializeObject(this.desired); } set {; } } public Desired desired { get; 세트; } public class Desired { public string window { get; 세트; } public string door { get; 세트; } public string ac { get; 세트; } public string temperature { get; 세트; } public string humidity { get; 세트; } } }}
    Media Tek Smart home - Source code for data logging
    source code for nodejsapp, aspnet5 and mediatek receiver inohttps://github.com/syediddi/iot-mediatek-linkIt

    회로도

    Transmit radio signal from arduino Transmit radio signal via Xbee from arduino without shield Transmit radio signals from arduino

    제조공정

    1. 스마트 데이터:IoT의 차세대 개척자
    2. Sensorflare 및 RaspberryPi가 포함된 433MHz 스마트 홈 컨트롤러
    3. RASPBERRY PI 홈 자동화
    4. Smart Bartender
    5. 미래의 스마트 병원에는 더 스마트한 소프트웨어가 필요합니다
    6. 스마트 홈 기술 격차
    7. 직장에서 상호 연결의 이점
    8. 스마트해지:가정의 미래
    9. 스마트 팩토리 파이프의 꿈
    10. 스마트 홈 연결:주요 장애물을 극복하기 위한 3단계