This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SmartHome by Rafał ;) | |
Przełącznik (przekaźnik) sterowany przez WiFi (MQTT, Google Home). | |
Cechy: | |
– obsługa protokołu MQTT (biblioteka PubSubClient: https://pubsubclient.knolleary.net/); | |
– podłączenie do Google Home realizowane przez gBridge (https://gbridge.kappelt.net/device) z wykorzystaniem lokalnego mostka | |
(RaspberryPi 1 + Mosquitto 1.4) ze względu na brak obsługi TLS w Arduino (patrz: dokumentacja gBridge); | |
– platforma sprzętowa: Arduino UNO + Ethernet Shield (W5100) + moduł DIY z przekaźnikiem RM96P-5-W; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
from io import BytesIO | |
from sys import argv | |
from pycurl import Curl, error | |
# Pozyskiwanie zewnętrznego adresu IP | |
# Adres użyty jako parametr domyślny zwraca wiersz CSV – drugie pole to nasz zewnętrzny IP | |
def get_ip(url_api = 'http://ip4only.me/api/'): | |
my_ip = BytesIO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
from io import BytesIO | |
from sys import argv | |
from pycurl import Curl, error | |
# Pozyskiwanie danych producenta karty sieciowej o wskazanym adresie sprzętowym MAC | |
def get_mac_vendor(mac_address, url_api = 'https://macvendors.co/api/', result_form = '/csv'): | |
vendor_result = BytesIO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pycurl import Curl | |
from pycurl import error | |
from io import BytesIO | |
# Pozyskiwanie zewnętrznego adresu IP | |
# Adres użyty jako parametr domyślny zwraca wiersz CSV – drugie pole to nasz zewnętrzny IP | |
def get_ip(url_api = 'http://ip4only.me/api/'): | |
my_ip = BytesIO() | |
c = Curl() | |
c.setopt(c.URL, url_api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
#include <Timer.h> | |
#define N 2 | |
#define S 1000 | |
Timer t; | |
int sekundy = 0; | |
int minuty = 0; | |
int godziny = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Timer.h> | |
#define N 2 | |
#define S 1000 | |
Timer t; | |
int sekundy = 0; | |
int minuty = 0; | |
int godziny = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
from io import BytesIO | |
from pycurl import Curl | |
from pycurl import error | |
import urllib.parse | |
# Pozyskiwanie globalnego adresu IP | |
# Adres użyty jako parametr domyślny zwraca wiersz CSV – drugie pole to nasz globalny IP | |
def get_ip(url_api = 'http://ip4only.me/api/'): | |
my_ip = BytesIO() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
#define CZAS 100 | |
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; | |
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); | |
void show_monkey(byte x, byte y, int time_disp) { | |
lcd.setCursor(x, y); | |
lcd.print("@"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Równianie kwadratowe – wersja 1, prosta | |
from math import sqrt | |
print("Rozwiązywanie równiania kwadratowego") | |
a = float(input("Podaj wartość a: ")) | |
b = float(input("Podaj wartość b: ")) | |
c = float(input("Podaj wartość c: ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
# – powyższy wiersz dodajemy, gdy chcemy wymusić na Pythonie przetwarzanie pliku w określonej stronie kodowej; | |
# koniecznie trzeba go dodać w programach dl Pythona 2; opcjonalny dla Pythona 3 – domyślne kodowanie w tej wersji | |
# to właśnie UTF-8. | |
# Lista | |
filmy = ['Wejście smoka','Władca pierścieni','Hobbit','Underworld','Nieustraszeni zabójcy wampirów','Dolce Vita'] | |
# Wypisanie zawartości listy | |
for tytul in filmy: |