Tadeas Dvoracek
Published © GPL3+

How to Connect Arduino Industrial 101 to Cayenne

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

EasyProtip30 minutes2,827
How to Connect Arduino Industrial 101 to Cayenne

Things used in this project

Hardware components

Arduino Industrial 101
Arduino Industrial 101
×1
BMP180
×1
TSL2561
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Cayenne
myDevices Cayenne

Story

Read more

Schematics

Schematic

2017 11 18 13 14 05 zsvv6lzsoi

Code

Code

Arduino
#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);
}

Credits

Tadeas Dvoracek

Tadeas Dvoracek

5 projects • 19 followers

Comments