element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog Upcycled Clock – posting sensor data to Cayenne
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 26 May 2017 7:55 AM Date Created
  • Views 1615 views
  • Likes 4 likes
  • Comments 5 comments
  • upcycledclock
  • cayenne
  • mqtt
  • upcycleit
  • iot
  • iot dashboard
Related
Recommended

Upcycled Clock – posting sensor data to Cayenne

carmelito
carmelito
26 May 2017

When I attended Makerfaire Bay Area last week , I heard a talk by the folks at myDevices, who build an IoT platform called– Cayenne,  which has an online IoT dashboard that takes most of the complication out of creating hardware-oriented programming, originally it worked with just the Raspberry Pi, and is now available for the Arduino as well. In addition, you also have a feature were you can use MQTT to post sensor data to Cayenne IoT dashboard, this means we can use the Intel Edison to post sensor data as shown in the picture below. For more info about Cayenne check out the documentation at https://mydevices.com/cayenne/docs/

image

 

Initially as part of design challenge proposal, I had planned to use Intel’s cloud analytics, but I soon found out that the application was sunset’ed, and I had planned to use to use either use AWS IoT or IBM Watson IoT. But after hearing about Cayenne, and spending some time at the Cayenne booth at the Makerfaire, and getting to look at their dashboard, I plan to change directions slightly and use Cayenne.

 

 

As part of the Circuit I have the Intel Edison connected to Temperature, Light and Air Quality sensor data to Cayenne

  • Grove Air Quality sensor (version 1.3) connected to A0 on the grove connector shield
  • Temperature sensor connected to A1
  • Light sensor connected to A2

image

 

To setup your cayenne dashboard create an account at - https://mydevices.com/ , and then add your own device using "Bring Your Own Thing API selection" icon, and make a note of the following

  • MQTT Username
  • MQTT Password
  • Client ID

image

Before we run the python program below, we will have to install the cayenne-mqtt package using pip

pip install cayenne-mqtt

 

image

 

Here is the python code use to upload sensor data to cayenne. And once you run the python program below, after updating the MQTT_USERNAME, MQTT_PASSWORD and MQTT_CLIENT_ID you should see your new sensor appear in the dashboard. You can then create a new project in Cayenne and added the sensor to the project. (* as part of the dashboard picture above you can see there is an on/off button, which i plan to trigger/control a couple of things on the Intel Edison, which is going to be part of a future blog post)

 

#!/usr/bin/env python
# Create by Carmelito to post data to Cayenne Dashboard using MQTT
# Cayenne https://github.com/myDevicesIoT/Cayenne-MQTT-Python
# Grove temperature sensor- https://github.com/intel-iot-devkit/upm/blob/master/examples/python/grovetemp.py
# Grove light sensor - https://github.com/intel-iot-devkit/upm/blob/master/examples/python/grovelight.py
# Grove Air quality sensor v1.3- https://software.intel.com/en-us/iot/hardware/sensors/air-quality-sensor


import cayenne.client
import time
from upm import pyupm_grove as grove
from upm import pyupm_gas as TP401 #for the Air quality sensor


# Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME  = "xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxx"
MQTT_PASSWORD  = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
MQTT_CLIENT_ID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"


client = cayenne.client.CayenneMQTTClient()
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

# Give a qualitative meaning to the value from the Ait quality sensor
def airQuality(value):
    if(value < 50): return "Fresh Air"
    if(value < 200): return "Normal Indoor Air"
    if(value < 400): return "Low Pollution"
    if(value < 600): return "High Pollution - Action Recommended"
    return "Very High Pollution - Take Action Immediately"
# New Grove Air Quality Sensor on AIO pin 0
airSensor = TP401.TP401(0)


# Wait for Ait quality sensor to warm up - it takes about 3 minutes
print("Sensor is warming up for 3 minutes...")
for i in range (1, 4):
    time.sleep(60)
    print(i, "minute(s) passed.")
print("Sensor is ready!")


