Skip to content

Instantly share code, notes, and snippets.

@sigmdel
sigmdel / cputemp.py
Last active October 24, 2024 17:19
Python script to forward a thermal zone temperature to Domoticz, with e-mail notification when the temperature is over a threshold.
#!/usr/bin/python3
# coding: utf-8
# Python script to read the CPU temperature and send the results to
# a Domoticz server. Meant to be executed by cron at regular intervals.
#
#
# Requires: Python 3
#
# Version: 2.1
@sigmdel
sigmdel / test-vlan.sh
Created May 24, 2024 20:22
Bash script to create or delete a VLAN in Linux
#!/bin/bash
#
# Bash script to create or delete a VLAN in Linux
# Tested in Linux 5.15.0-107 x86_64
#
# Must be root to execute
#
# Reference: archlinux VLAN @ https://wiki.archlinux.org/title/VLAN
@sigmdel
sigmdel / dnswanip.sh
Created January 19, 2024 23:42
Bash script to obtain the WAN IP address of a router from some DNS name servers
#!/usr/bin/bash
# Obtain WAN IP address with DNS Query
# List of command line parameters for the host command
#
NameServers=("-4 myip.opendns.com resolver1.opendns.com"
"-c ch -t txt -4 whoami.Cloudflare 1.1.1.1"
"-t txt o-o.myaddr.l.google.com ns1.google.com"
"-4 whoami.akamai.net ns1-1.akamaitech.net")
@sigmdel
sigmdel / getwanipre.sh
Last active January 19, 2024 23:38
Bash script to obtain the WAN IP address of a router from a list of "what is my IP?" type of Web sites
#!/usr/bin/bash
# List of "What is my IP?" type of Web sites to test
#
MyIpSites=("ifconfig.me/ip
v4.ident.me
api.ipify.org
ipinfo.io/ip
ipecho.net/plain
myip.dnsomatic.com
@sigmdel
sigmdel / getwanipre.py
Last active January 19, 2024 23:39
Python 3 script to obtain the WAN IP address of a router from a list of "what is my IP?" type of Web sites
#!/usr/bin/python3
# coding: utf-8
# List of "What is my IP?" type of Web sites to test
#
MyIpSites = ['ifconfig.me/ip',
'v4.ident.me',
'api.ipify.org',
'ipinfo.io/ip',
'ipecho.net/plain',
@sigmdel
sigmdel / us2stamp.cpp
Created June 5, 2023 21:19
Convert microseconds to 32 bit fraction of a second (for conversion of timeval struct to 64 bit NTP timestamp)
/*
How to convert microseconds to 32 bit fraction of a second. This
calculation is needed when converting a struct timeval to an
NTP 64 bit timestamp.
Four methods are tested with four ESP32 processors. Here
uint32_t y_us is the microseconds input
uint32_t x is the 32 bit fraction of a second ouput
@sigmdel
sigmdel / restart.cpp
Last active February 3, 2023 03:14
ESP8266 - Forget Wi-Fi credentials (network SSID and passkey)
// ESP8266 - Forget Wi-Fi credentials (network SSID and passkey)
// Both
// WiFi.disconnect(true); or (false) // as per https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/station-class.html#disconnect
// WiFi.begin("0","0"); // as per https://github.com/espressif/arduino-esp32/issues/400#issuecomment-411076993
// did not forget Wi-Fi credentials.
// Erasing the station configuration as shown below works.
//
// Tested with platformio/platform-espressif8266 version 4.1.0 based on
// esp8266/Arduino Release 3.1.0 (NONOS SDK 3.0.5)
//
@sigmdel
sigmdel / internet_watchdog.ino
Last active April 12, 2020 18:57
ESP8266 Internet watchdog using AsyncPing
/*
internet_watchdog.ino
Continuous testing with an ESP8266 that the Internet is reachable through a Wi-Fi router.
Uses AsyncPing by akaJes @ https://github.com/akaJes/AsyncPing and is based on its example
ping_interval.ino sketch.
April 10, 2020 Michel Deslierres <https://sigmdel.ca/michel>