Skip to content

Instantly share code, notes, and snippets.

@Lukelectro
Lukelectro / read-sds011-data.sh
Created June 6, 2019 17:56 — forked from marians/read-sds011-data.sh
How to read data from SDS011 sensor via USB serial connection, from http://opengeiger.de/Feinstaub/FeinstaubDatenLogger.pdf
#!/bin/bash
# Anpassung für big endian unter RHEL 7
WDIR=~
while true; do
stty -F /dev/ttyUSB0 9600 raw
INPUT=$(dd conv=swab bs=10 count=1 </dev/ttyUSB0 2>/dev/null | od -x -N10 |head -n 1|cut -f2-10 -d" ");
#Ausgabe
#echo $INPUT
@Lukelectro
Lukelectro / mainsspy_main.c
Created December 31, 2018 13:28
work in progress. Sensor that monitors mains voltage / wheter a appliance is turned off or not, sends ID every nn s and/or goodbye at powerdown.
// MainsSensor.
// doel: op zuinige attiny (attiny10? attiny45?) bij opstarten en elke paar minuten op 433Mhz eigen ID zenden, en bij wegvallen van de voeding een afmeldbericht sturen (Met de energie uit een elco) met datzelfde ID.
// PORTB1 data output
// PORTB2 = INT0 watch powerloss (same pin on both t45 and t10)
#define t45
//#define t10
// TODO: Please note: do not forget to edit the makefile as well when changing MCU between attiny45 and attiny10 (in 2 places), and when using t45, set its fuses correctly.
#include <ctype.h>
const int sp = 0; // speaker pin
char tekst[] = "pas wijze lynx bezag vroom het fikse aquaduct 1234567890"; // test tekst
const int mlen = 80; // morse length
void setup() {
// put your setup code here, to run once:
pinMode(sp,OUTPUT);
/*
Basic ESP8266 MQTT example, editted for "Grote Schakelaar". REMINDER: PAS DE NETWERKINSTELLINGEN AAN! En zet de topics goed. (En soldeer even een bordje maar dat is minder vergeetbaar)
It connects to an MQTT server then:
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary
- If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
else switch it off
- Publishes to a topic set below a value set below (hardcoded)
#define STEPSPERROT (200)
#define MICROSTEPS (16)
#define INTERVALS (512)
#define MAGNETIZETIME (200) // miliseconds the magnet is powered. Hint from Aart: short, high current pulses (dump a capacitor) work best.
#define LEDPIN 17 // not 13 on pro micro, but 17
//#define DEBUG
#define FULLROTSTEPS (STEPSPERROT*MICROSTEPS)
#define STEPSPERINTERVAL (FULLROTSTEPS/INTERVALS)
@Lukelectro
Lukelectro / randomgepruts.ino
Created November 5, 2017 20:01
Attempt at random number generation with noise from last bit of ADC read, for seeding pseudorandom generator. For STM32F103 board.
#define debug
void setup() {
// put your setup code here, to run once:
//analogReadResolution(12); // STM32F103, 12 bits adc resolution // Allwrong, this should work but doesn't. Fortunately, in contrast to documentation, a 12 bit result turns out te be the default on this board.
if(Serial);
}
void loop() {
// put your main code here, to run repeatedly: