EnzoDAndrea / ESP32-AWS

Use ESP32 to send on AWS IoT Core telemetry data: Temperature, Humidity, Atmospheric pressure, luminosity, current weather condition coming from OpenWeatherMapAPI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32-AWS: Read data from different sensor and store them in Amazon Web Service IoT (Arduino Sketch)


Board Manager Libraries:

  1. ESP32 by Espressif Systems

Required Libraries:

  1. MQTT by Joel Gaehwiler
  2. ArduinoJson by Benoit Blanchon
  3. DHT sensor library by Adafruit
  4. Adafruit BMP280 Library by Adafruit
  5. BH1750 library by Christopher Laws

File to be modified

ESP32-AWS/ESP32/secrets.h

  1. FILL YOUR SSID and PASSWORD
const char WIFI_SSID[] = "[YOUR SSIS]";
const char WIFI_PASSWORD[] = "[YOUR PASSWORD]";
  1. FILL THE NAME of YOUR DEVICE
#define THINGNAME "[YOUR THINGNAME]" 
  1. FILL AWS ENDPOINT
const char MQTT_HOST[] = "[YOUR AWS MQTT]";
  1. Download your root certificate, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char cacert[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
[PUT YOUR CERTIFICATE HERE]
-----END CERTIFICATE-----
)EOF";
  1. Download your device certificate, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char client_cert[] PROGMEM = R"KEY(
-----BEGIN CERTIFICATE-----
[PUT YOUR CERTIFICATE HERE]
-----END CERTIFICATE-----
)KEY";
  1. Download your device private key, open it in read mode and replace the section between "BEGIN CERTIFICATE" and "END CERTIFICATE"
static const char privkey[] PROGMEM = R"KEY(
-----BEGIN RSA PRIVATE KEY-----
[PUT YOUR KEY HERE]
-----END RSA PRIVATE KEY----- 
)KEY";
  1. Replace this section with your registred API KEY from https://openweathermap.org/
const char OPEN_WEATHER_MAP_API_KEY[] = "[YOUR API KEY]"; 

Example of telemetry payload

{"time":1675957668,"city":"Milan","latitude":45.22,"longitude":9.22,"humidity":28.89999962,"temp":24.04000092,"pressure":101844.1406,"lux":11.66666603,"weathercode":800,"weatherdescr":"clear sky"}

About

Use ESP32 to send on AWS IoT Core telemetry data: Temperature, Humidity, Atmospheric pressure, luminosity, current weather condition coming from OpenWeatherMapAPI


Languages

Language:C 66.1%Language:C++ 33.9%