Search for Lua script for a simple Time Clock with esp8266 and a 8 Dig 7 Segment

Hallo anybody,
i have experimented with my new esp8266 (Lolin V3) and a 8Dig 7 Segment Modul (Max7219).
Its worked fine!
But i found only Demo scripts with blinking and so.
I need a simple code for a Time Clock a' la "H - M - S"

I have also experimented with raspberry pi and there i have a solution!
But is it in PYTHON :frowning: and i dont want raspi.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Richard Hull and contributors

import time
from datetime import datetime

from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.virtual import viewport, sevensegment

def clock(seg):

    interval = 0.5
    for format in cycle(["%H-%M-%S", "%H %M %S"]):
        now = datetime.now()
        seg.text = now.strftime(format)
        time.sleep(interval)

def main():
    # create seven segment device
    serial = spi(port=0, device=0, gpio=noop())
    device = max7219(serial, cascaded=1)
    seg = sevensegment(device)

    # Digit futzing
    clock(seg)

if __name__ == '__main__':
    main()

Can anybody help me please. And sorry for my bad english.

Thanks

There are Internet clock examples included in the ESP88266 libraries.
Also Arduino Playground - MAX72XXHardware

Thanks!
There is many examples but nothing with Time and for a 7Segment with Max7219

Use NTP to get the time: This example prints the time to the Serial monitor.
Then use a library to drive your MAX chips: This library allows you to print numbers to 7-segment displays.
Combine the two, and you're done.

Pieter

OK many Thanks, i will try it :slight_smile:

The first try is work. :smiley:

1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
⸮HP⸮⸮⸮`fS[⸮$⸮⸮G⸮TimeNTP Example
Connecting to Robis iPhone6s
......IP number assigned by DHCP is 172.20.10.8
Starting UDP
Local port: 8888
waiting for sync
Transmit NTP Request
ptbtime1.ptb.de: 192.53.103.108
Receive NTP Response
17:16:26 16.8.2017
17:16:27 16.8.2017
17:16:28 16.8.2017
17:16:29 16.8.2017
17:16:30 16.8.2017
....