You’ve heard about this Internet of Things (IoT) trend and wanted an excuse to try a project. Well, me too. Actually, I have a goal to create a series of low cost climate/environment modules that capture various types of data like temperature, humidity and more. I want to take all this data and put it in the cloud where I can eventually build out dashboards, alerts and more.

Any good programmer knows to make it work before you make it scale. That’s where this post comes in. It's a simple IoT project using three things:

Connect the Sensor to the Arduino

The diagram below shows how the LM35 Temperature Sensor is connected to the Arduino Uno board. I used a breadboard to connect all this together. But I simplifyed the diagram so that you know what is connected to which pin. The LM35 has 3 pins.

  • The first pin goes to the 5V power pin on Arduino.
  • The third pin is the GND.
  • The middle pin is the VOUT which emits the values that we need to capture. We connect this to the Analog Pin (A0) on the Arduino Uno.

Connecting The Arduino

Now we can write our Arduino code to read that value.

Retrieve the Readings from the Arduino Uno

Arduino requires a computer to interface via a serial port. A larger project would use something like a Raspberry Pi. I discuss this a bit more in a similar post on my personal blog.

Again, we’re keeping this example simple. The Arduino code is straightforward as given below:

float temp;
int tempPin = 0;

void setup()

void loop()
 temp = analogRead(tempPin);
 temp = temp * 0.48828125;

You will notice in the loop that every 10 seconds we are printing out the temperature value read from the Analog Pin (#0).

If you run the Serial Port Monitor that comes with the Arduino IDE, and if the Arduino is powered up and connected as per the diagram shown, the Temperature value is printed on the Serial Monitor.

Monitoring Arduino Data

Once the data appears we know that the Arduino setup is correct. All we need to do now is write a client program on the PC that interfaces with the Arduino, reads the values via the Serial port, and then pushes them to the cloud database service.

Store the Readings in Orchestrate

Before using Orchestrate, you’ll need to create a free account. Be sure to note your application’s API Key. Then, I created an application containing one collection: Temperature_Data.

I decided to use Python to interface with the Arduino connected to my computer’s serial port. Here’s the plan:

  1. Initialize the Orchestrate API Client using our API Key.
  2. Initialize the serial port communication via which we read the Temperature values that the Arduino unit emits. You need to know which Serial Port on your machine is interfaced to the Arduino.
  3. Every 10 seconds the code will read the value from the Serial Port. Obviously we can build more validations in the code, but this is good for now to demonstrate how all the pieces come together.
  4. Use the Orchestrate Python client library to post data into my application’s collection.

Here’s the code needed to accomplish the above:

import serial
import time
from porc import Client

API_KEY = "Your API Key"
# create an Orchestrate client
client = Client(API_KEY)

# make sure our API key works

#Connect to Serial Port for communication
ser = serial.Serial('COM15', 9600, timeout=0)

#Setup a loop to send Temperature values at fixed intervals
#in seconds
fixed_interval = 10
while 1:
  #temperature value obtained from Arduino + LM35 Temp Sensor
  temperature_c = ser.readline()
  #current time and date
  time_hhmmss = time.strftime("%H:%M:%S")
  date_mmddyyyy = time.strftime("%d/%m/%Y")

  #current location name
  temperature_location = "Mumbai-Kandivali"
  print temperature_c + ',' + time_hhmmss + ',' + date_mmddyyyy + ',' + temperature_location

  #insert record
  response ='Temperature_Data',
                          "date" : date_mmddyyyy,
                          "time" : time_hhmmss,
                          "value" : temperature_c})
  print "Record inserted. Key = " + response.key
except ser.SerialTimeoutException:
  print('Error! Could not read the Temperature Value from unit')

The important thing to note in the POST to the Orchestrate service is the code. Here, all we're doing is specifying the collection (Temperature_Data) that we had created for our Application in Orchestrate and the Data. The Data is specified in JSON format. The fields that I'm specifying are temperature in centigrade, date, time, and location (weather station name).

Check Your Data

The final step is to validate if our data is being transmitted successfully and stored in Orchestrate. The Python code returns a confirmation message each time it checks the temperature, but to be extra sure we can go to the Orchestrate dashboard.

Dashboard Temperature Log

Visit your collection page and select the search tab. Then, you can enter a search query (or use * to find everything in the collection) to check on your data. This validates the end-to-end working of the project.

Arduino makes electronics prototyping fun. With languages like Python and services like Orchestrate, the process of collecting, transmitting, and saving the data in the cloud is made simple, too.

Have fun building great things with Orchestrate. By the way, we're live now in the CenturyLink Cloud. Sign up today for Orchestrate at