THOFARAK
Natural & Healthy
Jadwal Sholat dilengkapi Suara Adzan dan Dzikir Pagi & Petang serta Surat Al Kahfi Tiap Hari Jum'at + Temperature Udara Sekitar (Arduino Uno Project)


#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

#include <max6675.h>
int thermoDO = 2;
int thermoCS = 3;
int thermoCLK = 4;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

#include <stdio.h>
#include <DS1302.h>
#include <LiquidCrystal_I2C.h>
#include "PrayerTimes.h"

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

const int kCePin = 5; // Chip Enable (RST)
const int kIoPin = 6; // Input/Output (DAT)
const int kSclkPin = 7; // Serial Clock (CLK)

// Create a DS1302 object.
DS1302 rtc(kCePin, kIoPin, kSclkPin);
Time t = rtc.time();

double times[sizeof(TimeName)/sizeof(char*)];
int dst=7;

int jam, menit, detik, tahun, bulan, tanggal;

String cetak_jam;
String cetak_menit;
String cetak_detik;

int i = 0;

String jam_sekarang;
String jam_sholat;

int stringStart, stringStop = 0;

String wkt_sbh;
String wkt_zhr;
String wkt_asr;
String wkt_mgr;
String wkt_isy;
String Suhu;

int ambil_jam_sholat;
int ambil_menit_sholat;
int satuan_jam_sholat;
int puluhan_jam_sholat;
int satuan_menit_sholat;
int puluhan_menit_sholat;

int JamSubuh;
int mntSubuh;
int JamTerbit;
int mntTerbit;
int JamDhuhur;
int mntDhuhur;
int JamAshar;
int mntAshar;
int JamMaghrib;
int mntMaghrib;
int JamIsya;
int mntIsya;



void setup() {


mySoftwareSerial.begin(9600);
Serial.begin(115200);

Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));

myDFPlayer.volume(20); //Set volume value. From 0 to 30
myDFPlayer.EQ(DFPLAYER_EQ_ROCK);


Serial.begin(9600);

// Initialize a new chip by turning off write protection and clearing the
// clock halt flag. These methods needn't always be called. See the DS1302
// datasheet for details.
//rtc.writeProtect(false);
//rtc.halt(false);

// Make a new time object to set the date and time.
// Tuesday, June 16, 2020 at 15:48:00.
//Time t(2020, 6, 16, 15, 48, 00, Time::kTuesday);

// Set the time and date on the chip.
//rtc.time(t);

// initialize the lcd
lcd.init();
lcd.backlight();
delay(500);



}

void loop() {

// basic readout test, just print the current temp
Suhu = String(thermocouple.readCelsius());

//////////////////////Ambil Real Time Clock////////////////////////////////
Time t = rtc.time();
jam = t.hr;
menit = t.min;
detik = t.sec;
tahun = t.yr;
bulan = t.mon;
tanggal = t.date;


//Masukkan lintang dan Bujur Kota Anda (contoh: Gresik L: -7.66666 (tanda '-' untuk LS) B: 112.66666)
set_calc_method(MWL);
set_asr_method(Shafii);
set_high_lats_adjust_method(AngleBased);
set_fajr_angle(20);
set_isha_angle(18);
get_prayer_times(t.yr, t.mon, t.date, -7.16666, 112.66666, dst, times);

///////////////////////////////////////////////Ambil Waktu Sholat Jam dan Menit (integer)///////////////////////////////////
ambil_jadwal_sholat(0);
JamSubuh = ambil_jam_sholat;
mntSubuh = ambil_menit_sholat;


ambil_jadwal_sholat(1);
JamTerbit = ambil_jam_sholat;
mntTerbit = ambil_menit_sholat;


ambil_jadwal_sholat(2);
JamDhuhur = ambil_jam_sholat;
mntDhuhur = ambil_menit_sholat;


ambil_jadwal_sholat(3);
JamAshar = ambil_jam_sholat;
mntAshar = ambil_menit_sholat;


ambil_jadwal_sholat(5);
JamMaghrib = ambil_jam_sholat;
mntMaghrib = ambil_menit_sholat;


ambil_jadwal_sholat(6);
JamIsya = ambil_jam_sholat;
mntIsya = ambil_menit_sholat;


/////////////////////Mengaktikan waktu Sholat sudah masuk/////////////////////

if (jam == JamSubuh && menit == mntSubuh)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("WAKTUNYA SUBUH");
myDFPlayer.play(1);
delay(60000);}

else if (jam == JamDhuhur && menit == mntDhuhur)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("WAKTUNYA DHUHUR");
myDFPlayer.play(2);
delay(60000);}

else if (jam == JamAshar && menit == mntAshar)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("WAKTUNYA ASHAR");
myDFPlayer.play(3);
delay(60000);}

else if (jam == JamMaghrib && menit == mntMaghrib)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("WAKTUNYA Maghrib");
myDFPlayer.play(4);
delay(60000);}

