NTP-based WIFI time for v1 clocks

More
3 months 1 week ago #10519 by Froula
I did enable the memory map with SPIFFS in the board selection menu of the Arduino IDE. PUYA support was not needed for the ESP-12E board I am using. The configuration storage is working for me.

I did need to modify the GPIO pins used for the bit-banged I2C interface, as the ESP-12E has an LED connected to GPIO2. The v1 WifiTimeProviderESP8266.ino sketch defines GPIO0 for the SDA line and GPIO2 for the SCL line.

Wire.begin(0, 2); // SDA = 0, SCL = 2

These equate to D3 for SDA and D4 for SCL.

I changed the statement to:

Wire.begin(14, 12); // SDA = D5, SCL = D6

This moved the I2C pins to GPIO14 for SDA (D5) and GPIO12 for SCL (D6). These pins are not connected to any development board hardware.

To check the connections, I wired the ESP-12E, the RTC module, and the clock to the new I2C pins D5 and D6 and ran the i2c_port_address_scanner sketch on the ESP-12E. This program scans every possible combination of GPIO pins for SDA and SCL and looks for I2C device on each pairing. The results were as follows:

I2C Scanner to scan for devices on each port pair D0 to D7
Scanning (SDA : SCL) - GPIO16 : GPIO5 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO4 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO0 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO2 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO14 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO12 - No I2C devices found
Scanning (SDA : SCL) - GPIO16 : GPIO13 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO16 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO4 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO0 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO2 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO14 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO12 - No I2C devices found
Scanning (SDA : SCL) - GPIO5 : GPIO13 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO16 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO5 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO0 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO2 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO14 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO12 - No I2C devices found
Scanning (SDA : SCL) - GPIO4 : GPIO13 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO16 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO5 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO4 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO2 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO14 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO12 - No I2C devices found
Scanning (SDA : SCL) - GPIO0 : GPIO13 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO16 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO5 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO4 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO0 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO14 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO12 - No I2C devices found
Scanning (SDA : SCL) - GPIO2 : GPIO13 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO16 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO5 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO4 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO0 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO2 - No I2C devices found
Scanning (SDA : SCL) - GPIO14 : GPIO12 - I2C device found at address 0x57 !
I2C device found at address 0x68 !
I2C device found at address 0x69 !
**********************************

This validated my hardware connections through the ESP-12E level converter to the clock and the RTC module. The scanner program found the RTC module at I2C address 0x68 and the clock at 0x69.

Therefore, I knew the hardware I2C communication was working correctly.

I then loaded the modified WifiTimeProviderESP8266.ino with the changed I2C GPIO addresses and serial DEBUG configured on.

Things now started working!

The debug output:

SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
Starting debug session
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 7
cnt

connected with snickerdoodle, channel 1
dhcp client start...
ip:192.168.1.98,mask:255.255.255.0,gw:192.168.1.1
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.98
Connected!
mounted file system
reading config file
opened config file
{"time_zone":" its.internet-box.ch/getTime/Europe/Zurich "}

parsed json
Loaded time server URL: its.internet-box.ch/getTime/Europe/Zurich
Closing config file
AP IP address: 0.0.0.0
IP address: 192.168.1.98
I2C master started
Scanning I2C bus
Received a response from 87
I2C <-- Received bytes (expecting 22): 22
I2C <-- Got blank hour start:
I2C Protocol ERROR! Expected header 54, but got: 255
Received a response from 104
I2C <-- Received bytes (expecting 22): 22
pected header
I2C Protocol ERROR! Expected header 54, but got: 52
Received a response from 105
I2C <-- Received bytes (expecting 22): 22
cted header
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
I2C <-- Got minDim Hi:
Leading
param:
Received a ping answer from 105
Scanning I2C bus done
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2018,01,01,0,0,0
HTTP server started
Sending time to I2C: 2019,9,3,16,38,35
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
pm open,type:2 0


Clearly SPIFFS is working fine and parameters are being sent/received. The clock shows status "13" meaning both RTC and WiFi module are recognized. I am able to get the correct status from the web interface and change parameters.

Next, I will try the NTP v2 code to see what happens.

Best regards,

Don

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #10520 by Froula
BTW, the protocol errors shown in the previous debug log stopped after the first web page refresh. All working fine now.

I have the CPU frequency on the ESP-12E set to 160 MHz.

Now, after refreshing the web server status page:

Got 24h mode param: 12h
Got blankLeading param: blank
Got useScrollback param: on
Got suppressACP param: on
Got useFade param: on
Got useLDR param: on
Got dateFormat param: 1
Got dayBlanking param: 0
Got blankFrom param:
Got blankTo param:
Got fadeSteps param: 50
Got scrollSteps param: 4
Got backLight param: 5
Got redCnl param: 15
Got grnCnl param: 0
Got bluCnl param: 0
Got cycleSpeed param: 10
Got blankMode param: 2
Got slotsMode param: 1
Got minDim param: 260
I2C <-- Received bytes (expecting 22): 22
cted header
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
w leading zero
Sending time to I2C: 2019,9,3,16,53,42
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #10521 by Froula
I loaded the v2 NTP WiFi code onto the ESP-12E connected to the v1 clock and it actually works!

