Tuesday, February 23, 2016

Arduino - MQTT - Raspberry Pi

a. What I have done in the class:

I have integrated my Raspberry Pi and Arduino through MQTT, to listen and respond on photocell(sensors that allow you to detect light) readings. I used pubsubclient to test request-response on wifi. Arduino - Pubsubclient provides examples of basic tests, so that we can test pre requirements.

Arduino - Hardware
  1. Arduino WiFi Module
  2. Photocell
  3. Resistors (10k, 330 ohm)
  4. LED
  5. Jumping wires
Arduino - Software / MQTT
There are four main tasks the Arduino software needs to take care of for this example:
  • Gather light sensor readings periodically
  • Publish sensor readings via MQTT
  • Listen for commands via MQTT
  • Control the LED based on a setpoint
  • An MQTT client is created in the setup function.
Experimnet overview:

The MQTT client connects (if it is not already connected).
Based on the “sensing mode” the application decides how to drive the LED.  It could be OFF, ON or SENSE.  In the SENSE case a light reading is taken and the LED is driven according to a hardcoded setpoint.

#include <SPI.h>
#include <PubSubClient.h>
#include <ESP8266WiFi.h>

#define MQTT_SERVER "q.m2m.io"

byte MAC_ADDRESS[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x31, 0xB8 };
PubSubClient client;

// Pin 9 is the LED output pin
int ledPin = 9;
// Analog 0 is the input pin
int lightPinIn = 0;

// defines and variable for sensor/control mode
#define MODE_OFF    0  // not sensing light, LED off
#define MODE_ON     1  // not sensing light, LED on
#define MODE_SENSE  2  // sensing light, LED controlled by software
int senseMode = 0;

unsigned long time;

char message_buff[100];

void setup()
{
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);

  // init serial link for debugging
  Serial.begin(9600);

  if (Ethernet.begin(MAC_ADDRESS) == 0)
  {
      Serial.println("Failed to configure Ethernet using DHCP");
      return;
  }

  client = PubSubClient(MQTT_SERVER, 1883, callback);
}

void loop()
{
  if (!client.connected())
  {
      // clientID, username, MD5 encoded password
      client.connect("arduino-mqtt", "", "");
      client.publish("io.m2m/arduino/lightsensor", "I'm alive!");
      client.subscribe("io.m2m/arduino/lightsensor");
  }

  switch (senseMode) {
    case MODE_OFF:
      // light should be off
      digitalWrite(ledPin, LOW);
      break;
    case MODE_ON:
      // light should be on
      digitalWrite(ledPin, HIGH);
      break;
    case MODE_SENSE:
      // light is adaptive to light sensor
   
      // read from light sensor (photocell)
      int lightRead = analogRead(lightPinIn);

      // if there is light in the room, turn off LED
      // else, if it is "dark", turn it on
      // scale of light in this circit is roughly 0 - 900
      // 500 is a "magic number" for "dark"
      if (lightRead > 500) {
        digitalWrite(ledPin, LOW);
      } else {
        digitalWrite(ledPin, HIGH);
      }
   
      // publish light reading every 5 seconds
      if (millis() > (time + 5000)) {
        time = millis();
        String pubString = "{\"report\":{\"light\": \"" + String(lightRead) + "\"}}";
        pubString.toCharArray(message_buff, pubString.length()+1);
        //Serial.println(pubString);
        client.publish("io.m2m/arduino/lightsensor", message_buff);
      }
   
   
  }

  // MQTT client loop processing
  client.loop();
}

// handles message arrived on subscribed topic(s)
void callback(char* topic, byte* payload, unsigned int length) {

  int i = 0;

  for(i=0; i<length; i++) {
    message_buff[i] = payload[i];
  }
  message_buff[i] = '\0';

  String msgString = String(message_buff);

  if (msgString.equals("{\"command\":{\"lightmode\": \"OFF\"}}")) {
    senseMode = MODE_OFF;
  } else if (msgString.equals("{\"command\":{\"lightmode\": \"ON\"}}")) {
    senseMode = MODE_ON;
  } else if (msgString.equals("{\"command\":{\"lightmode\": \"SENSE\"}}")) {
    senseMode = MODE_SENSE;
  }
}