#temperature sensor object using AIO pin 1 on the Grove connector shield
temp = grove.GroveTemp(1)
#light sensor object using AIO pin 2
light = grove.GroveLight(2)
while True:
    client.loop()
    print(temp.name())
    # Read the temperature ten times, printing both the Celsius and
    # equivalent Fahrenheit temperature, waiting one second between readings
    #for i in range(0, 10):
    celsius = temp.value()
    fahrenheit = celsius * 9.0/5.0 + 32.0;
    print("%d degrees Celsius, or %d degrees Fahrenheit" \
        % (celsius, fahrenheit))
    time.sleep(1)


    # Read values of the light sensor
    lightLux = light.value()
    print(light.name() + " raw value is %d" % light.raw_value() + \
        ", which is roughly %d" % light.value() + " lux");
    time.sleep(1)


    # Read values of Air quality sensor
    airValue = airSensor.getSample()
    ppm = airSensor.getPPM()
    print("raw: %4d" % airValue , " ppm: %5.2f   " % ppm , airQuality(airValue))


    #Uploading data to Cayenne
    print("Uploading data to Cayenne ...")
    client.celsiusWrite(1, celsius)
    client.luxWrite(2, lightLux)
    client.virtualWrite(3, airValue)
    #timestamp = time.time()
    #Sleep for
    time.sleep(5)

 

 

 

Reference:

Setting up Cayenne on the Intel Edison - https://github.com/myDevicesIoT/Cayenne-MQTT-Python

Cayenne docs - https://mydevices.com/cayenne/docs/

Grove Air quality sensor v1.3- https://software.intel.com/en-us/iot/hardware/sensors/air-quality-sensor

  • Sign in to reply

Top Comments

  • jasonwier92
    jasonwier92 over 8 years ago in reply to balearicdynamics +4
    Agree, just give me an open source package that can do the same and I will host it my self. Or what happens when they are down for a day or two, what if they never come back? What if they change to go…
  • Workshopshed
    Workshopshed over 8 years ago +1
    There are plans for Cayenne to introduce some new controls so you can pass status messages to your dashboard as well as numbers. This could be a really useful platform. "Coming Soon" Custom Widgets - FAQ…
  • balearicdynamics
    balearicdynamics over 8 years ago +1
    Good choice, IMHO! I have experimented Cayenne (if I am not wrong I was contacted by them as one of the first beta testers group) when it was almost primitive and just for the PI only. It was not yet usable…
  • carmelito
    carmelito over 8 years ago in reply to balearicdynamics

    Agreed, with both of you. It would be nice to have an open source package that you can host yourself..

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 8 years ago in reply to jasonwier92

    You perfectly completed the design of the scenario. This is the reason I own my AWS Linux machine on Amazon in their Virginia data center. Just for this reason.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to balearicdynamics

    Agree, just give me an open source package that can do the same and I will host it my self. Or what happens when they are down for a day or two, what if they never come back?  What if they change to go the new way and it breaks all your data? I like clear, not cloudy.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 8 years ago

    Good choice, IMHO! I have experimented Cayenne (if I am not wrong I was contacted by them as one of the first beta testers group) when it was almost primitive and just for the PI only. It was not yet usable in practice due the very reduced set of features but was very promising. I see that now they are going ahead in a very good way. I think that the winner choice of Cayenne is to be open to different kind of platforms - no matte what they was already able to support at the date, this is the trend -

    Almost a couple of years ago I was selected to test the LinkItOne board (a more advanced yet expensive Arduino-like device) by Instructables. I developed Hugo version 1 https://www.instructables.com/id/Hugo-or-U-Go-for-LinkIt-ONE/ ) and also Mediatek was appreciable providing an online platform for a decent data exposition making the things easier. The problem in this case was the limitation to their platforms instead of others (they followed a different philosophy)

     

    What I am concerned about Cayenne is what is their business model and what happens to the end user if he buy a product involving Cayenne as the distributed data platform.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago

    There are plans for Cayenne to introduce some new controls so you can pass status messages to your dashboard as well as numbers. This could be a really useful platform.

     

    "Coming Soon" Custom Widgets - FAQ's - myDevices Cayenne Community

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube