Programming a DS1307 clock

If doesn't fit into any other category ....
Post Reply
Marv
Posts: 11
Joined: Mon Feb 08, 2021 6:09 pm

Programming a DS1307 clock

Post by Marv »

I have an ESP8266 running in AP mode 192.168.4.1 the OPTION.NTPSYNC in the config file does not respond properly.
would like to know why? or if I am doing something wrong very weak on wifi.
so I installed a DS1307 clock and tried all combinations of i2c with no avail to read the clock. I need to write tothe clock using variables so as to compare the variable and go to a label when the variables match. the RTC.time$ works fine but can not obtain any variables for Hours, Minutes. Seconds. I am using this code for obtaining BCD info for the variables.

Hrs, Mn, Ss

Hxbcd:
d = int(value / 10 )
wlog "D",hex$(d)
d1 = d * 10
wlog "D1",hex$(d1)
d2 = value - d1
wlog "D2",hex$(d2)
value = d*16 + d2
wlog "Val",bin$(Value)
return

Write_clock:
I2c.begin &hD0
I2c.write &h00
I2c.write Ss
I2c.write Mn
I2c.write Hrs
I2c.End

Write_Clock:
'write_Array(0)=Ss
'write_Array(1)=Mn
'write_Array(2)=Hrs
I2C.WriteRegArray &hD0 , &h00, 3 , write_Array()
I2c.end
Stat = I2C.end
Stat reads 2
read_Clock:
i2c.begin &hD0
i2c.write &h00
i2c.end
i2c.begin &hD1
Ss = I2C.read
Mn = I2C.Read
Hrs = I2C.read
i2c.end
read_Clock:
I2C.ReadRegArray &hD1 , &h00, 3 , Read_Array()
I2c.end
Stat reads 2
Need some help to set me strait to see if this is possible to do. I noticed there is no way for Annex to read an Acknowledge input.
Thanks Marv
User avatar
Electroguard
Posts: 860
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 276 times
Been thanked: 323 times

Re: Programming a DS1307 clock

Post by Electroguard »

Hi Marv,
The device is using IP address 192.168.4.1 therefore it is not logged on to your wifi router subnet, therefore it cannot access the internet, so the internet command option.ntpsync cannot work.
Marv
Posts: 11
Joined: Mon Feb 08, 2021 6:09 pm

Re: Programming a DS1307 clock

Post by Marv »

That is what I thought thanks electroguard for verifying that for me.
Marv
Post Reply