Skip to content

Instantly share code, notes, and snippets.

@ebith
ebith / main.cpp
Created Jan 1, 2021
M5 ATOM(ESP32)で温度・湿度・気圧(BME280)をInfluxDBに投げるやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <FastLED.h>
#include <Adafruit_BME280.h>
#include <InfluxDbClient.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / main.cpp
Last active Dec 31, 2020
M5 ATOM(ESP32)でWiFiに常時接続してHTTP POSTするやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <FastLED.h>
#include <ArduinoJson.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / main.cpp
Created Nov 30, 2020
ATOM Liteで作るPCの電源スイッチ
View main.cpp
#include <Arduino.h>
#include <WiFi.h>
#include <FastLED.h>
#include <WebServer.h>
#include <ESPmDNS.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
static CRGB leds[NUM_LEDS];
@ebith
ebith / app.ini
Last active Oct 22, 2020
Keypirinha configuration
View app.ini
[main]
scan_desktop = no
scan_env_path = no
@ebith
ebith / main.cpp
Last active Jan 4, 2021
M5 ATOM(ESP32)でインターホンが押されたらDiscordに通知を飛ばすやつ
View main.cpp
#define FASTLED_INTERNAL
#include <Arduino.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <FastLED.h>
#include <ArduinoJson.h>
const int NUM_LEDS = 1;
const int LED_PIN = 27;
@ebith
ebith / ntp.bat
Created Mar 15, 2020
“Windows 10で時刻同期を完璧にする方法 お前らのやり方は間違っている - Windowsは好きですが何か” http://kfujieda.hatenablog.com/entry/2020/03/14/214544
View ntp.bat
sc triggerinfo w32time start/networkon stop/networkoff
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v NtpServer /d ntp.nict.jp,0x8 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v UpdateInterval /t REG_DWORD /d 100 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v PhaseCorrectRate /t REG_DWORD /d 7 /f
pause
@ebith
ebith / batteryCapacity.py
Last active Aug 4, 2019
mackerel plugin for UPS-Lite
View batteryCapacity.py
#!/usr/bin/env python3
import time
import smbus
i2c = smbus.SMBus(1)
addr=0x36
data = i2c.read_i2c_block_data(addr, 0x04, 2)
capacity = int((data[0] << 8 | data[1]) / 256)
print(f'battery.capacity\t{capacity}\t{time.time()}')
@ebith
ebith / light.sh
Created Apr 20, 2019
暗いときは30秒だけ明かりをつけるOctoPrint用スクリプト
View light.sh
#!/bin/sh
hour=$(date +%H)
if [ "$hour" -lt 9 ]; then
exit
fi
mean=$(curl -s "http://localhost/webcam/?action=snapshot" | identify -format "%[mean]" jpg:- | cut -d . -f 1)
if [ "$mean" -lt 1000 ]; then
curl -s "http://192.168.0.82:42897/api/light/on"
@ebith
ebith / .env
Created Apr 5, 2019
OctoPrintとスマートプラグをオンオフするスクリプト
View .env
PLUG_HOST=192.168.0.30
OCTOPI_HOST=octopi.local
API_KEY=
View savebackupMHW.bat
@powershell -NoProfile -ExecutionPolicy Unrestricted "$s=[scriptblock]::create((gc \"%~f0\"|?{$_.readcount -gt 1})-join\"`n\");&$s" %*&goto:eof
$dest = $env:USERPROFILE + '\dropbox\'
$src = 'C:\Program Files (x86)\Steam\userdata\******\582010\remote\'
While ($true) {
$saveGame = Get-ChildItem $src -Recurse | Where-Object {$_.Name -eq 'SAVEDATA1000'}
$latestBackup = Get-ChildItem $dest | Sort-Object LastWriteTime -Descending | Select-Object -first 1
if ($saveGame.LastWriteTime -gt $latestBackup.LastWriteTime) {
Copy-Item $saveGame.FullName ($dest + (Get-Date -Format yyyy-MMdd-HHmmss) + '-SAVEDATA1000')