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) 개발자

Build a cloud-ready temperature sensor with the Arduino Uno and the IBM Watson IoT Platform

Part 2: Write the sketch and connect to the IBM Watson IoT Platform

by Kyle Brown



Overview

In Part 1 of this four-part tutorial series, I discussed the design of a project for monitoring temperatures in my wiring closet, built by using the Arduino Uno and the Virtuabotix DHT11 temperature sensor. I showed the construction of the circuit for the project and walked you through the installation of the Arduino IDE and how to test out each of the individual components of the project with different Arduino sample sketches. You’re now ready to see the design of the sketch that ties the IoT project into the cloud and the steps to enable monitoring of realtime temperature and humidity data remotely. However, first I need to discuss the protocol that you’ll use to communicate with the IBM IoT Foundation: MQTT.

What is MQTT?

MQTT (formerly Message Queueing Telemetry Transport) is a lightweight, fast communications protocol designed for the Internet of Things. It has its origins at IBM (where it was originally developed by Andy Stanford-Clark), and it has since been submitted to Organization for the Advancement of Structured Information Standards (OASIS) for standardization, where the current version of the protocol standard is version 3.1. The MQTT V3.1 Protocol Specification specification states that its purpose is to be a “lightweight broker-based publish/subscribe messaging protocol designed to be open, simple, lightweight and easy to implement.” In the time since its introduction, the “easy to implement” part has certainly proven to be true, as several different libraries implementing MQTT clients have been developed. You can find links to nearly all of them at the Eclipse Paho project page.

MQTT is perfect for use in embedded devices because it:

  • Is asynchronous, with multiple different levels of quality of service, which is important in cases where Internet connections are unreliable.
  • Sends short, tight messages that make it handy for low-bandwidth situations.
  • Doesn’t require much software to implement a client, which makes it great for devices like the Arduino with limited memory.

MQTT is the protocol that the IBM IoT Foundation QuickStart is designed to take input on.

Resources

Learn
MQTT V3.1 Protocol Specification: Read the latest version of the MQTT specification.
IBM Internet of Things Foundation: Try out the IBM IoT Foundation and sign up for the beta program.
Arduino: Visit the Arduino website.
“Bluemix and the Internet of Things” (Ryan Baxter, developerWorks, July 2014): Find out how IBM Bluemix and the IBM IoT Foundation can work together.

Get products and technologies
MQTT client for Arduino: Click the GutHub link to download the client.
Mosquitto: Download the Mosquitto broker.
Eclipse Paho Project: Download MQTT clients.

Learn more

Goto Original
Goto Part1

블로그 이미지

밤소 MidnightCow

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