How to Connect Arduino Industrial 101 to Cayenne

How to Connect Arduino Industrial 101 to Cayenne © GPL3+

How to connect Arduino Industrial 101 to Cayenne over MQTT, and send data from BMP180 and TSL2561.

  • 4,120 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

1. Connecting the Arduino Industrial 101 to Cayenne:
  • Creating a Cayenne account
  • Add new: Device/Widget
  • Bring Your Own Thing
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['bc1af12ce3'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381284/1_akQDChsb7H.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

2. Setting Arduino Industrial 101:
  • Enter the Arduino IP address into your browser and login
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['8635cbbb96'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381285/4_DUpX4JdvT5.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['512823c2a0'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381286/5_nuclY5qZOB.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['ade3a784ec'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381287/6_hughor3iIK.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
  • Enter the host, port, MQTT username, password, and ClientID from Cayenne
  • Save the changes

3. Upload the code:
  • Open Arduino IDE
  • Copy the code
  • Insert MQTT username and ClientID to code
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['2769b81038'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381292/code_M8ZJuD1x4w.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
  • Select the board, port
  • Upload the code

4. Done
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['2aa969f260'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381289/2_OLR7q3oy92.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];
  • Click + to add a widget
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['8a39d52415'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/381290/3_ei1e6NIl50.png?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

Done, everything works!

Code

CodeArduino
#include <Ciao.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>
#include <Adafruit_TSL2561_U.h>

Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10180);
const int address = TSL2561_ADDR_FLOAT;
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(address, 12345);

void setup()
{
  Ciao.begin();  
  Wire.begin();
  bmp.begin();
  tsl.begin();
  
  tsl.enableAutoRange(true);
  /* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);  /* medium resolution and speed   */
  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */                       
}

void loop()                     
{
  sensors_event_t event;
  tsl.getEvent(&event);
  float pressure;
  bmp.getPressure(&pressure);
  float temperature;
  bmp.getTemperature(&temperature);

  Ciao.write("mqtt","v1/MQTTusername/things/ClientID/data/5", String(temperature));  //Replace MQTTusername and ClientID from Cayenne
  Ciao.write("mqtt","v1/MQTTusername/things/ClientID/data/6", String(pressure));
  Ciao.write("mqtt","v1/MQTTusername/things/ClientID/data/7", String(event.light));

  delay(2000);
}

Schematics

Schematic
2017 11 18 13 14 05 zsvv6lzsoi

Comments

Similar projects you might like

Sigfox to Cayenne

Project showcase by Tadeas Dvoracek

  • 2,807 views
  • 0 comments
  • 6 respects

MKR1000 Christmas IoTree with Cayenne Project Builder

Project tutorial by Benny Estes

  • 5,034 views
  • 3 comments
  • 9 respects

Christmas Tree Water Level via Cayenne and MKR1000

Project showcase by Ian Zahn

  • 4,156 views
  • 0 comments
  • 7 respects

Cayenne and SparkFun IoT 433 Mhz Sockets

Project tutorial by Giovanni Gentile

  • 3,452 views
  • 0 comments
  • 13 respects

Arduino 101 Home BLE System

Project tutorial by Alexis Santiago Allende

  • 5,446 views
  • 2 comments
  • 17 respects

Arduino + Cayenne = Light Quality Monitoring

Project in progress by Giovanni Gentile

  • 4,643 views
  • 0 comments
  • 11 respects
Add projectSign up / Login