A solution to record indoor environment using Google Sheets and ESP-WROOM-02 with several sensors.
Google Sheets is utilized for recording server.
- Create a new spreadsheet
- Open script editor
- Click Tools from the menu bar
- Select "Script editor" subitem
- Replace the default script code with the content of "main.gs" and save
- You must edit
TOKEN
to random characters for security.
- You must edit
const TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
- Run
setup()
function- Choose "setup" from the functions drop-down list
- Click ⏵ icon
- Publish web app
- Click Publish from the menu bar
- Click "Deploy as a web app..."
- Give the project a version number
- Set app access to "Anyone, even anonymous"
- Click Deploy
- If prompted, review and authorize permissions.
- Copy web app URL from Success prompt
This device measures the temperature, illuminance and sound level, and upload them to the sever every 3 minutes.
- ESP-WROOM-02
- Sensors
- Temperature sensor: GY-BMP280-3.3
- Illuminance sensor: M2561P5A
- Condenser microphone: AE-SPU0414
- LDO module (3.3V): M-3V3SIP
- USB to serial UART module: AE-FT234X
- Resistors
- 200kΩ × 2
- 10kΩ × 6
- 2.2kΩ × 1
- 390Ω × 1
- Electrolytic capacitor
- 1µF × 1
- Transistor
- NPN type, hFE 280–560: 2SC536-G
- Wires, connectors, switches, etc...
Main circuit
Writer circuit
Clone the source code and open the project file "ESP8266LivingSensor.ino" with Arduino IDE.
You must import ESP8266 board.
This sketch depends on following libraries. (You can add these by library manager)
Also this uses following library.
You must modify "Credentials.h" according to your situation.
MY_SSID
andMY_PASSWORD
for your Wi-Fi access point- If you assign static IP address to the device, uncomment
#ifdef STATIC_ADDRESS
and editstaticIP
,gateway
,subnet
anddns
.
- If you assign static IP address to the device, uncomment
GAS_PATH
andGAS_TOKEN
for your recoding serverGAS_PATH
depends on the web app URL.GAS_TOKEN
must be same asTOKEN
of web app script.
#define MY_SSID "SSID"
#define MY_PASSWORD "PASSWORD"
//#define STATIC_ADDRESS
#ifdef STATIC_ADDRESS
IPAddress staticIP(192, 168, 1, 100);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(192, 169, 1, 1);
#endif
#define GAS_HOST "script.google.com"
#define GAS_PATH "/macros/s/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/exec"
#define GAS_TOKEN "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
You can build the source code with following configuration.
- Board: "Generic ESP8266 Module"
- Builtin Led: "2"
- Upload Speed: "921600"
- CPU Frequency: "160 MHz"
- Crystal Frequency: "26 MHz"
- Flash Size: "4MB (FS:2MB OTA:~1019KB"
- Flash Mode: "QIO (fast)"
- Flash Frequency: "26 MHz"
- Reset Method: "dtr (aka modemcu)"
- Debug port: "Disabled"
- Debug Level: "None"
- lwIP Variant: "v2 IPv6 Higher Bandwidth"
- VTables: "Flash"
- Exceptions: "Legacy (new can return nullptr)"
- Erase Flash: "Only Sketch"
- Espressif FW: "nonos-sdk 2.2.1+119 (191122)"
- SSL Support: "Basic SSL ciphers (lower ROM use)"
Then, you can transfer binary data to ESP-WROOM-02 throungh the writer circuit.
These codes are licensed under MIT License.