0% found this document useful (0 votes)
33 views

Tema 3

This document describes a project using an ultrasonic sensor and NodeMCU ESP8266 to measure distance and display it on a Blynk app. The sensor works by sending ultrasonic pulses and measuring the echo time to calculate distance. It is connected to the ESP8266 along with a Blynk auth token. The ESP8266 code uses the sensor to periodically measure distance, convert it to inches, and send it to the Blynk virtual pin. A video demo of the working project is provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Tema 3

This document describes a project using an ultrasonic sensor and NodeMCU ESP8266 to measure distance and display it on a Blynk app. The sensor works by sending ultrasonic pulses and measuring the echo time to calculate distance. It is connected to the ESP8266 along with a Blynk auth token. The ESP8266 code uses the sensor to periodically measure distance, convert it to inches, and send it to the Blynk virtual pin. A video demo of the working project is provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

TEMA 3

SENSOR JARAK/SENSOR ULTRASONIK DENGAN APLIKASI BLYNK

Nama kelompok:
1. Farhan Ibnu Fajar
2. M Aditya Darmawan
3. Yonanda Andriawan
4. Iqbal Prasetio

1. CARA KERJA
Sensor ultrasonik adalah sebuah sensor yang berfungsi untuk mengubah
besaran fisis (bunyi) menjadi besaran listrik dan sebaliknya.

Cara kerja sensor ini didasarkan pada prinsip dari pantulan suatu gelombang
suara sehingga dapat dipakai untuk menafsirkan eksistensi (jarak) suatu
benda dengan frekuensi tertentu.

Panduan : https://youtu.be/Kn8_JAvAJsY
Tutorial :https://randomnerdtutorials.com/esp8266-nodemcu-hc-sr04-
ultrasonic-arduino/
PART YANG DIGUNAKAN
NO NAMA PART JUMLAH SATUAN
1 NODEMCU ESP8266 1 Unit
2 HC-SR04 1 PCS

2. WIRING DIAGRAM
3. PROGRAM

#define BLYNK_TEMPLATE_ID "TMPL58tkifbZ"


#define BLYNK_DEVICE_NAME "Sensor Jarak"
#define BLYNK_AUTH_TOKEN "QbqJkB8byA0ebRq5lOKBnKHu-aUwAiY7"
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.


// Set password to "" for open networks.
char ssid[] = "Paangg";
char pass[] = "Farhan123";

const int trigPin = D6;


const int echoPin = D7;

//define sound velocity in cm/uS


#define SOUND_VELOCITY 0.034
#define CM_TO_INCH 0.393701

long duration;
float distanceCm;
float distanceInch;
BlynkTimer timer;

void myTimerEvent()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);

// Calculate the distance


distanceCm = duration * SOUND_VELOCITY/2;
// Convert to inches
distanceInch = distanceCm * CM_TO_INCH;

// Prints the distance on the Serial Monitor


Serial.print("Distance (cm): ");
Serial.println(distanceCm);
Serial.print("Distance (inch): ");
Serial.println(distanceInch);

// You can send any value at any time.


// Please don't send more that 10 values per second.
Blynk.virtualWrite(V0,distanceCm);
}

void setup() {
Serial.begin(115200); // Starts the serial communication
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

// Setup a function to be called every second


timer.setInterval(1000L, myTimerEvent);
}

void loop() {

Blynk.run();
timer.run();
// Clears the trigPin

}
4. TAMPILAN APLIKASI

5. LINK VIDEO HASIL UJICOBA

https://drive.google.com/file/d/1Cb3gZRYf6xYiSLPDBfNssrn2gjVSkJ03/view?
usp=drivesdk

You might also like