- Tue Jan 29, 2019 11:20 am
#80330
01/29/2019
Project sketch is executing without a wdt_reset; it is still a little "touchy" initiating a client "GET" request. Over-all much improved. File, fileRead function is once again fully functional.
Some of the problem was with the GPIO pins I was attempting to use. Current GPIO pin used for espsoftwaresaerial are GPIO5 for TX, GPIO4 for RX, DS3231 uses GPIO2 for SDA, and GPIO0 for SCL. Project board is a RobotDyn WiFi D1 R2. Board looks like a clone of the WeMos WiFi D1 R2.
Project uses a DS3231 for time keeping and will be updated by a Neo m8n GPS module. I am having a "false" value for unixtime in the function RTC_UPDAE. Unixtime value is almost double. Standalone sketch "Get_unixtime.ino" gives correct unixtime value. Intergrating it into project gives about twice the value for unixtime.
Get_unixtime.ino:
[code#include <time.h>
#include <stdio.h>
void setup() {
Serial.begin(115200);
struct tm timeinfo;
unsigned int unixtime;
printf("hello\n");
timeinfo.tm_year = 2017 - 1900;
timeinfo.tm_mon = 12 - 1;
timeinfo.tm_mday = 13;
timeinfo.tm_hour = 16;
timeinfo.tm_min = 46;
timeinfo.tm_sec = 45;
unixtime = mktime(&timeinfo);
printf("time = %u\n", unixtime);
// return 0;
}
void loop(){}][/code]
RTC_UPDATE function:
Code: Select allvoid RTC_UPDATE()
{
ESP.wdtDisable();
Serial.println("");
Serial.print(F("GPS UTC Date/Time: "));
if (gps.date.isValid())
{
Serial.print(gps.date.month());
Serial.print(F("/"));
Serial.print(gps.date.day());
Serial.print(F("/"));
Serial.print(gps.date.year());
}
else
{
Serial.print(F("INVALID"));
}
Serial.print(F(" "));
if (gps.time.isValid())
{
if (gps.time.hour() < 10) Serial.print(F("0"));
Serial.print(gps.time.hour());
Serial.print(F(":"));
if (gps.time.minute() < 10) Serial.print(F("0"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
if (gps.time.second() < 10) Serial.print(F("0"));
Serial.print(gps.time.second());
Serial.print(F("."));
if (gps.time.centisecond() < 10) Serial.print(F("0"));
Serial.print(gps.time.centisecond());
Serial.println("");
}
else
{
Serial.print(F("INVALID"));
}
struct tm timeinfo;
unsigned long int unixtime;
timeinfo.tm_year = gps.date.year() - 1970;
timeinfo.tm_mon = gps.date.month() - 1;
timeinfo.tm_mday = gps.date.day();
timeinfo.tm_hour = gps.time.hour();
timeinfo.tm_min = gps.time.minute();
timeinfo.tm_sec = gps.time.second();
unixtime = mktime(&timeinfo);
Serial.println("");
printf("unixtime = %u\n", unixtime);
Clock.setDateTime(unixtime);
Serial.println("RTC updated");
ESP.wdtEnable(1000);
}
Any issues with the RTC_UPDATE function; that would cause the unixtime variable to be almost twice the expected value?
William
Attachments
Featuring web interface, graphs, rain gauge, and
GPS --still a work in progress. Working concept demo.
(21.83 KiB) Downloaded 170 times
Screen captures, text files and board pinout.
(1.65 MiB) Downloaded 163 times
Last edited by Sirquil on Wed Jan 30, 2019 4:09 pm, edited 1 time in total.