Internet of things project: Connect Arduino to Ubidots and Android – Part 1 & 2

by Francesco Azzola



Overview

This IoT project explores how to connect Arduino to Ubidots and Android. One important aspect in Arduino Internet of things programmin is how to connect arduino to internet and store date to IoT cloud platforms using arduino ethernet shield. This aspect is important because it is possible to store data in the cloud and then analyze it. Once the data, like sensor values, is on the cloud is possible to access it using smart phones and control remotely the Arduino board.

As soon as the temperature and humidity sensor starts reading values, it sends them through Arduino board to the cloud platform. The project uses Ubidots to store data in the cloud. This platform is easy to use and can be easily integrated with Arduino. Moreover, it has a built-in dashboard features, so that it is possible to creates interesting dashboard to show, using charts, the values sent from the board.

Components

  • W5500 Ethernet Shield
  • Arduino-Uno
  • DHT11
  • Ubidots

How to Build

  1. Connect the DHT11 to Arduino-Uno

  2. Import DHT11 Libary to Arduino IDE
    In this sketch, DHT11 sensor is connected to Arduino board, that, in turn, uses the Arduino Ethernet shield to connect to the network to send data. As first step, we check if everything is connected correctly trying to read the value of the temperature and the humidity. The snippet below shows the Arduino sketch to test the sensor:

    #include "DHT.h"
    #include <spi.h>
    #define DHTPIN 2
    #define DHTTYPE DHT11
    
    DHT dht(DHTPIN, DHTTYPE);
    
    void setup() {
     Serial.begin(9600);
     dht.begin();
    }
    
    void loop() {
     delay(50000);
    
     float h = dht.readHumidity();
     // Read temperature as Celsius (the default)
     float t = dht.readTemperature();
    
     Serial.print("Humidity: ");
     Serial.print(h);
     Serial.print(" %t");
     Serial.print("Temperature: ");
     Serial.print(t);
     Serial.println(" *C ");
    }
    
  3. Register the arduino to Ubidots & Import Ubidots Library to Arduino IDE

    http://things.ubidots.com/api/v1.6/collections/values
    

    Refer to Ubidots Dco

  4. Implements WebClient for Arduino
    Ubidots provides an example that can be useful. In Arduino, we have to develop an ArduinoHTTP client that calls a JSON service passing the data we want to store in the cloud.

    JSON Format :
    [{"variable": "varId", "value":val, "timestamp":timestamp},{"variable": "vardId1", "value":val1, "timestamp":timestamp1}]

Learn More

Goto Original
Get Free Arduino Things Free Source

블로그 이미지

밤소 MidnightCow

위즈네트 칩(W5300, W5200, W7100, W7500) 개발자

World Domination Using Arduinos and Websockets

by kevinrohling



Overview

In this post, Author say that arduinos are tons of fun and recommend remotely controlling robot to you. And, Author recommend solutions how to remotely control robot. It is to use pusher, a real-time push notification service that runs over WebSockets.

Building the WebSocket Client

WebSockets are an interesting hybrid between HTTP and raw TCP connections. They start life very much like a normal HTTP GET request. In the request the client sends a bit information asking for an “upgraded” connection. Once the server sees this, if WebSockets are supported it sends a response back with a status code of 101 indicating that the connection was successfully upgraded. Then, and here’s where things diverge from HTTP, nobody closes the connection. Both the client and the server remain connected to each other. Here’s what this looks like at the socket level:

  • Client Requests a WebSocket Connection

    GET /app/yourpusherapikey?client=js&version=1.9.0 HTTP/1.1
    Upgrade: WebSocket 
    Connection: Upgrade 
    Host: ws.pusherapp.com:80 
    Origin: ArduinoWebSocketClient
    
  • Server responds indicating that the upgrade was successful

    HTTP/1.1 101 Web Socket Protocol Handshake
    Upgrade: WebSocket 
    Connection: Upgrade 
    WebSocket-Origin: ArduinoWebSocketClient 
    WebSocket-Location: ws://ws.pusherapp.com:80/app/yourpusherapikey?client=js&version=1.9.0 
    Connected
    

Controlling an Arduino Robot using Websockets and Pusher

Learn More

Goto Original


 

블로그 이미지

밤소 MidnightCow

위즈네트 칩(W5300, W5200, W7100, W7500) 개발자

JSON - What is?

JSON 2016.09.05 16:51

JSON - What is ?



Overview

JAVAScript Obejct Notation의 약자로 2001년 더글라스 크락포드가 LISP(List Processing)에서 아이디어를 얻어 텍스트 형식으로 데이타를 저장하는 JavaScript 문법을 JSON이라 명명하고 문서화 했다. 즉 JavaScript에서 표현되고, 전달 될 수 있는 Data 기술 방식이나, 오늘날 많은 Web Application에서 복잡한 XML 대신 테스트로 표현가능하고, 사람이 읽고 쓰기 용이할 뿐만 아니라, Machine에서의 생성과 분석 또한 용이한 Data-교환의 이상적 언어로 만들어지고 있다. JSON은 Java와 JavaScript 뿐만 아니라 C, C++, C#, Perl, Phython, Ruby 등에서도 뛰어난 활용성으로 널리 사용되고 있다.

공식사이트

JSON

JSON은 크게 두가지 기본를 두고 있다.

  • JON은 기본적으로 Name/Vaule 형태의 쌍으로 Collection
    object, record, struct, dictionary, hash table, 키가 있는 list 등을 지원
  • 값들의 순서화된 리스트
    array, vector, list, sequence

이 두가지는 연상 배열과 색인 배열로 실현될 수 있다.

연상 배열

특정 키/Name와 Vaule의 쌍들로 비순서화된 SET으로 { }로 표현된다.

색인 배열

순서화된 Collection 으로 [ ]로 표현된다.

연상 배열 VS 색인 배열

연상 배열과 색인 배열은 Key 유무와 SET을 표현하는 기호의 차이로 구분된다.

  • 연상 배열 : key, {}
  • 색인 배열 : [ ]
JSON Example

다음은 User에 대한 JSON object가 각 User 정보등을 Arrary로 가지고 있는 예제이다.

JSON 과 Web-Browser Viewer
  • Chrome : JSON을 기본적으로 지원하지만, Plug-in을 설치하면 보다 계층적으로 볼 수 있다.

    • JSONview

    • 실행 화면

  • iExplore : JSON을 지원하지 않음. JSON 지원을 위해서는 Register를 아래와 같이 수정해야 한다.

    • IE-Json.reg로 복사 후 저장하고 실행한다.
    • 실행화면

Windows Registry Editor Version 5.00;
; Tell IE 7,8,9,10,11 to open JSON documents in the browser on Windows XP and later.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place"19
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/x-json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
블로그 이미지

밤소 MidnightCow

위즈네트 칩(W5300, W5200, W7100, W7500) 개발자