introduction_to_the_internet_of_things
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
introduction_to_the_internet_of_things [2018/07/10 23:05] – sdh7 | introduction_to_the_internet_of_things [2018/08/01 04:35] – sdh7 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====THINGS TO DO BEFORE THE CLASS==== | ||
**Software Setup** | **Software Setup** | ||
You should do the following things before the class: | You should do the following things before the class: | ||
+ | |||
+ | If you are using a Macintosh, install these drivers for the serial board - https:// | ||
Install Arduino IDE if you don't already have it, and upgrade to something recent if you're below version 1.7 - http:// | Install Arduino IDE if you don't already have it, and upgrade to something recent if you're below version 1.7 - http:// | ||
+ | *Go to Preferences in the Arduino app, and enter http:// | ||
* In Boards Manager, add ESP8266 Board support | * In Boards Manager, add ESP8266 Board support | ||
Set up a Cayenne account - https:// | Set up a Cayenne account - https:// | ||
+ | * Click on "Add new..." | ||
+ | * In the page that comes up, click "Bring Your Own Thing" The page that brings up will have your MQTT username/ | ||
Install the following libraries: | Install the following libraries: | ||
* Cayenne MQTT Library - https:// | * Cayenne MQTT Library - https:// | ||
- | * Adafruit Sensor Library | + | * Adafruit Sensor Library |
- | * Adafruit BME280 library | + | * Adafruit BME280 library |
* Arduino SimpleTimer library https:// | * Arduino SimpleTimer library https:// | ||
- | Modify BME280 library | + | For each of these four libraries, click on the "Clone or download" |
+ | |||
+ | Modify BME280 library: | ||
* on OS X, navigate using the finder or otherwise cd ~/ | * on OS X, navigate using the finder or otherwise cd ~/ | ||
- | * On Windows & Linux the files will be somewhere similar. | + | * 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 | + | * edit Adafruit_BME280.h using your favorite editor, and change #define BME280_ADDRESS from 0x77 to 0x76- it should be around line 34 or so. |
- | * more advanced C programmers may do something | + | |
+ | ===If Using Your Phone to Tether=== | ||
+ | I have not tested phone tethering- the prototype worked directly with our in-space WiFi. However, if you wish to try it, there are some instructions to be found here: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | ====THINGS WE WILL DO AT THE CLASS==== | ||
+ | Your kit should consist of a number of boards: | ||
+ | * ESP8266 Wifi-enabled microcontroller | ||
+ | * BME280 sensor array | ||
+ | * AMS1117 voltage regulator | ||
+ | * CH34x-based programmer for the ESP8266 | ||
+ | |||
+ | ==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 | ||
+ | * wiring: | ||
+ | * ESP8266-> | ||
+ | * AMS1117-> | ||
+ | * Note that the 3.3V & GND connections are going to multiple places. | ||
+ | |||
+ | ==Software Programming== | ||
+ | This is the stock program for the class, with some minor edits to account for our BME280 header hack above. | ||
< | < | ||
- | # | + | # |
- | #ifdef CLASS_BME280 | + | |
- | #define BME280_ADDRESS 0x76 | + | |
- | #endif | + | |
- | </code> | + | |
- | 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... | + | #include <Wire.h> |
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | // Your network name and password. | ||
+ | char ssid[] = " | ||
+ | char pass[] = " | ||
+ | // Cayenne authentication info. This should be obtained from the Cayenne Dashboard. | ||
+ | char username[] = " | ||
+ | char mqtt_password[] = " | ||
+ | char client_id[] = " | ||
- | **Hardware Construction** | + | // Virtual Pins of the BME280 widget. |
- | - On the programming board, wire an SPST or SPDT switch between GPIO | + | #define TEMPERATURE_PIN V0 |
+ | #define BAROMETER_PIN V1 | ||
+ | #define HUMIDITY_PIN V2 | ||
+ | # | ||
+ | |||
+ | #define SEALEVELPRESSURE_HPA (1013.25) | ||
+ | |||
+ | Adafruit_BME280 bme; // I2C | ||
+ | unsigned long delayTime; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | Serial.begin(9600); | ||
+ | Cayenne.begin(username, | ||
+ | Wire.begin(0, | ||
+ | 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, | ||
+ | } | ||
+ | |||
+ | CAYENNE_OUT(V2) | ||
+ | { | ||
+ | // Send the Humidity value to Cayenne | ||
+ | Cayenne.virtualWrite(V2, | ||
+ | } | ||
+ | |||
+ | CAYENNE_OUT(V3) | ||
+ | { | ||
+ | // Send the Altitude value to Cayenne | ||
+ | Cayenne.virtualWrite(V3, | ||
+ | } | ||
+ | </ | ||
**Power considerations** | **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. | + | 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. You should be able to power via USB with the serial board as well- just run wires from 3.3v & ground to the appropriate ESP8266 pins and leave out the AMS1117. |
introduction_to_the_internet_of_things.txt · Last modified: 2018/08/22 15:09 by sdh7