I was able to connect and receive the responses, but I didn't observe the light to be turn on and off.
I think I still need to improve the program to work on my experiment.



Program to connect to the MQTT Server:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <String.h>


const char* ssid = "Pi_AP";
const char* password = "Raspberry";
const char* mqtt_server = "192.168.0.34";

WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
int timer = 200;
int ar[] = {15, 12, 4, 16};


void setup_wifi() {

  delay(10);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}



void off() {

  for(int i = 0; i < 4 ; i++){
  digitalWrite(ar[i], LOW);
  }

}

void red() {
  off();
  for(int i = 0; i < 2 ; i++){
    digitalWrite(ar[i], HIGH);
  }
}

void yellow() {
  off();
  for(int i = 2; i < 4 ; i++){
    digitalWrite(ar[i], HIGH);
  }
}


void allOn() {

  for(int i = 0; i < 4 ; i++){
  digitalWrite(ar[i], HIGH);
  }

}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  Serial.println();

  String s = "";

  for(int i = 0; i< length; i++) {
    char a = ((char)payload[i]);
    s = s + a;
  }


  if( s == "disco") {
    disco();
  }
  else if( s == "on"){
    allOn();
  }
  else if( s == "off") {
    off();
  }
  else if(s == "red") {
    red();
  }
  else if(s == "yellow") {
    yellow();
  }

}

void reconnect() {
   while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
      if (client.connect("ESP8266Client")) {
      Serial.println("connected");
          client.publish("outTopic", "hello world");
        client.subscribe("inTopic");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
           delay(5000);
    }
  }
}

