Saturday, April 4, 2015

Create dashboards for dweet.io things with freeboard.io

With freeboard.io, you can create simple dashboards for your devices, include dweet.io things. In previous post, I have create my thing of RPi 2 core temp at dweet.io.


This video show how to create a simple dashboard on freeboard.io link to my thing on dweet.io.



My dashboard on freeboard.io: https://freeboard.io/board/2u9N6O

Updated version of dweetIoTemp.py, to send data to dweet.io.
#$ sudo pip install requests
import requests
import os
import matplotlib.pyplot as plt
from drawnow import *

# This example send the core temperature of Raspberry Pi
# to http://dweet.io/, a IoT on Cloud.
# with name = helloRaspberryPi_RPi2_vcgencmd
#
# To check this dweet, visit here on browser
# http://dweet.io/follow/helloRaspberryPi_RPi2_vcgencmd
#
dweetIO = "https://dweet.io/dweet/for/"
myName = "helloRaspberryPi_RPi2_vcgencmd"
myKey = "RaspberryPi2_core_temp"
myLink = "link=http://helloraspberrypi.blogspot.com/"

tempC = []

plt.ion()
cnt=0

def plotTempC():
    plt.ylim(20,80)
    plt.title('Raspberry Pi core temperture')
    plt.grid(True)
    plt.ylabel('Temp C')
    plt.plot(tempC, 'rx-', label='Degrees C')
    plt.legend(loc='upper right')

#pre-load dummy data
for i in range(0,26):
    tempC.append(0)
    
while True:

    ostemp = os.popen('vcgencmd measure_temp').readline()
    temp = (ostemp.replace("temp=", "").replace("'C\n", ""))
    print(temp)
    tempC.append(temp)
    tempC.pop(0)
    drawnow(plotTempC)

    #Send to Cloud, dweet.io
    rqsString = dweetIO+myName+'?'+myKey+'='+str(temp)+'&'+myLink
    print(rqsString)
    rqs = requests.get(rqsString)
    print rqs.status_code
    print rqs.headers
    print rqs.content
    
    plt.pause(.5)



Related example on Arduino:
Arduino Uno + Ethernet Shield send data to dweet.io and freeboard.io

No comments: