Cloud-enabling with Exosite: Local Temperature with chipKIT Digilent uC32, Digilent Basic I/O and Raspberry Pi

Introduction

Exosite is a technology company focused on connecting devices and systems. They have been developing embedded technologies for over 20 years – and have first-hand experience dealing with the lack of connectivity between devices, networks and users. Their cloud-based data platform makes it easy to put real-world information online.

The exponential growth in electronic data implores a ubiquitous connection tool. Exosite’s platform is that tool. Their software provides a central vantage point, enabling the next generation of connected products and supplying insight into operations.

According to Gartner, there will be nearly 26 billion devices worldwide on the Internet of Things by 2020. The Gartner report can be purchased for US$199,00.

Exosite offers a zero cost free developer account. It has everything one needs to start interacting with one’s devices real-time over the Internet. One gets a web dashboard account, full access to the API, a cloud scripting environment, and the ability to upgrade features a-la-carte.

Objectives

  • Capture the local temperature read by Microchip TCN75A temperature sensor on Digilent Basic I/O shield connected to chipKIT Digilent uC32 board
  • Send the values read by chipKIT Digilent uC32 to Exosite platform through Raspberry Pi.

Pre-Requirements

Setup

  • chipKIT Digilent uC32 with Digilent Basic I/O shield on top, and power supply

tempmon1

  • Raspberry Pi Model B and power supply (and I recommend a powered USB hub)

tempmon2

  • USB A to mini-B cable

tempmon3
Procedure

a) Having run the sketch as shown in previous tutorial (it is a pre-requirement to have done) you will see on Basic I/0 shield’s OLED:tempmon9Note that rightmost switch is toggled to up position. Only in this position the Alert for temperature above 24ºC will work.

Now we are ready for Raspberry Pi!

b) Registering at Exosite and configuration of dashboard 

i – Visit the Exosite at http://portals.exosite.com. Here you can register if you are not already registered:

remote3ii – Once in your working area you can manage your portal. You need to add Devices (choose the link shown in red rectangle):

remote4iii – Add device clicking at + Add Device link on top right side:remote5

iv – In next screen choose the default option “I want to create a generic device”remote6

Click CONTINUE button.

v – In next step choose your time zone and add your geolocation: remote7Click CONTINUE button.

vi –  Fill in the name of your New Device. I have called it “TCN75A on BIO”                                remote8Click SUBMIT button. If you forget to give a name you will be greeted with the following warning on top of this configuration window:

remote10vii -A final window will open with your configuration. The following image shows my Device:

remote12Your Device will be now available.Click the link on top right that says to add Data remote11We are interested in this tutorial in reading degrees Centigrade and whether Alarm condition is met. In our firmware code for chipKIT Digilent uC32 when 24ºC is read and above Alarm is ON. Below temperature is OK. At the moment where I am temperature even in my Office is higher than 24ºC so the OLED display on BASIC I/O shield says ALARM! and this is transmitted serially.  So two Data values will be sent to portal TEMP1 and condition, the former has the temperature and second is string Alarm or OK.

viii – Let us configure our two Data entries. We will start with condition:

remote13We give the name condition and we say that the Exosite must expect a string. If the reviewed information is correct click on SUBMIT button. Up to 100 data entries can be configured for the Device. You will be greeted next with a window that says that your configuration has been successful.

ix – Now Add Data again clicking remote11And fill in as shown, naming TEMP1 and stating that Exosite must expect a float type data and unit as ºC:

remote14Click SUBMIT button and you will again see the window that Data has been added successfully.

x – Now we configure our Device and obtain valuable information from it for our code that we will write after.

Click on your Device to configure it (the name I gave is “TCN75A on BIO”. BIO means “Basic I/O”, the shield that contains the temperature sensor Microchip TN75A):

remote9A configuration window will open:

remote15CIK number will be need. I have blackened my CIK number. Copy it and past somewhere else. Note that our Data entries are already in our Device configuration TEMP1 and condition. You can close clicking CLOSE button or UPDATE (if you make any changes to your Device) and CLOSE buttons.

Exosite Porta’s dashboard is read. We will now proceed to Raspberry Pi.

c) Reading values with Raspberry Pi and sending to Exosite

On LXTerminal of Raspberry Pi desktop write

ls /dev/tty*

And the response now will be something similar to:

remote1Connect USB cable between Digilent USB cable and Raspberry Pi and do write again on the Terminal:

ls /dev/tty*

And the last part of the response will be as shown:

