INT 21h

Hi, I am Vladimir Smagin, SysAdmin, DevOps and barely good guy. Telegram Email / GIT / Микроблог / Thingiverse / GPG

NTP driven clock on ESP8266 and TM1640 (+ отдельная версия для Томска с погодой)

№ 9710 В разделах: Программирование Электроника ESP8266 от February 4th, 2019,

About 8 years ago I created wall clock with bluetooth synced time. Ok, its enough. Lets go to modern world with universal wifi driven devices! Today I trashed old AVR microcontroller from wall clock and used esp8266. 8 MHz and 80MHz… feel difference! At first steps I used ESP-12 NodeMCU module to develop and debug firmware. You can do final device with this module if you absolutely novice in mcu programming, if not you can do it with ESP-01 module.

If you want get own weather from service like OpenWeatherMap use xml library, look here example.

Do not forget turn on SPIFFS 1M option in Arduino IDE. At first run device will turn on own AP with configuring interface, connect it to your wifi network. With ESP-01 modules vendored by Puya problem, SPIFFS is not accessible! Saving parameters works only with ESP-12. This problem must be solved in future SDK versions.

Download source code

Wiring for NodeMCU ESP-12 development board

Wiring for ESP-01 board

Final device after moving to ESP-01

Checkout my another clock projects:

Нет комментариев »

GIT: sign your commit with GPG

№ 9363 В разделах: Администрирование Программирование от September 4th, 2018,

Yes, you can sign your commits! GIT supports it out of the box.

Sample signed commit
At first, create your secret and public keys, I wrote earlier about it (for english speaking users).

Check your keys gpg --list-keys

Add your fingerprint to your git configuration

$ git config --global user.signingkey A37721C3

Now you can sign your commits!

$ git commit -a -S -m 'fixed bugs, added new'

Here you can read full git documentation about this great feature.

Нет комментариев »

Python: Нахождение тренда

№ 9343 В разделе "Программирование" от September 3rd, 2018,

Код создаст CSV файл, который можно открыть в табличном редакторе. Код взят отсюда и чуток дополнен. Еще о трендах можно прочитать здесь.

import csv

def linreg(X, Y):
    return a,b in solution to y = ax + b such that root mean square 
    distance between trend line and original points is minimized
    N = len(X)
    Sx = Sy = Sxx = Syy = Sxy = 0.0
    for x, y in zip(X, Y):
        Sx = Sx + x
        Sy = Sy + y
        Sxx = Sxx + x*x
        Syy = Syy + y*y
        Sxy = Sxy + x*y
    det = Sxx * N - Sx * Sx
    return (Sxy * N - Sy * Sx)/det, (Sxx * Sy - Sx * Sxy)/det

x = [12, 34, 29, 38, 34, 51, 29, 34, 47, 34, 55, 94, 68, 81]
a,b = linreg(range(len(x)),x)  #your x,y are switched from standard notation

extrapolatedtrendline=[a*index + b for index in range(len(x))]

with open('open_in_calc.csv','w') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)

Нет комментариев »


Fortune cookie: I figure that if God actually does exist, He's big enough to understand an honest difference of opinion. -- Isaac Asimov