else if (jam == JamIsya && menit == mntIsya)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("WAKTUNYA ISYA");
myDFPlayer.play(5);
delay(60000);}


else if (jam == JamTerbit && menit == mntTerbit)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("MATAHARI TERBIT");
delay(60000);}

else if (jam == 05 && menit == 10)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("DZIKIR PAGI");
myDFPlayer.play(6);
delay(60000);}

else if (jam == 18 && menit == 10)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("DZIKIR PETANG");
myDFPlayer.play(7);
delay(60000);}

else if (jam == 10 && menit == 00 && t.day == 6)
{lcd.clear();
lcd.setCursor(0,0);
lcd.print("SURAT AL KAHFI");
myDFPlayer.play(8);
delay(60000);}


////////////////////////////////////////////////////////////////////////////////

// ambil waktu subuh
ambil_jadwal_sholat(0);
wkt_sbh = String(puluhan_jam_sholat) + String(satuan_jam_sholat) + ":" + String(puluhan_menit_sholat) + String(satuan_menit_sholat) + " " + Suhu;
// ambil waktu zuhur
ambil_jadwal_sholat(2);
wkt_zhr = String(puluhan_jam_sholat) + String(satuan_jam_sholat) + ":" + String(puluhan_menit_sholat) + String(satuan_menit_sholat)+ " " + Suhu;
// ambil waktu ashar
ambil_jadwal_sholat(3);
wkt_asr = String(puluhan_jam_sholat) + String(satuan_jam_sholat) + ":" + String(puluhan_menit_sholat) + String(satuan_menit_sholat)+ " " + Suhu;
// ambil waktu maghrib
ambil_jadwal_sholat(5);
wkt_mgr = String(puluhan_jam_sholat) + String(satuan_jam_sholat) + ":" + String(puluhan_menit_sholat) + String(satuan_menit_sholat)+ " " + Suhu;
// ambil waktu isya
ambil_jadwal_sholat(6);
wkt_isy = String(puluhan_jam_sholat) + String(satuan_jam_sholat) + ":" + String(puluhan_menit_sholat) + String(satuan_menit_sholat)+ " " + Suhu;

if(jam<10){ cetak_jam = "0" + String(jam); }
else { cetak_jam = String(jam); }

if(menit<10){ cetak_menit = "0" + String(menit); }
else { cetak_menit = String(menit); }

if(detik<10){ cetak_detik = "0" + String(detik); }
else { cetak_detik = String(detik); }

lcd.clear();
lcd.setCursor(0,0);
jam_sekarang = String(t.date) + "/" + String(t.mon) + "/" +String(t.yr).substring(2,4) + " " + String(cetak_jam) + ":" + String(cetak_menit) + ":" + String(cetak_detik);
lcd.print(jam_sekarang);

jam_sholat = "Fajr " + wkt_sbh + "Duhr " + wkt_zhr + "Ashr " + wkt_asr + "Mgrb " + wkt_mgr + "Isya " + wkt_isy + " ";


lcd.setCursor(0, 1);
lcd.print(jam_sholat.substring(stringStart,stringStop));
lcd.print(" ");
delay(500);

i++;
if (i>=1 && i<16){
stringStart=0;
stringStop=16;
}
if (i>=16 && i<33){
stringStart=16;
stringStop=32;
}
if (i>=33 && i<49){
stringStart=32;
stringStop=48;
}
if (i>=48 && i<64){
stringStart=48;
stringStop=64;
}
if (i>=64 && i<80){
stringStart=64;
stringStop=80;
}
if (i>=80 && i<90){
i=0;
}
}

void ambil_jadwal_sholat(int waktu)
{

get_float_time_parts(times[waktu], ambil_jam_sholat, ambil_menit_sholat);
if (ambil_menit_sholat < 58)
{
ambil_menit_sholat = ambil_menit_sholat + 2;
ambil_jam_sholat = ambil_jam_sholat;
}
else if (ambil_menit_sholat == 58)
{
ambil_menit_sholat = 0;
ambil_jam_sholat = ambil_jam_sholat + 1;
}
else if (ambil_menit_sholat == 59)
{
ambil_menit_sholat = 1;
ambil_jam_sholat = ambil_jam_sholat + 1;
}

satuan_jam_sholat = ambil_jam_sholat % 10;
puluhan_jam_sholat = ambil_jam_sholat / 10;
satuan_menit_sholat = ambil_menit_sholat % 10;
puluhan_menit_sholat = ambil_menit_sholat / 10;

}
Komponen Yang Diperlukan:

- Arduino Uno R3
- I2C 1602 LCD
- RTC DS1302
- T/C dgn Max6675
- DFPlayer Mini + Speaker
- Bread Board
- Kabel Jumper Secukupnya


PC dengan Arduino IDE
untuk Pemrograman

Terinspirasi dari :
https://yopiardinal.wordpress.com/