User Tools

Site Tools


introduction_to_the_internet_of_things

This is an old revision of the document!


Software Setup You should do the following things before the class:

Install Arduino IDE if you don't already have it, and upgrade to something recent if you're below version 1.7 - http://arduino.cc

  • In Boards Manager, add ESP8266 Board support

Set up a Cayenne account - https://cayenne.mydevices.com

Install the following libraries:

Modify BME280 library

  • on OS X, navigate using the finder or otherwise cd ~/Documents/Arduino/libraries/Adafruit_BME280_Library-master/
    • On Windows & Linux the files will be somewhere similar.
  • edit Adafruit_BME280.h using your favorite editor- change #define BME280_ADDRESS from 0x77 to 0x76
  • more advanced C programmers may do something like:
#define BME280_ADDRESS 0x77
#ifdef CLASS_BME280 
#define BME280_ADDRESS 0x76
#endif

and then add #define CLASS_BME280 at the beginning of your program, so that way if you get an Adafruit BME280 board in the future, it will continue to work right…

Hardware Construction
  • On the programming board, wire an SPST or SPDT switch between GPIO and GND
  • If you plan on re-using the boards for something else in the future, solder in header pins on the other boards. If you're building this as a

If you want to re-use the component boards for other projects

Software Programming
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <CayenneMQTTESP8266.h>
#include <SimpleTimer.h>

// Your network name and password.
char ssid[] = "your_mobile_phone_tether_ssid";  //  your network SSID (name)  
char pass[] = "your_mobile_phone_password";       // your network password  
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "xxxxxxxxxxxxxxxxxxxxxxx5c2";  
char mqtt_password[] = "xxxxxxxxxxxxxxxxxxxxxxxxx190";  
char client_id[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

// Virtual Pins of the BME280 widget.
#define TEMPERATURE_PIN V0
#define BAROMETER_PIN V1
#define HUMIDITY_PIN V2
#define  ALTITUDE_PIN V3

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C  
unsigned long delayTime;

void setup()  
{
  Serial.begin(9600);
  Cayenne.begin(username, mqtt_password, client_id, ssid, pass);
  Wire.begin(0, 2); // SDA, SDL
  bme.begin();

}

void loop()  
{
  Cayenne.loop();
}

// These functions are called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(V0)  
{
  // Send the Temperature value to Cayenne
  Cayenne.virtualWrite(V0, bme.readTemperature());
}

CAYENNE_OUT(V1)  
{
  // Send the Pressure value to Cayenne
  Cayenne.virtualWrite(V1, bme.readPressure());
}

CAYENNE_OUT(V2)  
{
  // Send the Humidity value to Cayenne
  Cayenne.virtualWrite(V2, bme.readHumidity());
}

CAYENNE_OUT(V3)  
{
  // Send the Altitude value to Cayenne
  Cayenne.virtualWrite(V3, bme.readAltitude(SEALEVELPRESSURE_HPA));
}

Power considerations The kit does not come with a power source. The regulator board requires at least 4.5V (and at most 15V!) to adequately supply 3.3V to the ESP8266 and BME280 boards. A 9V battery or 6V AA case should work

introduction_to_the_internet_of_things.1531265691.txt.gz · Last modified: 2018/07/10 19:34 by sdh7