My First IOT (Internet Of Things) project

Even though IOT has been around for a while, it’s still mystery to a large group of people. How do you make devices talk and derive intelligence and actionable and useful data out of it.

I have been working with one of the IOT project Nube for past 6 months which gives you full control and comfort, so you never run out of gas. You can manage and monitor your consumption, create alerts and place orders in one click! I helped architected the cloud application which consumes lot of data reported by sensors on gas tanks and provide relevant information for gas companies and end consumers. It’s a complete end to end IOT solution targeting 10 million tanks to start with.

More I worked with Nube IOT solution, it became clear to me to on how to design and architect end to end solution but I thing that wasn’t clear to me was on how these actual sensors work and what kind of programming and skills are needed to develop IOT hardware and firmwares.

Out of the curiosity I got access to Raspberry Pi 2 and I decided to build a simple POC which reports temperature and humidity and sends data to the cloud.

Here I am describing the process to build IOT solution which reports temperature and humidity.


  1. Raspberry PI — Small single board computer
  2. DHT11 temperature & humidity sensor
  3. Jumper Wires and Breadboard (3 Male to Female)
  4. External Mouse and Keyboard ( I used wireless keyboard and mouse)
  5. Internet — You can use LAN connection or WiFi. My Raspberry Pi 2 didn’t had WiFi and I didn’t liked the idea to adding more LAN wires. I ordered Wireless Nano USB Adapter, but this is completely optional.
  6. ThingSpeak — A server side platform for collecting IoT device data.
  7. A Python Program — It will run on Raspberry PI

Understanding Raspberry PI GPIO Pins

GPIO (General purpose input/output) pings along the edge of the board.

GPIO Pins on Raspberry PI 2

These pins are physical interface between the Pi and the outside world.

Diagram 1

Read more about these pins from here.

Connecting Sensor DHT11 to Raspberry PI

The DHT11 is a basic, ultra low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed).

DHT11 can have three or four pins. If it is a 4 pin version, then a pin is unused[NC]. PIN 1 is VCC, PIN 2 is data, if you have 4 PIN version then PIN3 is unused[NC], PIN4 is ground. [ In case of 3 PIN version PIN 3 is ground]

Diagram 2 — Connection Diagram

Note — I used 10K 0hm resistor as shown in the Diagram 2 — Connection diagram above but it didn’t worked for me and once I removed the resistor my sensor started reporting data. Some tutorials will include instructions for using resistor but it didn’t worked for me.

Step 1 — Insert DHT11 in the breadboard

DHT11 Sensor

1. VCC connected to +3.3V~5V
2. DATA connected to the microcontroller IO port
3. GND connected to ground

Step 2 — Now make below connections using Jumper Wire

  1. Connect 3.3v P1 pin from Raspberry Pi to VCC (V) of DHT11 using Jumper wire.
  2. Connect Pi ground P6(Black dot from Diagram 1 above) to PIN 3 which is GND pin in DHT11 (Or PIN4 if that exists)
  3. Connect Pi GPIO2 P3 to DHT11 Data pin

Server Side Setup

Now lets setup server side to receive the data. We will use ThingSpeak as it provides server side infrastructure to collect the data and process it but you can use any other service as well.

  1. Create a free account on ThingSpeak.
  2. Create a channel as shown below with 3 fields for Temp-C (in celsius), Temp-F (in Fahrenheit), Humidity
ThingSpeak Channel Configuration

3. Once you save the Channel, go to API Key section of channel & note the Write API key. This key will be needed to send data to ThingSpeak channel from device.

Making Raspberry Pi ready to read data from sensor

  1. If Install updates
sudo apt-get update

2. Install Python if not already there. You can check the python version by running command

python -V

3. If Python doesn’t exists. Install it using

sudo apt-get install python-dev

4. Install Rpi.GPIO (Library used to interact with GPIO pins)

sudo apt-get install python-rpi.gpio

5. Install library for ADH11 sensor — Download library

git clone
cd Adafruit_Python_DHT

6. Install library

sudo apt-get update

sudo apt-get install build-essential python-dev python-openssl
sudo python install

You can download the code by using following command

git clone


Update your API key here in the code

# Define GPIO pin to which DHT11 is connected
DHTpin = 2
#Setup our API and delay
myAPI = "GET_YOUR_KEY" # API Key from
myDelay = 60 #number of seconds between posting data

Run Application

sudo python

Once you run the python script, you should start seeing the data on ThingSpeak as shown in the below image.

Public Channel — Can be accessed from