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 git.blindage.org/commit/e1a24a6814082efb74cbad924c68a40b505f4e74
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)
    spamwriter.writerow(x)
    spamwriter.writerow(extrapolatedtrendline)

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

Микроблог перейти

# 2019-05-16 15:02:51

Для установки временной зоны из консоли одной командой в Ubuntu придумали sudo timedatectl set-timezone Europe/Moscow, но можно и через Ansible модулем timezone docs.ansible.com/ansible/lates

# 2019-04-14 20:17:08

Офигенный проект бортового компьютера на Rasperry Pi www.drive2.ru/b/3013396/ Жаль дороговат получается, проще за 500 рублей купить OBDII свисток с вайфаем и подключать его к телефону.

# 2019-04-05 19:15:52

О фреймворке Celery и его применении, очень полезная штука при организации очередей habr.com/ru/company/oleg-bunin


© Vladimir Smagin, 2005-2019. Копирование материалов без разрешения запрещено. GPG DA4CD0F5E222EA727D6A40C413BCE12E5618F071 *
Яндекс.Метрика

Fortune cookie: Send your questions to ``ASK ZIPPY'', Box 40474, San Francisco, CA 94140, USA