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.
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.
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.
- Arduino IDE with ESP8266 board support.
- Required libraries: ESP8266WiFi, WiFiClientSecure, PubSubClient, ArduinoJson.
- AWS IoT account with endpoint, certificates, and Thing Name configured.
- Arduino board compatible with Arduino IoT Cloud.
- Arduino IoT Cloud account - Arduino IoT Cloud.
- Required libraries installed using the Arduino Library Manager.
Connect the ultrasonic sensor as per the defined TRIGGER_PIN
and ECHO_PIN
in the sketch.
Connect the ultrasonic sensor and LED according to the specified pins in the sketch.
- Modify the
secrets.h
file with WiFi credentials, AWS IoT endpoint, and certificates. - Adjust time zone, ultrasonic sensor pins, and MQTT topics as needed in
main.ino
.
- Open the
thingProperties.h
file and update it with your IoT Cloud credentials and Thing properties. - Set up the Arduino IoT Cloud Dashboard with widgets for
message
,ultraSonic
, andled
variables.
- Upload the respective sketch to your Arduino or ESP8266 board.
- Monitor the serial output for debugging information.
- Use the IoT Cloud Dashboards for AWS IoT and Arduino IoT Cloud to interact with variables and observe real-time changes.
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.
- 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.