Skip to content

Instantly share code, notes, and snippets.

View dniklaus's full-sized avatar

Dieter Niklaus dniklaus

View GitHub Profile
package dn;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.io.IOException;
import java.io.InputStream;
@dniklaus
dniklaus / DoubleStrobeBlink_with_Timer.cpp
Last active June 7, 2020 18:32
Double Strobe Blink with Timer
@dniklaus
dniklaus / sqrt-heron.cpp
Last active February 24, 2020 23:21
Square Root - iterative according to Heron
#include <iostream>
using namespace std;
int main()
{
int x = 10;
double a = 1.0 * x;
double l = 1.0;
const double eps = 0.000001;
@dniklaus
dniklaus / TTN-Temperature-Decoder.js
Last active October 25, 2019 23:53
https://github.com/ERNICommunity/hnh19ech-iot sends 2 bytes to TTN: temperature [ °C ], byte[0]: integer part, byte[1]: fraction (1/100 °C)
var bytesToInt = function(bytes) {
var i = 0;
for (var x = 0; x < bytes.length; x++) {
i |= +(bytes[x] << (x * 8));
}
return i;
};
var unixtime = function(bytes) {
if (bytes.length !== unixtime.BYTES) {
@dniklaus
dniklaus / testLoraKey.cpp
Last active November 24, 2018 09:07
LoRaKey string to byte array conversion
//============================================================================
// Name : testLoraKey.cpp
// Author : nid
//============================================================================
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <stdio.h>
@dniklaus
dniklaus / test.puml
Created October 10, 2017 05:27
Test Plantuml Gist
@startuml
Alice -> Bob: test
@enduml
@dniklaus
dniklaus / Mega2560DraginoLoRaHelloWorld.ino
Last active August 31, 2017 06:16
Sending Hello World from a test node based on a Dragino LoRa Shield on a Mega2560, based on https://github.com/SensorsIot/LoRa/blob/master/Nodes/Dragino/HelloWorld/HelloWorld.ino
// MIT License
// https://github.com/gonzalocasas/arduino-uno-dragino-lorawan/blob/master/LICENSE
// Based on examples from https://github.com/matthijskooijman/arduino-lmic
// Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
// Adaptions: Andreas Spiess
#include <lmic.h>
@dniklaus
dniklaus / Feather9x_RX.ino
Created July 22, 2017 04:34
Adafruit Feather M0 LoRa, Basic RX & TX example, Receiver example code, source: https://learn.adafruit.com/adafruit-feather-m0-radio-with-lora-radio-module/using-the-rfm-9x-radio#
// Feather9x_RX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (receiver)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_TX
#include <SPI.h>
#include <RH_RF95.h>
@dniklaus
dniklaus / Feather9x_TX.ino
Last active July 22, 2017 04:31
Adafruit Feather M0 LoRa, Basic RX & TX example, Transmitter example code, source: https://learn.adafruit.com/adafruit-feather-m0-radio-with-lora-radio-module/using-the-rfm-9x-radio#
// Feather9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_RX
#include <SPI.h>
#include <RH_RF95.h>