void setup() {
  for(int i = 0; i < 4; i++){
    pinMode(ar[i],OUTPUT);  
  }
  Serial.begin(115200);

  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  long now = millis();
  if (now - lastMsg > 1000) {
    lastMsg = now;
    ++value;
    snprintf (msg, 75, "hello world #%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish("outTopic", msg);
     }
}

b. To whom I helped and What I did for them:

  • I  helped HemaLatha to connect to her server and getting connection responses from the server. Also I helped her to modify the code to work on our experiment to get the result. In the class, she almost done with her experiment. We saw the light blinked only once, but need to implement further.
  • I also helped Bhargav, Pavan, Sandeep and Jorge, to do basic test on pubsubclient.

c. Who helped me and What they did for me:

  • Bhargav, Pavan, Sandeep and Jorge helped to me find the resources on the web, wiring diagrams and modification in the given code.

References:

  • http://www.rs-online.com/designspark/electronics/blog/building-distributed-node-red-applications-with-mqtt
  • http://jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/
  • http://pubsubclient.knolleary.net/
  • https://learn.adafruit.com/photocells/overview
  • http://m2mio.tumblr.com/post/30048662088/a-simple-example-arduino-mqtt-m2mio

Saturday, February 13, 2016

Tutorial: MQTT


MQTT stands for MQ Telemetry Transport. It is essentially a simple format for sending small data packages back and forth. It is a publish/subscribe, extremely simple and lightweight messaging protocol that is optimized to connect physical world devices and events with enterprise servers and other consumers. It is designed for constrained devices and low-bandwidth, high-latency or unreliable networks. The design principles are to minimise network bandwidth and device resource requirements whilst also attempting to ensure reliability and some degree of assurance of delivery.

These principles also turn out to make the protocol ideal of the emerging “machine-to-machine” (M2M) or “Internet of Things” world of connected devices, and for mobile applications where bandwidth and battery power are at a premium. It is described as a machine-to-machine(M2M)/IoT connectivity protocol and is so lightweight that it can be supported by some of the smallest measuring and monitoring devices. It can transmit data over far reaching, sometimes intermittent networks.

MQTT is designed to overcome the challenges of connecting the rapidly expanding physical world of sensors, actuators, phones, and tablets with established software processing technologies. TCP/IP port 1883 is reserved with IANA for use with MQTT. TCP/IP port 8883 is also registered, for using MQTT over SSL.

Refrences:

  • http://www.rs-online.com/designspark/electronics/blog/building-distributed-node-red-applications-with-mqtt
  • http://pubsubclient.knolleary.net/
  • https://github.com/knolleary/pubsubclient
  • http://www.rs-online.com/designspark/electronics/blog/an-mqtt-powered-display-using-an-arduino-ethernet-and-lcd
  • https://github.com/francoisvdm/TT3
  • https://github.com/mqtt/mqtt.github.io/wiki/software?id=software
  • http://stackoverflow.com/questions/32327512/mqtt-between-arduino-and-raspberry-pi
  • http://forum.arduino.cc/index.php?topic=330222.0
  • http://tech.scargill.net/mqtt-on-arduino/
  • http://jpmens.net/2013/02/25/lots-of-messages-mqtt-pub-sub-and-the-mosquitto-broker/
  • https://www.element14.com/community/groups/arduino/blog/2015/03/14/getting-data-over-the-internet-with-arduino

Raspberry Pi - WiFi AP

Setting up Raspberry Pi as a WiFi access point:

As we know, our Raspberry Pi can used for lot of purposes, today we are going to do an experiment to make it as an access point of WiFi (Interner Hub or WiFi router). It is an advanced feature to use raspberry pi as an access point rather as a client, with spending very less time on configuration. To set up raspberry pi as an access point, follow below configuration steps.

Installing software to make pi as host access point:

  • First update the existing packages: 'sudo apt-get update'
  • To install hostap: 'sudo apt-get install hostapd isc-dhcp-server'
  • DHCP Server: Open and edit dhcpd.conf file to setup DHCP server on pi by using the following step;
  • To open file in edit mode: sudo nano /etc/dhcp/dhcpd.conf
  • Find and comment the two lines in the file:                                                                          option domain-name "example.org";         option domain-name-servers ns1.example.org, ns2.example.org;
  • Remove # from the lines:                                                                                                      # If this DHCP server is the official DHCP server for the local         # network, the authoritative directive should be uncommented.
             authoritative;
  • Then scroll down to the bottom and add the following lines:                                              subnet 192.168.42.0 netmask 255.255.255.0 {                                                            range 192.168.42.10 192.168.42.50;
             option broadcast-address 192.168.42.255;
             option routers 192.168.42.1;
             default-lease-time 600;
             max-lease-time 7200;
             option domain-name "local";
             option domain-name-servers 8.8.8.8, 8.8.4.4;
             }
  • Save the file: ctrl + X, then Y then return.

  • Now, run: 'sudo nano /etc/default/isc-dhcp-server' and scroll down to INTERFACES="" and update it to say INTERFACES="wlan0". Close and save the file.
  • wlan0 for static IP: Before moving farward make sure that wlan0 is not active. Make it inactive using command: 'sudo ifdown wlan0'
  • set up the wlan0 connection to be static and incoming:                                                                    'sudo nano /etc/network/interfaces'
  • Comment(#) the line in the file 'auto wlan0' and comment the lines afterwards the current line.
  •  add the lines into the file: iface wlan0 inet static
       address 192.168.42.1


       netmask 255.255.255.0
  • Save the file and return.
  • Assign a static IP address to the wifi adapter: 'sudo ifconfig wlan0 192.168.42.1'

  • Configure Access Point:  Now we can configure the access point details. We will set up a password-protected network so only people with the password can connect. 
  • Create file using command: 'sudo nano /etc/hostapd/hostapd.conf'
  •  Write the following code into file:    interface=wlan0
    driver=rtl871xdrv
    ssid=Pi_AP
    hw_mode=g
    channel=6
    macaddr_acl=0
    auth_algs=1
    ignore_broadcast_ssid=0
    wpa=2
    wpa_passphrase=Bhargav
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP
  • Save the file and return 
  • Now we need to setup configuration file for Raspberry Pi:                                                             'sudo nano /etc/default/hostapd'
  • Find the line #DAEMON_CONF="" and edit it as:                                                                             DAEMON_CONF="/etc/hostapd/hostapd.conf"                
  • Save the file and return          

Configure Network Address Translation:

This will allow multiple clients to connect to the WIFI network. Follow below steps;

  • Open the file sysctl.conf: 'sudo nano /etc/sysctl.conf'
  • Add the line "net.ipv4.ip_forward=1" at the bottom of the file
  • Save the file and return
This will start IP forwarding on boot up.

  • Now run: sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
  • Run the following commands to create the network translation between the ethernet port eth0 and the wifi port wlan0

    sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
  • Configuration to start the WiFi connection: sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
  • Open the file iptables.ipv4.nat: 'sudo nano /etc/network/interfaces'
  • Add the line at end of file: up iptables-restore < /etc/iptables.ipv4.nat
  • Save the file and return

Update the software to support WiFi hardware. Follow the below steps to setup software;

  • To download:                                                                                                                                          wget   http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip


  • To install:   unzip adafruit_hostapd_14128.zip                                                                                                  sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG                                                                        sudo mv hostapd /usr/sbin
  • Give permission for execution: sudo chmod 755 /usr/sbin/hostapd

Now we are done with setting up our own WiFi on Raspberry Pi. This can be hosted using following command:    'sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf'
It displays the name of our WiFi on other devices. To connect to our router users should provide the password.

Network Name: Krishna_PI
Password: Krishna


Krishna_PI appears on the display (List of available wifi networks)




Connecting to Krishna_PI successfully
(Note: Sometimes video attached is not working properly in blogspot. In such case please visit youtube link: https://www.youtube.com/watch?v=RoahdQBKG0c)


References:

  • https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview

Sunday, February 7, 2016

Tutorial: Arduino Programming

Contents:

  • Setting up Arduino Environment
  • Flashing LED Circuit
  • Test1 - External LED
  • Test2 - Internal LED
  • Temperature/Humidity Sensor Circuit
  • ARRAYS - Test with more LEDs
  • BUTTON Test
  • Difference setting up and programming interface using two different source
  •  References

Setting up Arduino Environment:


To interact with Arduino board from our system we need to setup required software installed in the system. Follow below steps to install Arduino IDE,

  • Download and install arduino IDE from the link: https://www.arduino.cc/en/Main/Software
  • After installation, add the ESP8266 package by following these steps:
  • In the Arduino IDE, open the Preferences window.
  • Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json in the Addiotional Board Manager URLs text field.
  • Open Board Manager from Tools and install esp8266 platform.
  • Setup ESP8266 support: Select Tools --> Board --> NodeMCU 1.0(ESP-12E Module)
  • CPU Frequency: Select Tools --> CPU Frequency --> 80 MHz
  • Upload Speed: Select Tools --> Upload Speed --> 115200
  • Finally selecting a port: Select one of the ports available in the list: Tools --> Port

Following diagram represents the ESP8266MOD and its configuration information, it helps to make connections easier (pins, GPIOs etc.)


1. Flashing LED Circuit:

Arduino ESP8266MOD provides easy environment to do experiments with minimum number of connections.

Test1 - External LED:

The following code works for GPIO#7 (pin#13 or D7),

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(750);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(750);              // wait for a second
}

Output: Now, you can see that the external LED blinks, with delay as 750 milliseconds.


Test2 - Internal LED:

The following code works for pin#16,

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(16, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(16, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);              // wait for a second
  digitalWrite(16, LOW);    // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
}

Output: Now, you can see that the internal LED blinks, with delay as 500 milliseconds.


2. Temperature/Humidity Sensor Circuit:


The DHT sensor is much easier to connect:
  • Plug the pin number 1 to the Arduino’s 3.3V pin
  • Pin number 4 to GND
  • Pin number 2 to Arduino pin 13(D7 or GPIO#7)
  • Finally, put the 10K resistor between the sensor pins number 1 and 2


Code:

// Include required libraries
                       #include <SPI.h>
                       #include <string.h>
                       #include "DHT.h"

                       // DHT11 sensor pins
                       #define DHTPIN 13
                       #define DHTTYPE DHT11

                       // DHT instance
                       DHT dht(DHTPIN, DHTTYPE);
                                     
                        void setup(void)
                       {

                        // Initialize DHT sensor
                        dht.begin();

                        Serial.begin(115200);

                        }

                        void loop(void)
                        {

                        // Measure the humidity & temperature
                        float h = dht.readHumidity();
                        float t = dht.readTemperature();

                        // Transform to String
                        String temp = String((int) t);
                        String hum = String((int) h);

                        Serial.print("Temperature: ");
                        Serial.println(temp);
                        Serial.print("Humidity: ");
                        Serial.println(hum);
                        Serial.println("");
                        delay(1000);
                        }

The following code interacts with Arduino board and read the responses of DHT11 and displays the output. To see the result, Select Tools --> Serial Monitor



Final report is shown below,



ARRAYS - Test with more LEDs:

A serial of LEDs connected, and tested for blink one after another


Following code enables the serial(array) of LEDs to turn on:

int timer = 200;           // The higher the number, the slower the timing.
int ledPins[] = {
  5, 4, 2, 14, 12, 15
};       // an array of pin numbers to which LEDs are attached
int pinCount = 6;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    pinMode(ledPins[thisPin], OUTPUT);
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);
  }
}


