Connect Arduino to PubNub

See more at: Connect Arduino to PubNub in 2 Steps

PubNub is a provider of APIs that publishers as like Temboo.
Developers and Makers can use to implement messaging on cloud websites and SNS Apps by usin PubNub API.

PunNub

The PubNub Data Stream Network powers thousands of apps, streaming 50 billion messages to 150 million devices a month..

This tutorial explains the steps to connect an Arduino to the PubNub Data Stream Network.
STEP 1: Connect the Arduino to a monitor, keyboard, mouse and ethernet cable.

STEP 2: You’ll need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys in the PubNub Developer Portal. Be sure to input your unique publish/subscribe keys!

In this tutorial, Arduino Ethernet Shield is provides the Internet connectivity.
Arduino mega + Ethernet Shield

Note4 – Ethernet shield

ArduinoNote List-page
PREVIOUS: Note3 – Hello world

Ethernet Shield

Ethernet Shield

Arduino Ethernet Shield는 Arduino Platform들을 Internet에 연결할 수 있는 Arduino Platform에 Plug-in하는 Module이다. Ethernet Shield에는 TCP/UDP Network stack을 처리할 수 있는 Ethernet Chip인 W5100 (WIZnet)가 onboard되어 있다. 이 칩과 제공되는 Ethernet Library를 통해 Arduino Platform이 Internet에 연결될수 있도록 합니다. 또한 이 Shield에서 RJ45 (Ethernet) Port를 통해 Ethernet Cable를 연결할 수 있으며, Micro-SD Slot을 지원하여 Network를 통한 File을 저장할 수 있도록 지원한다.

Serial Peripheral Interface

Arduino의 MCU와 Ethernet Shield의 W5100의 Connection을 위해 Serial Peripheral Interface(SPI)를 사용한다. SPI는 Synchronous Serial data protocol를 사용하며 Duplex를 지원하는 Bus Interface이다. 아래와 깉이 MISO, MOSI, SCK, SS 4개의 Line으로 구성돤다.

  • SPI Signals
    • MISO (Master In Slave Out) – The Slave line for sending data to the master
    • MOSI (Master Out Slave In) – The Master line for sending data to the peripherals
    • SCK (Serial Clock) – The clock pulses which synchronize data transmission generated by the master
    • SS (Slave Select) – the pin on each device that the master can use to enable and disable specific devices.
  • Connections
    아래 표와 같이 Arduino Board마다 SPI port가 각각 다르며 ICSP에는 SPI Interface가 공통으로 존재합니다.

    Arduino Board MOSI MISO SCK
    Uno or Duemilanove 11 or ICSP-4 12 or ICSP-1 13 or ICSP-3
    Mega1280 or Mega2560 51 or ICSP-4 50 or ICSP-1 52 or ICSP-3
    Leonardo ICSP-4 ICSP-1 ICSP-3
    Due ICSP-4 ICSP-1 ICSP-3
    • ICSP Header
      ICSP Header
  • Ethernet shield compatible (W5100 base)
    • Seeedstudio
      Seeedstudio
    • DFROBOT
      DFROBOT
    • e-gizmo
      e-gizmo

NEXT : Note5 – isShield-A

ARDUINO with TEMBOO

-www.temboo.com
템부(Temboo)는 기업들은 API 관리 전문업체 중 하나이다. 보안 API 접속 서비스는 물론이고 일부는 API 호환 서비스를, 또 일부는 클라우드 기반의 API 접근경로를 제공한다.
 
-Program hardware for the Internet of Things
위의 그림처럼 IoT의 hardware 들을 위한 API (Agent+SDK), Cloud service까지 그 영역을 넓혀가는 중이며 Open Hardware의 선두주가 Arduino와 LaunchPad를 중심으로한 Texas Instruments사의 Platform을 현재 지원중이다.
글보단 한편의 동영상으로 Temboo를 이해해 보자
IoT Hardware을 위한 API를 살펴보면서 그 막강한 기능을 체험해보자.
Yahoo Weather를 Temboo와 Arduino를 이용한다.
*Preparation materials
-Arduino board : Arduino Due
-Ethernet Shield : WIZ550io (W5500 with MAC address)
-IDE : IDE 1.5.7
-Lib. : Ethernet Lib. and Temboo Lib
1. 먼저 Temboo에 로그인 한뒤 아래의 페이지에서 “Arudino” 클릭 
-Select Arduino on Program hardware for the Internet of Things
2. ARDUINO+TEMBOO에서 자신이 사용하려는 Hardware선택 
– Select Device: Arduino Yun or Other Arduino Boards + Internet Shield
3. 이제 Temboo Arduino Library의 설치를 위해 아래의 그림에서 우측상단의 “Download”클릭 
– ARDUINO+TEMBOO
4. Installing에 관한 대용은 아래의 사이트를 참고하며 간단하게 download된 Temboo Arduino Library를 “C:\Program Files\Arduino\libraries” 에 압축을 푼다. IDE1.5.7기준! 
– Installing the Temboo Arduino Library
5. 이제 예제를 선택한다 여기서는 GetWeatherByAddress! 
– Select GetWeatherByAddress with Temboo Arduino Library
6. 이제 몇가지 설정으로 GetWeatherByAddress.ino를 생성 시키자
-우측상단의 “IoT Mode”를 “ON”으로 활성화
-GetWeatherByAddress란에서 “The address to be searched”밑의 박스에 “Seoul”를 입력 뒤 코드의 생성을 위해 Run을 클릭
-CODE란에 생성된 코드 확인 및 복사 
– Configuration and Generation of CODE
7. IDE에서 Compile 및 다운로드
-“C:\Program Files\Arduino\libraries\Temboo\”폴더 밑에 아래와 같이 examples\YahooWeather폴더를 생성한다.
-“C:\Program Files\Arduino\libraries\Temboo\examples\YahooWeather”에 복사한 코드를 폴더명과 같은 이름으로 복사한다.
– 컴파일 후 다운로드
8. Demo: Serial Monitoring
아래와 같이 Seoul의 날씨를 HTTP Get을 통해 해당 웹페이지를 다운받아 Serial로 출력시키는 것을 볼 수 있다.
-Get Seoul Weather http message on Serial Monitoring