Skip to content

Arduino and ESP8266 project measuring distance with ultrasonic sensor, connecting to AWS IoT and Arduino IoT Cloud for remote monitoring and control.

Notifications You must be signed in to change notification settings

noamperets/IoT-Ultrasonic-Sensor-Project-

Repository files navigation

Project README

Overview

This project consists of two Arduino sketches for distance measurement using an ultrasonic sensor, with data communication facilitated through AWS IoT and Arduino IoT Cloud. The main.ino sketch is designed for AWS IoT, while the Untitled_mar02a.ino sketch is tailored for Arduino IoT Cloud.

AWS IoT (main.ino)

The AWS IoT sketch connects an ESP8266 to WiFi, synchronizes time using NTP, and publishes distance data to AWS IoT using MQTT. The distance is measured by an ultrasonic sensor (HC-SR04), and the AWS IoT platform is utilized for remote monitoring.

Arduino IoT Cloud (Untitled_mar02a.ino)

The Arduino IoT Cloud sketch employs an ultrasonic sensor to measure distance, controlling an LED based on the measured distance. Additionally, it communicates with the Arduino IoT Cloud to update variables such as ultraSonic, led, and message. The sketch includes functions generated by the Arduino IoT Cloud Thing for handling variable changes from the IoT Cloud Dashboard.

Prerequisites

AWS IoT (main.ino)

  1. Arduino IDE with ESP8266 board support.
  2. Required libraries: ESP8266WiFi, WiFiClientSecure, PubSubClient, ArduinoJson.
  3. AWS IoT account with endpoint, certificates, and Thing Name configured.

Arduino IoT Cloud (Untitled_mar02a.ino)

  1. Arduino board compatible with Arduino IoT Cloud.
  2. Arduino IoT Cloud account - Arduino IoT Cloud.
  3. Required libraries installed using the Arduino Library Manager.

Hardware Setup

AWS IoT (main.ino)

Connect the ultrasonic sensor as per the defined TRIGGER_PIN and ECHO_PIN in the sketch.

Arduino IoT Cloud (Untitled_mar02a.ino)

Connect the ultrasonic sensor and LED according to the specified pins in the sketch.

Configuration

AWS IoT (main.ino)

  1. Modify the secrets.h file with WiFi credentials, AWS IoT endpoint, and certificates.
  2. Adjust time zone, ultrasonic sensor pins, and MQTT topics as needed in main.ino.

Arduino IoT Cloud (Untitled_mar02a.ino)

  1. Open the thingProperties.h file and update it with your IoT Cloud credentials and Thing properties.
  2. Set up the Arduino IoT Cloud Dashboard with widgets for message, ultraSonic, and led variables.

Usage

  1. Upload the respective sketch to your Arduino or ESP8266 board.
  2. Monitor the serial output for debugging information.
  3. Use the IoT Cloud Dashboards for AWS IoT and Arduino IoT Cloud to interact with variables and observe real-time changes.

Troubleshooting

If encountering issues:

  • AWS IoT: Check WiFi connection, AWS IoT credentials, and certificates.
  • Arduino IoT Cloud: Verify hardware connections, IoT Cloud credentials, and library installations.

Refer to official documentation and community forums for assistance.

Additional Notes

  • AWS IoT: AWS IoT platform is utilized for remote monitoring and MQTT communication.
  • Arduino IoT Cloud: LED control and variable updates based on ultrasonic sensor measurements.
  • Customize sketches based on requirements.

Note: Basic familiarity with Arduino, ESP8266, AWS IoT, and Arduino IoT Cloud is assumed. Refer to respective documentation for assistance.

About

Arduino and ESP8266 project measuring distance with ultrasonic sensor, connecting to AWS IoT and Arduino IoT Cloud for remote monitoring and control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published