Some time ago I built a LED clock. It works well, but the blue LED on the ESP8266 blinks continuously and a AM radio near it makes a toc-toc-toc sound with a 1 second period.
I read that NTP servers could ban an IP if a device reads the time more often than one time every 64 seconds or something similar. The NTP time reading should be every 10 minutes. I tried
setSyncInterval (600);
but I didn't notice any difference.
I used the time.h library, but some days ago I wasn't able to find it between installed ones in library manager, despite being the program compiled and loaded without any problem, so I installed TimeLib.h (I don't know if it is a new version of time.h), but it works the same...
Does anyone know exactly what should I do?
Thanks for your help
Gianluca
#include <ESP8266WiFi.h> // URL aggiuntivo per il gestore schede: http://arduino.esp8266.com/stable/package_esp8266com_index.json
#include <SPI.h> // Mi sembra che funzioni anche senza...
#include <Adafruit_GFX.h> // Usato da Max72xxPanel
#include <Max72xxPanel.h> // Installare da zip: https://github.com/markruys/arduino-Max72xxPanel
// #include <time.h>
#include <TimeLib.h>
void scrive_orario()
{
time_t now = time(nullptr); // Facendo now variabile globale, perdeva il fuso orario.
if (now!=t_prec)
{
t_prec=now;
matrix.fillScreen(LOW);
String time = String(ctime(&now));
time.trim();
time.substring(11,19).toCharArray(time_value, 10);
if(time_value[7]!=sec_prec) {t_prec=millis(); digitalWrite(D0, HIGH); sec_prec=time_value[7];/*GP16O|=1;*/} // Porta a livello alto la porta GPIO16 (D0).
// Visualizza lo '0' iniziale prima delle ore 9.00:
matrix.drawChar(P,0, time_value[0], HIGH,LOW,1); //
(...)
}
}
void setup()
{
//ESP.wdtDisable(); // Disabilita il watchdog software.
//hw_wdt_disable(); // Disabilita il watchdog hardware.
pinMode(D0, OUTPUT); // 1Hz.
pinMode(sys_pin,INPUT_PULLUP); // Chiudere a massa durante il loop per leggere sysinfo.
pinMode(D6,INPUT_PULLUP); // Chiudere a massa in qualsiasi momento per capovolgere il display.
// Serial.begin(9600);
setSyncInterval(600); // 600 secondi.
se_capovolto(); // Imposta la disposizione delle matrici di LED leggendo lo stato dell'ampollina al mercurio.
(...)
void loop()
{
if(millis()-t_display>200)
{
t_display=millis();
lum=map(analogRead(0),0,1023,0,15); matrix.setIntensity(lum); // Ogni 200ms legge il potenziometro (1023 con 3,3V).
se_capovolto();
}
scrive_orario();
(...)