2019
- ESP32 board
- HC-SR04 ultrasonic sensor
- WiFi network with internet access
- Line developer account
- Line Notify API token
2. Connect the HC-SR04 sensor to the ESP32 board.
3. Replace the 'LINE_TOKEN' value with your Line Notify API token.
4. Compile and upload the code to the ESP32 board.
5. Open the Serial Monitor to see the program output.
6. The program will automatically connect to a WiFi network if available.
7. Once connected to the network, the program will get the time from an NTP server.
8. The program will then continuously read the distance from the HC-SR04 sensor and send a notification to your Line account every 15 minutes at :15, :30, :45, and :00 of every hour.
9. To stop the program, press the reset button on the ESP32 board.
- 'echoPin' and 'trigPin' are the pins used for the HC-SR04 sensor.
- 'timezone' is the timezone used to set the correct time.
- 'dst' is used to set the daylight saving time.
- 'count', 'savehour', and 'savemin' are used to keep track of the time.
- 'ckh' and 'ckm' are used to check the current hour and minute.
- 'A' is a flag that is used to check if a notification has already been sent.
- 'message1', 'message2', 'message3', and 'message4' are variables used to construct the message sent to Line.
- 'humid' and 'temp' are variables used to read the humidity and temperature from the BME280 sensor.
- 'setup()' initializes the program by setting the pin modes, starting the serial communication, and connecting to a WiFi network using the 'WiFiManager' library.
- 'loop()' is the main program loop that continuously reads the time and distance from the HC-SR04 sensor. If the current time matches the scheduled time, the program sends a notification to Line.
- 'Line_Notify()' is a function that sends a notification to Line using the Line Notify API.
- The program is currently hard-coded to send notifications every 15 minutes. This can be changed by modifying the 'ckm' variable.
- The program uses the HC-SR04 sensor to measure distance, which has limitations in terms of accuracy and range.
- The program may encounter issues with time synchronization if the NTP server is not reachable.