Skip to content

Instantly share code, notes, and snippets.

View nobodyguy's full-sized avatar

Jan nobodyguy

  • ExpertaLabs
  • Brno, Czech Republic
View GitHub Profile
@nobodyguy
nobodyguy / printer_monitor.js
Last active February 13, 2024 17:03
Shelly Plus Plug S script to automatically turn off the plug after 3D printing has finished and cooling delay has elapsed
// This script detects printing start and stop events based on power consumption.
// When the stop event is detected, it waits for 15 minutes to enable printer to cool down and shutdown event is triggered.
let CONFIG = {
cooldownDelay: 15 * 60 * 1000, // 15 minutes
idlePowerMax: 12, // 12 Watts (in reality 7-8W)
};
let cooldownTimer = null;
let printingStarted = false;
@nobodyguy
nobodyguy / instructions.md
Created November 27, 2021 22:48
How to turn BlackPillV2 into BMP
  1. Compile blackmagic firmware according to this guide https://github.com/blacksphere/blackmagic/blob/master/src/platforms/f4discovery/Readme.md#alternate-build-for-stm32f401-stm32f411-minif4-aka-blackpillv2-boards (make PROBE_HOST=f4discovery BLACKPILL=1)
  2. Connect the board to your computer while holding BOOT0 and NRST buttons to boot into STM32 bootloader
  3. Execute these commands to unlock the board and flash BMP firmware:
dfu-util --list
dfu-util -a 0 --device XXX:XXX --dfuse-address 0x08000000 -D ./src/blackmagic.bin -s :unprotect:force
dfu-util -a 0 --device XXX:XXX --dfuse-address 0x08000000 -D ./src/blackmagic.bin
@nobodyguy
nobodyguy / controller.ino
Last active September 27, 2023 18:14
Arduino PID controller with relay and DS18B20
#include <PID_v1.h>
// Libraries for the DS18B20 sensor
#include <OneWire.h>
#include <DallasTemperature.h>
// DS18B20 on PIN 6 on the Arduino
#define ONE_WIRE_BUS 6
//Solid state relay on PIN 5 on the Arduino
@nobodyguy
nobodyguy / tracker.ino
Last active September 21, 2022 03:13
GpsLoRaWANTracker using Arduino, RN2483 and L86/neo-m8n GPS module
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <avr/sleep.h>
#include <avr/power.h>
// ----------------------------------------------
// DEFINES
// ----------------------------------------------
#define rxGpsPin 10
#define txGpsPin 11
@nobodyguy
nobodyguy / testNode.ino
Last active January 18, 2017 14:35
RFM69CW basic sleeping node - reports static payload every 1 minute
//*********************************************************************************************
// Sample RFM69 sender/node sketch, with ACK and optional encryption, and Automatic Transmission Control
// Sends periodic static messages to gateway (id=1)
//*********************************************************************************************
#include <RFM69.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h> //included with Arduino IDE install (www.arduino.cc)
#include "LowPower.h"
//*********************************************************************************************
@nobodyguy
nobodyguy / temp.ino
Created January 10, 2017 13:07
DHT22 OLED temperature
#include <DHTSensor.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
DHTSensor sensor(7);//Will be using pin3 for collecting the data
@nobodyguy
nobodyguy / wateringSystem.ino
Last active September 25, 2015 21:53
Watering system using Arduino, soil humidity sensor and 3-6V water pump. Checking for humidity is done every 24 hours.
const int sensorPin = A0;
const int sensorPowerPin = 4;
int sensorValue = 0;
const int transistorPin = 5;
const long sleepTime = 86390000; // 24 hours - 10 seconds
const int wateringTime = 10000; // 10 seconds
const int drySoil = 400;
printf("Temperature table:\n\n\t ");
n=0;
while (mon[n]!='\0')
{
if (mon[n]==',')
printf(" ");
else
printf("%c", mon[n]);
n++;
@nobodyguy
nobodyguy / http_server.ps1
Last active July 9, 2022 15:09
Powershell HTTP server in background thread (could be easily killed)
$ServerThreadCode = {
$listener = New-Object System.Net.HttpListener
$listener.Prefixes.Add('http://+:8008/')
$listener.Start()
while ($listener.IsListening) {
$context = $listener.GetContext() # blocks until request is received
$request = $context.Request
@nobodyguy
nobodyguy / gist:9936036
Last active August 29, 2015 13:58
PowerShell HTTP server with forced 500 response code
$listener = New-Object System.Net.HttpListener
$listener.Prefixes.Add('http://+:8000/') # Must exactly match the netsh command above
$listener.Start()
Write-Host "Listening..."
while ($listener.IsListening) {
$context = $listener.GetContext() # blocks until request is received
$request = $context.Request