0

$USD

$USD
PROJECTS ArduinoBluetoothIoTESP32

Blynk Internet Clock

DFRobot Jun 09 2019 1056

 

Things used in this project
 

Hardware components

DFRobot FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth) ×1

DHT11 Temperature & Humidity Sensor (4 pins) ×1

Speaker: 3W, 4 ohms ×1

SparkFun display nokia 5510 ×1

Breadboard (generic) ×1

Jumper wires (generic) ×20


 

Software apps and online services

Blynk


 

Hand tools and fabrication machines

Laser cutter (generic)

Soldering iron (generic)

Hot glue gun (generic)

 

Story

Here will be shown how to realize a reveille controlled by a smartphone, using simple raw materials and an Arduino.

We decided to make this project for homework.

Here are the request of this work:

It is asked to use the arduino board.

It is asked to have an input, which in this case is the time set.

It is asked to have an output, which in this case is the alarm sound.

It is asked to use a sensor which was not explained during the school lessons.

The project is an alarm clock based on an ESP32 which is connected by WiFi to a smartphone.

Code

alarmclock.inoArduino

the code of the project is here

#include <DHTesp.h>
#include <WiFi.h>
#include <PCD8544.h>
#include "driver/gpio.h"
#include <SPI.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Blynk.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <BlynkSimpleEsp32.h>
DHTesp dht;
const char* ssid     = "TIM-69381033";
const char* password = "DT6vrJYAt6Z4bJ64";
char auth[] = "2c9cf057d5cd4207962e49220c646e19";
int freq = 2000;
int channel = 0;
int resolution = 8;
int runMinutes = 0;
int runHours = 0;
int secsRemaining = 0;
int runSeconds = 0;
static PCD8544 lcd = PCD8544(14, 13, 27, 26, 15);\\pin of 5510 lcd
#define BLYNK_PRINT Serial
#define NTP_OFFSET  3600 // In seconds 
#define NTP_INTERVAL 60 * 1000    // In miliseconds
#define NTP_ADDRESS  "1.it.pool.ntp.org"
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);
BLYNK_WRITE(V1) {
  runHours = param[0].asLong() / 3600;
  secsRemaining = param[0].asLong() % 3600;
  runMinutes = secsRemaining / 60;
  runSeconds = secsRemaining % 60;
}
void setup() {
  gpio_set_direction( GPIO_NUM_23, GPIO_MODE_OUTPUT);
  gpio_set_level( GPIO_NUM_23, 1);
  dht.setup(22);
  Blynk.begin(auth, ssid, password);
  ledcSetup(channel, freq, resolution);
  ledcAttachPin(12, channel);
  lcd.begin(84, 48);
  timeClient.begin();
}
void loop()
{
  Blynk.run();
  timeClient.update();
  float temperature = dht.getTemperature();
   Blynk.virtualWrite(V6, temperature);.
  String formattedTime = timeClient.getFormattedTime();
  lcd.clear();
  // digital clock display of the time
  lcd.setCursor(20, 1);
  lcd.print(formattedTime);
  int ore = timeClient.getHours();
  int minuti = timeClient.getMinutes();
  int secondi = timeClient.getSeconds();
  if (minuti == runMinutes && ore == runHours)
  {
    ledcWriteTone(channel, 500);
    delay(500);
    ledcWriteTone(channel, 0);
  }
  delay(500);
   }

(This article copied from hackster.io, Author: lollos01)