Hi i am curios how to change "time" from RTC using at command,,
any suggestion ?
Which RTC is it ?
Are you using a library to control the RTC ?
If so then please provide a link to it
Did it come with any examples ?
DS3231
yeah i am using
#include <DS3231.h>
// LIBRARY
#include <SD.h>
#include <SPI.h>
#include <DS3231.h>
// BUAT FILE DAMA SD CARD
File myFile;
DS3231 rtc(SDA, SCL);
/////////////////////////////////////////////////INISIALISASI///////////////////////////////////////
//SENSOR
const int pinCS = 53; // Pin 10 on Arduino Uno // Pin Data Loggin SD CARD
const int Sensor_Prox = A0; // Sensor pin
int Nilai_Sensor_Prox = 0; // variable sensor
int Data_Sensor_Prox = 0; // nilai output
//WAKTU
unsigned long Millis_Ambil_Sensor_Prox = 0; //Sesuaikan "unsigned long Millis_Sensor_Prox" dengan "const long_X"
unsigned long Millis_Ambil_Sensor_Waktu = 0;
unsigned long Millis_Kirim_DataSensor_Prox = 0;
unsigned long Millis_Kirim_DataSensor_Waktu = 0;
// waktu eksekusi data
const long Ambil_Data_Sensor_Prox = 500; //rubah sesuai waktu yang dibutuhkan untuk melakukan suatu pekerjaan tertentu
const long Ambil_Data_Sensor_Waktu = 500;
const long Millis_Kirim_DataSensor = 1000;
//const long Millis_Kirim_DataSensor_Prox =
void setup() {
// put your setup code here, to run once:
// pilih mode input atau output
pinMode(Sensor_Prox, INPUT); // pilih mode input atau output
pinMode(pinCS, OUTPUT);
Serial.begin(115200);
// SD Card Initialization
if (SD.begin())
{
Serial.println("SD card siap digunakan.");
} else
{
Serial.println("SD card error");
return;
}
rtc.begin();
}
void loop() {
// put your main code here, to run repeatedly:
// Sensor yang akan digunakan
//Sensor Jarak
Nilai_Sensor_Prox = analogRead(Sensor_Prox);
Data_Sensor_Prox = map(Nilai_Sensor_Prox, 100, 1023, 0, 367); //<<<<< PERLU KALIBRASIII!!!
//Sensor RTC / Waktu
unsigned long currentMillis = millis();
if (currentMillis - Millis_Ambil_Sensor_Prox >= Ambil_Data_Sensor_Prox) {
Millis_Ambil_Sensor_Prox = currentMillis;
//////////////////////MASUKAN PERINTAH DI BAWAH INI/////////////
Serial.print("Test Ambil Data Sensor Prox = ");
Serial.print (Data_Sensor_Prox);
Serial.println(" cm");
}
if (currentMillis - Millis_Ambil_Sensor_Waktu >= Ambil_Data_Sensor_Waktu) {
Millis_Ambil_Sensor_Waktu = currentMillis;
//////////////////////MASUKAN PERINTAH DI BAWAH INI/////////////
Serial.println("Test Ambil Data Sensor Waktu");
Serial.print(rtc.getTimeStr());
Serial.print(",");
Serial.println(int(rtc.getTemp()));
// Serial.print (Data_Sensor_Prox);
// Serial.println(" cm");
}
if (currentMillis - Millis_Kirim_DataSensor_Prox >= Millis_Kirim_DataSensor) {
Millis_Kirim_DataSensor_Prox = currentMillis;
//////////////////////MASUKAN PERINTAH DI BAWAH INI/////////////
Serial.println("Test Kirim Data Sensor Prox dan waktu");
myFile = SD.open("test.txt", FILE_WRITE);
if (myFile) {
myFile.print(rtc.getTimeStr());
myFile.print(",");
myFile.println(int(rtc.getTemp()));
myFile.close(); // close the file
}
else {
Serial.println("error opening test.txt"); // error apabila file tidak terbuka
}
// Serial.print (Data_Sensor_Prox);
// Serial.println(" cm");
}
///////////////////////////
}
i wanna change the time using SMS via AT COMMAND, and i dont have any idea to do it,,
my project will be implemented in the middle nowhere when its so hard to get acccest, so i can set up time, and recalibration the sensor ,,
how can i do it ?
// rtc.setDOW(TUESDAY); // Set Day-of-Week to SUNDAY
// rtc.setTime(10, 50, 12); // Set the time to 12:00:00 (24hr format)
// rtc.setDate(20, 4, 2021); // Set the date to January 1st, 2014
i usually use this,, but in couple year if the project going on, i had some issue with the time, and not working properly,,
so i wanna recalibrate the time using AT COMMAND via SMS ? Please help me
The .setXXX functions are the way to do it. You could write directly to the RTC registers to set the values but that is exactly what the functions do so there is no real advantage
so basically i cant reprogram with at command ?
Why the obsession with using AT commands ?
As long as you write the sketch correctly it could parse any format that you send it via SMS
Take a look at Serial input basics - updated for some ideas and guidance
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.