Product Overview

1/23/2018 ESP32 Environment Sensor Shield Hookup Guide - learn.sparkfun.com
https://learn.sparkfun.com/tutorials/esp32-environment-sensor-shield-hookup-guide?_ga=2.200929641.659504291.1516640116-204410570.150963…
15/17
Besides the ESP32 Arduino Core, the ESP32 Environment Sensor Shield also requires the CCS811, BME280 and APDS-
9301 Arduino libraries. Be sure to grab the libraries from each respective GitHub repositories, or you can download the files directly
from the buttons below:
SPARKFUN CCS811 ARDUINO LIBRARY
SPARKFUN BME280 ARDUINO LIBRARY
SPARKFUN APDS-9301 ARDUINO LIBRARY
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time
using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library,
please check out our installation guide.
If you have not already, make sure to setup your own weather station with Wunderground. You will need to fill out a form and pick a
username & password in order to receive a station ID. Sensor data from the ESP32 Thing and the ESP32 Environment Sensor
Shield can then be pushed to Wunderground’s server.
Here we present some example code for the ESP32 Environment Sensor Shield. This code reads all of the sensors, prints the
resulting data to the serial port once per second, then posts some of the more germane data to Weather Underground once per
minute.
Note: When connecting to a WiFi network and the Wunderground server, make sure to modify the
variables ssid , password , ID , and key .
Expected Output
Here is a picture of what you should expect upon starting up your ESP32 and letting it connect to WiFi:
COPY CODE
#include <SparkFunCCS811.h>
#include "SparkFunBME280.h"
#include "Wire.h"
#include <Sparkfun_APDS9301_Library.h>
#include <WiFi.h>
BME280 bme;
CCS811 ccs(0x5B);
APDS9301 apds;
// Variables for wifi server setup
const char* ssid = "your_ssid_here";
const char* password = "password";
String ID = "wunderground_station_id";
String key = "wunderground_station_key";
WiFiClient client;
const int httpPort = 80;
i