In this lesson, we’ll learn how to measure distances using the HC-SR04 ultrasonic sensor through Cayenne IOT platform.
2 Hardware Preparation
|Ethernet Shield W5100||1|
|HC-SR04 Ultrasonic sensor module||1|
3 Hardware connection
Connect the HC-SR04 with UNO as following diagram:
4 Add new device
Log in Cayenne IOT platform, Add new…->Device/Widget
Click Digital Input，setting the datasheet as followed:
In your dashboard, click “Step 1:Sketch File”, the sample sketch will be displayed, in this example,we creat a new sketch, please download from:http://osoyoo.com/driver/HC-SR04_sensor.txt
Copy and paste the sketch into Arduino IDE ,please remember to use your own authentication token. Upload the sketch to your Uno board, then click “Setp 2 :Add Sensor”, you will find the distance widget was added on your dashboad.
From the dashboard, you can check the results of the distance measurement from the web browser or smart phone.