BUTTON Test:

A button connected to ESP8266MOD as follows,

  • One pin of button is connected to the GND(ground)
  • Another end of button is connected to the one end of 220 Ohms resistor
  • Other end of resistor is connected to 3.3V pin
  • Finally, LED is connected as anode to GPIO pin annd cathode to GND




Code:

// set pin numbers:
const int buttonPin = 14;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
}

Difference setting up and programming interface using two different source ( laptop and pi ):

I wanted to try to get Raspberry talking to an Arduino over USB using Python.

There is a Python library for serial communications called 'pySerial' which has history with Arduino. You can find more information here: http://playground.arduino.cc/Interfacing/Python


  • First, install Arduino: $ sudo apt-get install arduino
  • Next, install the nanpy source:  This is needed to later build the new Arduino firmware:
1 $ cd ~
2 $ curl -O https://pypi.python.org/packages/source/n/nanpy/nanpy-v0.8.tar.gz
3 $ tar xvf nanpy-v0.8.tar.gz
4 $ rm nanpy-v0.8.tar.gz
  • Now install the required Python libs:
1 $ sudo pip install nanpy
2 $ sudo pip install pyserial
  • Hook up your Arduino to one of the Pi’s USB ports, and create/upload the new firmware (using an Arduino Uno as an example):
