This is my second posted project with AVR-IoT WG board. In the first project we connected the board to a private Google cloud, saved all received data in Firebase, and displayed only the most recent Blood Pressure Monitor (BPM) data in Google Sheets. In this project we will save all data directly in Google Sheets. To avoid unnecessary duplication of work, please review the first project prior to reading this project.
We will use Arduino IDE for this project because it lowers the barrier to entry for many new makers. I'm using Google sheets after receiving good feedback regarding my previous AVR-IoT WG project and Helium Network GPS Tracking Directly In Google Sheets project.
Game PlanWe will use AVR-IoT WG to connect to Wi-Fi and send data to Google Sheets which means we will code only in Arduino IDE and Apps Script. Once a connection is made, BPM will take measurements and results will be sent with a simple HTTPS POST request. Apps Script will then parse the data and populate Google Sheets.
Gathering InformationThis is one of the most useful diagrams in the documentations. We can get few bits of information from AVR-IoT_WG_Schematics.pdf. The first thing we need is the I2C address of CryptoAuthentication so we can get the serial number and avoid manually hard coding values in every device we deploy. The next I2C address we need to get is the Temperature Sensor's.
We don't need to do anything with SPI since ATmega4808 and WINC1510 already connected. However, we need to find from the schematic pin numbers for CHIP_EN, RESET, WAKE, and IRQN. We could also get the same information from MPLAB X IDE.
First of all; we need to install the board in Arduino IDE following steps listed here. We also need to install three libraries for CryptoAuthentication, Wi-Fi, and temperature sensor.
The only modification that needed to be done outside Arduino IDE is in C:\Users\<login>\Documents\Arduino\libraries\ArduinoECCX08\src\ECCX08.cpp because that file uses 0x60 as I2C address. The I2C address of CryptoAuthentication that we obtained above was 0x58. Therefore, we needed to change:
ECCX08Class ECCX08(Wire, 0x60);
to
ECCX08Class ECCX08(Wire, 0x58);
One thing to note here is the I2C address in MPLAB X IDE is 7-bit left-aligned (0xB0) so we can't just use it without shifting right (divide by 2) first.
Please note that we used pin numbers in C:\Users\<login>\AppData\Local\Arduino15\packages\MegaCoreX\hardware\megaavr\1.0.6\variants\32pin-standard\pins_arduino.h
Apps ScriptWe used the same Google Sheets and Apps Script from the previous project. We added doPost function to handle POST request made by AVR-IoT WG.
DemoThe top few rows came from the previous project and kept here for comparison. We can barely hear the sound, but as soon as BPM finishes reading, the data shows up in Google Sheet almost instantly.
Comments