Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens Chr Brynildsen jenschr

View GitHub Profile
View SoftwareSerialPassthrough.ino
#include <SoftwareSerial.h>
// RX, TX on Arduino
SoftwareSerial mySerial(8, 9);
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
View SoftwareSerialPassthrough2.ino
#include <SoftwareSerial.h>
// RX,TX on Arduino
SoftwareSerial mySerial(8, 9);
void setup()
{
Serial.begin(38400);
mySerial.begin(38400);
}
@jenschr
jenschr / LoRaEnviroNode.ino
Created Nov 24, 2016
LoRa Feather M0 with extra serial (CO2 sensor on Serial2 + DHT11)
View LoRaEnviroNode.ino
#include <Arduino.h> // required before wiring_private.h
#include "wiring_private.h" // pinPeripheral() function
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTTYPE DHT11
#define DHTPIN 5
int ppm = 0;
View WatchdogTestWICED.ino
/*
* This example shows that the WICED is not capable of
* recovering from a network fallout. It will keep
* returning the error:
*
* SDEP_CMD_TCP_WRITE failed, Error: NOTUP (9)
*
* even if it can reconnect.
*
* To test - update wifi-credentials below and connect
@jenschr
jenschr / WICED_reconnect_test.ino
Created Jul 25, 2017
Test script for checking if the WICED is able to reconnect when a connection is lost
View WICED_reconnect_test.ino
/*
* This example shows that the WICED is not capable of
* recovering from a network fallout. It will keep
* returning the error:
*
* SDEP_CMD_TCP_WRITE failed, Error: NOTUP (9)
*
* even if it can reconnect.
*
* To test - update wifi-credentials below and connect
View Feather LoRa Client (that actually works)
/*
Basic client for Adafruit Feather LoRa radios.
This is based on the RadioHead library for RF95, but has all
the required pins and setup for Feather LoRa's.
NOTE: You need to select a unique radio address for this to work
*/
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
View Feather LoRa Server (that actually works)
/*
Basic server for Adafruit Feather LoRa radios.
This is based on the RadioHead library for RF95, but has all
the required pins and setup for Feather LoRa's.
NOTE: Each client needs a unique radio address for this to work
*/
#include <RHReliableDatagram.h>
#include <RH_RF95.h>
@jenschr
jenschr / mBot_Siren.ino
Created Apr 3, 2018
Simple code snippet to blink lights and produce a siren for Makeblock's mBot. Please credit if re-distributing this code
View mBot_Siren.ino
// Simple code snippet to blink lights and produce a siren for Makeblock's mBot.
// Author: @jenschr / Jensa
// Please credit if re-distributing this code
#include <MeMCore.h>
MeRGBLed rgb(PORT_7);
int highestPitch = 3500;
int lowestPitch = 640;
int toneRightNow = lowestPitch;
boolean isTheToneMovingUpwards = true;
@jenschr
jenschr / ParticleDetect.sh
Last active Apr 6, 2018
Script to automate the setup of multiple Particle devices (Photon, P1, P0, Electron)
View ParticleDetect.sh
#!/bin/sh
# Basic setup script for devices
# Works on OSX + should also work for Unix.
# Users of Windows 10 (or higher) can likely use the builtin Ubuntu install.
#
# We need to do the following:
# 1. Query the computer for the relevant USB port
# 2. Set the device to listening mode (if required)
# 3. Query the device for the deviceID
@jenschr
jenschr / wait.js
Created Jun 26, 2018
Generic Javascript wait/delay function
View wait.js
// Generic wait-function. I use this to throttle MQTT connections.
// Only use this when you want to do absolutely NOTHING while waiting.
// If you need something to be done while waiting, consider putting what
// you want done inside the while-loop :)
// uncomment the console.log calls to see debug output
var wait = function(startTime){
var d = new Date();
var millis = d.getTime();
var stopAt = millis+(startTime*1000);