matwerber1 / arduino-heltec-esp32-aws-iot-shock-sensor

An Arduino project for the Heltec ESP32 deb board that publishes messages to AWS IoT when a shock sensor on the board detects movement.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arduino + Heltec ESP 32 + AWS IoT - Shock Sensor

This is a simple Arduino project that uses this Heltec ESP 32 board with a built-in OLED display.

I've wired the board with a shock sensor from this kit and an LED with a 100 ohm resistor.

When a shock (movement) is detected, the LED turns on and publishes a message to AWS IoT Core.

Inspired by this blog:

Notes

  1. The Heltec board does require some soldering.

  2. Be sure to install the MQTT client from Arduino Library Manager authored by Joel Gaehwiler. There are a lot of MQTT libraries for Arduino, and not all of them seem to support certificate-based authentication / mTLS needed by AWS IoT Core.

  3. I've since added a DHT11 temp/humidity sensor that publishes these sensor values to AWS IoT shadow every few seconds. This is not yet reflected in the examples below.

  4. Also since added a third LED that is meant to be toggled on/off using the AWS IoT device shadow.

  5. At the moment, this is hacked together from various examples. Excuse the mess in main.c.

Demo

Once the board turns on, it connects to WiFi and AWS IoT, and then waits for either the sensor to activate from motion or an incoming MQTT message from AWS IOT:

If I physically move the board, the sensor activates, triggers a red LED, and publishes an MQTT message to the esp32/shockAlert topic in AWS IoT:

Using the "Test" section of the AWS IoT Console to subscribe to this topic and see the message come in almost immediately:

I can also use the IoT Console to publish messages. In this case, the device subscribes itself to the esp32/alert topic:

And finally, the device is subscribed to the topic and will activate a yellow LED and show the received message on the OLED dispay:

About

An Arduino project for the Heltec ESP32 deb board that publishes messages to AWS IoT when a shock sensor on the board detects movement.


Languages

Language:C 76.7%Language:C++ 23.3%