1 Overview

In this lesson, we’ll learn how to measure distances using the HC-SR04 ultrasonic sensor through Cayenne IOT platform.

2 Hardware Preparation

Quantity
Arduino UNO 1
Ethernet Shield W5100 1
USB Cable 1
HC-SR04 Ultrasonic sensor module 1
Jumper wires Several
Breadboard(Optional) 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

Choose Sensors->”Generic”

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.

Leave a Reply

WordPress spam blocked by CleanTalk.
Bombax Theme designed by itx