1 $ cd ~/nanpy/firmware
2 $ export BOARD=uno
3 $ make
4 $ make upload
NOTE: When I am trying to run make upload, the command throws an error. Later I understand that the downloaded arduino IDE is of 1.0.x version instead 1.6.x version. In this old version of arduino IDE, there is no setup for ESP8266MOD. When I am trying to install ESP8266 plugin there is no option to go to Board Manager in Tools. Hence I could not able to do test on raspeberry pi - arduino integration through with old version. I will try to install newer version and make necessary installation and setup, as well as the basic tests of raspberry pi - arduino integration(data exchange).

References:
  • http://www.akeric.com/blog/?p=2420
  • http://www.doctormonk.com/2012/04/raspberry-pi-and-arduino.html
  • http://playground.arduino.cc/Interfacing/Python
  • http://www.instructables.com/id/The-Raspberry-Pi-Arduino-Connection/
  • http://blog.oscarliang.net/connect-raspberry-pi-and-arduino-usb-cable/
  • http://www.seeedstudio.com/recipe/166-basic-pi-lt-gt-arduino-communication-over-usb.html
  • http://playground.arduino.cc/Linux/Ubuntu
  • http://blogspot.tenettech.com/?p=2723
  • http://razzpisampler.oreilly.com/ch10.html
  • http://spellfoundry.com/sleepy-pi/setting-arduino-ide-raspbian/