The Clock server page says "Communicating with: NixieFirmwareV1, I2C v54", which is incorrect as the clock is running v56, but the debug log seems to indicate the parameter count and definitions are compatible:

SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
Starting debug session

ezTime debug level set to DEBUG
--> Set OTA Updates on
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 7
cnt

connected with snickerdoodle, channel 1
dhcp client start...
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
state: 5 -> 0 (0)
rm 0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 7
cnt

connected with snickerdoodle, channel 1
dhcp client start...
ip:192.168.1.98,mask:255.255.255.0,gw:192.168.1.1
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.98
Connected!
mounted file system for read
reading config file
opened config file
{"time_zone":" its.internet-box.ch/getTime/Europe/Zurich "}

parsed json
Loaded time server URL: its.internet-box.ch/getTime/Europe/Zurich
Loaded NTP server:
Loaded NTP timezone:
Loaded NTP interval: 0
Closing config file
Recovered Config from SPIFFS
mounted file system for read
reading config file
opened config file
{"time_zone":" its.internet-box.ch/getTime/Europe/Zurich "}

parsed json
Loaded time server URL: its.internet-box.ch/getTime/Europe/Zurich
Loaded NTP server:
Loaded NTP timezone:
Loaded NTP interval: 0
Closing config file
Recovered Config from SPIFFS
AP IP address: 0.0.0.0
IP address: 192.168.1.98
I2C master started
Scanning I2C bus
Received a response from 87
2C <-- Received bytes (expecting 1):
ate format:
I2C Protocol ERROR! Expected header 54 or 62, but got: 255
Received a response from 104
2C <-- Received bytes (expecting 1):
er:
I2C Protocol ERROR! Expected header 54 or 62, but got: 25
Received a response from 105
2C <-- Received bytes (expecting 1):
cted header
I2C <-- Received bytes (expecting 22): 22
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
leading zero
Received a ping answer from 105
Scanning I2C bus done
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2018,01,01,0,0,0
HTTP server started
Querying pool.ntp.org ... Received data:
0: 24, 2, 9, EA,
4: 0, 0, 8, BD,
8: 0, 0, 5, 85,
12: 98, 2, 85, 35,
16: E1, 18, FD, 6E,
20: C4, EC, AE, 8D,
24: 0, 0, 0, 0,
28: 0, 0, 0, 0,
32: E1, 18, FE, 83,
36: A8, 49, B5, 10,
40: E1, 18, FE, 83,
44: A8, 4D, F, FF,
success (round trip 129 ms)
Received time: Tuesday, 03-Sep-19 15:00:19.724 UTC
Set event (#1) to trigger on: Tuesday, 03-Sep-2019 15:30:20 UTC
Sending time to I2C: 2019,9,3,15,00,20
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
pm open,type:2 0
Got 24h mode param: 12h
Got blankLeading param: blank
Got useScrollback param: on
Got suppressACP param: on
Got useFade param: on
Got useLDR param: on
Got dateFormat param: 1
Got dayBlanking param: 0
Got blankFrom param:
Got blankTo param:
Got fadeSteps param: 50
Got scrollSteps param: 4
Got backLight param: 5
Got redCnl param: 15
Got grnCnl param: 0
Got bluCnl param: 0
Got cycleSpeed param: 10
Got blankMode param: 2
Got slotsMode param: 1
Got minDim param: 260
2C <-- Received bytes (expecting 1):
cted header
I2C <-- Received bytes (expecting 22): 22
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
leading zero
Sending time to I2C: 2019,9,3,15,01,21
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Got 24h mode param: 12h
Got blankLeading param: blank
Got useScrollback param: on
Got suppressACP param: on
Got useFade param: on
Got useLDR param: on
Got dateFormat param: 1
Got dayBlanking param: 0
Got blankFrom param:
Got blankTo param:
Got fadeSteps param: 50
Got scrollSteps param: 4
Got backLight param: 5
Got redCnl param: 15
Got grnCnl param: 0
Got bluCnl param: 0
Got cycleSpeed param: 10
Got blankMode param: 2
Got slotsMode param: 1
Got minDim param: 260
2C <-- Received bytes (expecting 1):
cted header
I2C <-- Received bytes (expecting 22): 22
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
leading zero
Got 24h mode param: 12h
Got blankLeading param: blank
Got useScrollback param: on
Got suppressACP param: on
Got useFade param: on
Got useLDR param: on
Got dateFormat param: 1
Got dayBlanking param: 0
Got blankFrom param:
Got blankTo param:
Got fadeSteps param: 50
Got scrollSteps param: 4
Got backLight param: 5
Got redCnl param: 15
Got grnCnl param: 0
Got bluCnl param: 0
Got cycleSpeed param: 10
Got blankMode param: 2
Got slotsMode param: 1
Got minDim param: 260
2C <-- Received bytes (expecting 1):
cted header
I2C <-- Received bytes (expecting 22): 22
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
leading zero
Sending time to I2C: 2019,9,3,15,02,22
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,15,03,23
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,15,04,24
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,15,05,25
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,15,06,26


However, the NTP setting showed blank in Time Servers tab. I manually entered the correct Posix TZ string for my area, a valid ntp pool address and suitable poll interval. It successfully began using the NTP time instead of the backup server and displayed the correct time:

Saved config
mounted file system for write
saving config
{"time_zone":" its.internet-box.ch/getTime/Europe/Zuric....0","ntp_interval":0 }

Saved config
mounted file system for write
saving config
{"time_zone":" its.internet-box.ch/getTime/Europe/Zuric...,"ntp_interval":7201 }

Saved config
Set event (#1) to trigger on: Tuesday, 03-Sep-2019 17:37:20 UTC
Timezone lookup for: America/Chicago ... (round-trip 153 ms) success.
Olson: America/Chicago
Posix: CST6CDT,M3.2.0,M11.1.0
mounted file system for write
saving config
{"time_zone":" its.internet-box.ch/getTime/Europe/Zuric...,"ntp_interval":7201 }

Saved config
Sending time to I2C: 2019,9,3,10,37,20
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,38,21
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,39,22
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,40,23
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
2C <-- Received bytes (expecting 1):
cted header
I2C <-- Received bytes (expecting 22): 22
2C <-- Got hour mode:
2C <-- Got blank lead:
2C <-- Got scrollback:
2C <-- Got suppress ACP:
2C <-- Got useFade:
2C <-- Got date format:
I2C <-- Got day blanking:
I2C <-- Got blank hour start:
I2C <-- Got blank hour end:

<-- Got scroll steps:
-- Got backlight mode:
channel:
I2C <-- Got green channel:
I2C <-- Got blue channel:
t cycle speed:
2C <-- Got useLDR:
C <-- Got blankMode:
2C <-- Got slotsMode:
2C <-- Got minDim Hi:
<-- Got minDim Lo:
leading zero
Sending time to I2C: 2019,9,3,10,41,24
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,42,25
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,43,26
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
mounted file system for write
saving config
{"time_zone":" its.internet-box.ch/getTime/Europe/Zuric...,"ntp_interval":7201 }

Saved config
Sending time to I2C: 2019,9,3,10,44,27
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,45,28
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,46,29
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,47,30
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,48,31
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,49,32
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,50,33
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98
Sending time to I2C: 2019,9,3,10,51,34
Normal time serve mode


It appears to be mostly working.

Best regards,

Don

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago - 3 months 1 week ago #10522 by Froula
I believe the reason the v2 WiFi module code is working with V1 version 56 is that,in the clock code, the:

#define I2C_PROTOCOL_NUMBER 54

Sets the protocol ID to 54 even though the software version is 56, which makes sense if there are no parameter changes from 54.

Mike's code checks the protocol number, which matches and allows the code to work:

} else if ( receivedByte == I2C_PROTOCOL_NUMBER_V1 ) {
i2cProtocol = v1v56;

Even though the "i2cProtocol" is set in Mike's code to "v1v56", the protocol rev that is tested for ( I2C_PROTOCOL_NUMBER_V1) to set that value is "54", not "56". Kind of confusing.

The "v54" displayed on the top of the web server "Clock" tab is the protocol revision, rather than the firmware version.

Slightly confusing, but explains why the v2 WiFi code works with the latest V1 clock code.

BTW, there is a WiFi server "WLAN" tab that does not work, at least with a v1 clock.

Don
Last edit: 3 months 1 week ago by Froula.

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago #10523 by jjansen

Froula wrote: It was a WiFi shield library I had installed in:

C:\Program Files (x86)\Arduino\libraries\WiFi\

Thanks, that did the trick! :D
The following user(s) said Thank You: Froula

Please Log in or Create an account to join the conversation.

More
3 months 1 week ago - 3 months 1 week ago #10524 by Froula
The debug log configuration string that I posted got mangled by the web text formatting. Here is the actual string:
Saved config
Set event (#1) to trigger on: Tuesday, 03-Sep-2019 19:27:00 UTC
Timezone lookup for: America/Chicago ... (round-trip 153 ms)  success.
  Olson: America/Chicago
  Posix: CST6CDT,M3.2.0,M11.1.0
mounted file system for write
saving config
{"time_zone":"http://its.internet-box.ch/getTime/America/Chicago","ntp_server":"0.pool.ntp.org","ntp_tz":"CST6CDT,M3.2.0,M11.1.0","ntp_interval":7205}

Saved config
Sending time to I2C: 2019,9,3,12,26,56
Normal time serve mode
Sending IP Address to I2C: 192.168.1.98

Don
Last edit: 3 months 1 week ago by Froula.

Please Log in or Create an account to join the conversation.

Moderators: AccutronTy_EeberfestIan
Time to create page: 0.341 seconds

Search

Tube Suppliers

Go to top
JSN Boot template designed by JoomlaShine.com