remote2ttyUSB0 is our connection on Raspnerry Pi. We are now ready to write Python program

In /home/pi write the following code with:

nano /home/pi/tempmon1.py

Write the following code:

#!/usr/bin/python
#tempmon1.py

#Exosite Cloud-enabled TCN75A sensor

#Imports
import time
import serial
from decimal import *
import urllib
import httplib

#Exosite portal configuration
cik = 'YOUR CIK HERE'
server = 'm2.exosite.com'

# Serial port parameters
serial_speed = 9600
# Your serial port the example uses ttyUSB0
serial_port = '/dev/ttyUSB0'

ser = serial.Serial(serial_port, serial_speed, timeout=1)

while True:            
     # Request data and read the answer      
     data = ser.readline() # read data from serial      
     if (data != ""):      
            # If the answer is not empty, process & display data         
            processed_data = data.split(',')        
            Data1r = str(processed_data[0])
            Data1 = '%.1f' % Decimal(Data1r)
            print Data1
            Data2 = str(processed_data[2])
            print Data2
            
        print '========================================================================'
        print 'Exosite API Using CIK ', cik
        print '========================================================================'
        print '\r\n'
        
        url = '/api:v1/stack/alias'
        params = urllib.urlencode({'TEMP1': Data1, 'condition': Data2 })
        headers = {'X-Exosite-CIK': cik, 'content-type': 'application/x-www-form-urlencoded; charset=utf-8'}
        print '=================='
        print 'POST'
        print '=================='
        print 'URL: ', url
        print 'Data: ', params
        print ' '
        conn = httplib.HTTPConnection(server)
        conn.set_debuglevel(1)
        conn.request("POST",url,params,headers)
        response = conn.getresponse();
        print 'response: ',response.status,response.reason
        data = response.read()
        end = data.find('<')
        if -1 == end: end = len(data)
        
        print '\r\n\r\n'
        url = '/api:v1/stack/alias?TEMP1&condition'
        headers = {'Accept':'application/x-www-form-urlencoded; charset=utf-8','X-Exosite-CIK':cik}
        print '=================='
        print 'GET'
        print '=================='
        print 'URL: ', url
        print ' '        
        conn = httplib.HTTPConnection(server)
        conn.request("GET",url,"",headers)
        response = conn.getresponse();
        print 'response: ',response.status,response.reason
        data = response.read()
        conn.close()
        print 'response data:', data
                 
time.sleep(30)

Save the code as tempmon1.py. Now we are ready to run the code. In LXTerminal write:

python /home/pi/tempmon1.py

You will see on LXTerminal something similar to following:

remote16I have whitened my CIK value.

At the beginning we see that TEMP1 and condition are both read. Next the values read are sent to Exosite.  The response “204 No Content” which is alright as it is what is expected. Next we get a response from the server that has been delivered with “200 OK”.

If this does not happen with you something you did is wrong. You need to follow this tutorial thoroughly and follow all the steps.

These values are properly registered at Exosite. Click at portal side in your dashboard Data button.remote18You will see something like the following image:

remote189If you click on TEMP you will see the graph being generated and the values that have been read:

remote17

A graph will be generated, something like following image:

remote19You can next play with your Exosite’s portal page. My dashboard’s Home looks like the following two images show:

remote20

remote21We are at the end of this tutorial.

What you can do Next?

You can add a Bluetooth dongle to your Raspberry Pi and a Serial SPP module to the chipKIT Digilent uC32 board. You can use Bluetooth to send the values read on Microchip TCN75A temperature sensor on Digilent Basic I/O shield to Raspberry Pi. So you can achieve a truly wireless connection doing away with USB cable.

Conclusions

More and more applications are now Cloud-enabled. Exosite has lots more of potential that we have not exploited. Connecting up Raspberry Pi with chipKIT Digilent uC32 with Basic I/O shield open up a whole new range of  interesting electronic projects. It is quite easy to Cloud-enable your project and Exosite offers you the possibility of doing for free to test your ideas and gradually grow.

 

 

Advertisements

About Tayeb

Electronics engineer, part-time webmaster and owner of "Aliatron", a tech-oriented company registered in Portugal and Mozambique.
This entry was posted in Internet of Things and tagged , , , , , , , , , , . Bookmark the permalink.

One Response to Cloud-enabling with Exosite: Local Temperature with chipKIT Digilent uC32, Digilent Basic I/O and Raspberry Pi

  1. Pingback: Send Local Temp from chipKIT and Raspberry Pi to Exosite Cloud » chipKIT Development Platform

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s