Monday, February 1, 2016

Programming Arduino





  • Fill in the parts below and provide any references to outside resources that you pulled in:

    • Which laptop OS are you testing to program from:
              Lenovo Ideapad - Windows8 64-bit.
           
              References:
    • https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon
    • https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/overview 
    • What is the PI you are using and which OS is it setup with?
              Arduino Software (IDE) - v1.6.7 and it is setup with Windows Operating System.

              References:
    • https://www.arduino.cc/en/Main/Software
    • What is the hardware that is needed?
    • ESP8266MOD 
    • MicroUSB charger
    • LED
    • DHT11 Sensor
    • 10K Ohms Resistor
    • Jumper wires 
               References:
    • https://learn.adafruit.com/wifi-weather-station-arduino-cc3000/connecting-the-cc3000-breakout-board 
    •  https://learn.adafruit.com/home-automation-in-the-cloud-with-the-esp8266-and-adafruit-io/hardware-and-software-requirements
    • What is the software that is needed?
    • Arduino Software (sketch)
    • Libraries and dependencies
    • Programming to interact with hardware (device)
               References:
    • http://playground.arduino.cc/Main/DHT11Lib
    • https://github.com/adafruit/DHT-sensor-library 
    • How do you wire it together?
              References:
    • https://learn.adafruit.com/adafruit-cc3000-wifi-and-xively/connections
    • http://www.hobbyist.co.nz/?q=documentations/wiring-up-dht11-temp-humidity-sensor-to-your-arduino 
    • What is the logical first test?

    • a. LED
                            Test1:
                         
                         

                            Code:

                           void setup() {
                                 pinMode(13, OUTPUT);
                           }

                           void loop() {
                                digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
                                delay(1000);              // wait for a second
                                digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
                                delay(1000);              // wait for a second
                           }

                           Test2:


                            
                           Code:

                           void setup() {
                                 pinMode(16, OUTPUT);
                           }

                           void loop() {
                                digitalWrite(16, HIGH);   // turn the LED on (HIGH is the voltage level)
                                delay(1000);              // wait for a second
                                digitalWrite(16, LOW);    // turn the LED off by making the voltage LOW
                                delay(1000);              // wait for a second
                           }
    • b. humidity, temperature sensor

                          Code:

                           // Include required libraries
                           #include <SPI.h>
                           #include <string.h>
                           #include "DHT.h"

                           // DHT11 sensor pins
                           #define DHTPIN 13
                           #define DHTTYPE DHT11

                           // DHT instance
                           DHT dht(DHTPIN, DHTTYPE);
                                           
                            void setup(void)
                           {

                            // Initialize DHT sensor
                            dht.begin();

                            Serial.begin(115200);

                            }

                            void loop(void)
                            {

                            // Measure the humidity & temperature
                            float h = dht.readHumidity();
                            float t = dht.readTemperature();
     
                            // Transform to String
                            String temp = String((int) t);
                            String hum = String((int) h);
     
                            Serial.print("Temperature: ");
                            Serial.println(temp);
                            Serial.print("Humidity: ");
                            Serial.println(hum);
                            Serial.println("");
                            delay(1000);
                            }

                             Results:


                   References:
    • https://www.arduino.cc/en/Tutorial/Blink
    • http://playground.arduino.cc/Main/DHT11Lib 
    • https://learn.adafruit.com/downloads/pdf/dht.pdf
    • https://learn.adafruit.com/cloud-connected-weather-station-with-the-arduino-yun-and-temboo/connections 

    • --- What were the problems that you had to solve?
    •  Basic tests completed without any problems.
    • Arduino programming is easy to understand and implement. 
    • Built-in libraries are very helpful with examples. 
    • --- How far did you get.
    • Completed two basic tests on LED
    •  One basic test of DHT11 temperature and humidity sensor.