Skip to content

Instantly share code, notes, and snippets.

View pfeerick's full-sized avatar

Peter Feerick pfeerick

  • Australia
  • 08:28 (UTC +10:00)
View GitHub Profile
@pfeerick
pfeerick / ledStatus.ino
Created July 4, 2016 08:26
Oak MQTT test
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <string.h>
// Update with values suitable for your network.
const char* mqtt_server = "pine64";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
@pfeerick
pfeerick / pine64-battery.sh
Last active August 24, 2019 03:43
Colourful Battery Status script for Pine64 SOC board
#!/bin/bash
# See https://github.com/pfeerick/pine64-scripts/blob/master/pine64-battery-colour.sh
# for updated versions of this script.
SWITCH="\033["
NORMAL="${SWITCH}0m"
RED="${SWITCH}1;31m"
GREEN="${SWITCH}1;32m"
YELLOW="${SWITCH}1;33m"
@pfeerick
pfeerick / pine64-i2c-MCP23017-toggleLeds.sh
Last active March 6, 2022 18:43
Shell script to toggle LEDs on a MCP23017 I2C I/O expander connected to a pine64 board
#!/bin/bash
#elevate to root to ensure no permission errors
#[ `whoami` = root ] || exec su -c $0 root
if [[ $EUID -ne 0 ]]; then
echo "i2cset usually needs sudo powers to run, please login if prompted to avoid permission errors"
exec sudo $0
fi
echo "Set all Port A pins (GPA0-7) as outputs..."
@pfeerick
pfeerick / pine64-SYSLED-heartbeat.sh
Last active July 2, 2021 07:02
Shell script that makes the Pine64 System LED do a double flash heartbeat approximatley every 10 seconds
#!/bin/bash
function openGPIO
{
#test if GPIO sysfs entry exists, create if necessary
if [ ! -e "/sys/class/gpio/gpio359" ]; then
# echo "DEBUG: export 359"
echo 359 > "/sys/class/gpio/export"
fi
@pfeerick
pfeerick / nrfRx_v0.1.ino
Created September 21, 2016 11:22
Arduino script to receive a NRF24L01+ sensor on a Digistump Oak
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
//needed for printDetails
#define printf Serial.printf
#define sprintf(...) os_sprintf( __VA_ARGS__ )
#define CE_PIN 10
#define CSN_PIN 5
@pfeerick
pfeerick / oakBlinkAndPublish.ino
Last active September 30, 2016 05:10
Just s simple script to test some particle stuff on the Oak
/*
Just s simple script to test some particle stuff on the Oak
*/
// this makes the Oak only automatically connect to wifi, not particle
SYSTEM_MODE(SEMI_AUTOMATIC)
// the setup function runs once when you reset or power the board
void setup()
{
@pfeerick
pfeerick / oak-mqtt-led.ino
Created October 8, 2016 00:26
Working MQTT example for a Digistump Oak
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <string.h>
// Update with values suitable for your network.
const char* mqtt_server = "pine64";
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
@pfeerick
pfeerick / oakNRFsensorMonitorWebpage.ino
Last active October 13, 2016 11:39
Oak NRF receiver code. Generates a local web page to see latest data, and relays data to Particle as events.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <elapsedMillis.h>
@pfeerick
pfeerick / oakDoorMonitor.ino
Created October 17, 2016 04:59
Simple example for the Oak that monitors a reed switch, and publishes an event on Particle when the state changes.
/*
Door Monitor
Monitors a reed switch for an open door, and posts to particle.
Created 2 June 2016
Updated 17th October
by Peter Feerick
*/
const int LED_PIN = 1; //The LED is connected to P1 on the Oak
@pfeerick
pfeerick / oakStaticIp.ino
Last active November 12, 2016 07:30
Simple demo to show how to get a Digistump Oak to change to a Static IP. Isn't the best method, but it works.
//SEMI_AUTOMATIC mode to ensure variable is available
//Probably isn't needed if you don't use Particle.variable in your code
SYSTEM_MODE(SEMI_AUTOMATIC);
#include <ESP8266WiFi.h>
char myIpString[24];
IPAddress myIp;
void setup()