Skip to content

Instantly share code, notes, and snippets.

Avatar

Phill Paraphraser

  • Cootamundra NSW Australia
View GitHub Profile
@Paraphraser
Paraphraser / IOTstackNextCloud.md
Last active Jun 10, 2021
Getting Nextcloud to work under IOTstack
View IOTstackNextCloud.md

Getting Nextcloud to work under IOTstack

docker-compose.yml fragment

This is a docker-compose.yml that works on my Raspberry Pi 4B. Either use it as-is or copy everything except the first four and last 13 lines to the clipboard, then paste them into your existing docker-compose.yml, replacing any previous definitions for "nextcloud" and "nextcloud_db".

version: '3.6'

services:
@Paraphraser
Paraphraser / power_monitor_poc.md
Last active Jun 3, 2021
UPS monitor - back end - proof of concept
View power_monitor_poc.md

UPS monitor - back end - proof of concept

Assumptions

  • There exists a mechanism (unspecified) for acquiring status information from an Uninterruptible Power Supply;
  • That mechanism is available to Node-RED; and
  • There exists a Node-RED flow (unspecified) that is capable of interpreting the UPS status information and making decisions about when devices should power down and in what order.

Task Goal

@Paraphraser
Paraphraser / RPiWiFiFreeze.md
Last active Jun 1, 2021
Does your Raspberry Pi's Wireless Interface freeze? This may solve it.
View RPiWiFiFreeze.md

Does your Raspberry Pi's Wireless Interface freeze?

My Raspberry Pi 4 kept losing its wlan0 interface. I could usually reconnect via Ethernet but, from time to time, I noticed that the eth0 interface would also go walkabout.

I tried a lot of things but the one described here seems to have cured the problem. I have no idea why it works. It just does.

Step 0 - are you a Windows user?

The script shown in the next step should be created on your Raspberry Pi. Please do not make the mistake of selecting the text, copying it into a text editor on your Windows machine, saving the file, and then moving the file to your Raspberry Pi. Unless you take precautions, Windows will add its 0x0d 0x0a (CR+LF) line endings and those will stop the script from working properly on your Raspberry Pi.

@Paraphraser
Paraphraser / Enabling UDP support in InfluxDB.md
Last active May 21, 2021
Enabling UDP support in InfluxDB for SensorsIot/IOTstack
View Enabling UDP support in InfluxDB.md

Tutorial: Enabling UDP support in InfluxDB

Assumptions:

  • you are running SensorsIot/IOTstack with InfluxDB as one of the containers
  • you want to enable UDP support
  • your goal is to log traffic arriving on UDP port 8086 into an InfluxDB database named "udp".

This tutorial is specific to SensorsIot/IOTstack. You're on your own if you "get creative" and choose different ports or database names.

@Paraphraser
Paraphraser / Node-Red IOTstack hints.md
Last active May 13, 2021
Hints: Running Node-Red in IOTstack
View Node-Red IOTstack hints.md
@Paraphraser
Paraphraser / Using the PiHole container as your container DNS.md
Last active May 4, 2021
IOTstack - Using the PiHole container as your container DNS
View Using the PiHole container as your container DNS.md

IOTstack - Using the PiHole container as your container DNS

First, a small bit of editorialising (my gist, my rules). PiHole is an excellent ad-blocker. It's perfectly OK for just about every other device on your home network to use PiHole as its primary DNS.

The one device in your network that shouldn't use PiHole-in-a-container for its DNS is the Raspberry Pi running PiHole in a Docker container. I'll go so far as to describe it as a seriously dumb idea.

Why? Several reasons:

  • Containers start quite late in the boot cycle. Any process starting before Docker that depends on the DNS being "there" can be disappointed. PiHole being late to the party and occasionally disappearing when you do perfectly ordinary things like…
  • … Taking down your stack can trigger resolver failover conditions which don't always recover gracefully. You might think your DNS setup is working just fine with the PiHole container in the prime role but then it all turns to custard and you don't know why.
@Paraphraser
Paraphraser / IOTstackPullRequest.md
Last active Apr 19, 2021
Preparing IOTstack Pull Requests
View IOTstackPullRequest.md

Preparing a Pull Request for IOTstack

If you want to fix a bug or propose an enhancement for IOTstack, you will need to prepare a Pull Request (PR).

Please don't try to do anything in this gist inside an ~/IOTstack folder on a Raspberry Pi that is also being used to run your Docker containers. It's easy to get confused and you could accidentally break your own working IOTstack.

You can do everything on the same Raspberry Pi that is running your IOTstack but it's usually easier to work on a desktop or laptop. If you accept this advice, there's no risk of breaking your running IOTstack.

This guide barely scratches the surface of Pull Requests. There is lots of advice on GitHub and Google will find plenty of hits for any question you might have.

@Paraphraser
Paraphraser / InfluxDB security under IOTstack.md
Last active Feb 26, 2021
Enabling authentication in InfluxDB for SensorsIot/IOTstack
View InfluxDB security under IOTstack.md

Tutorial: Enabling authentication in InfluxDB

Assumptions:

  • you are running SensorsIot/IOTstack with InfluxDB as one of the containers
  • you want to enable authentication for your InfluxDB databases.

Note: This tutorial is specific to SensorsIot/IOTstack.

Definition:

@Paraphraser
Paraphraser / CalculatingBarometricPressureTrend.md
Last active Jan 2, 2021
Calculating barometric pressure trend
View CalculatingBarometricPressureTrend.md

Calculating barometric pressure trend

This gist is a response to a Discord question. It explains my approach to deciding whether barometric pressure is rising, falling or remaining steady.

I do the trend calculation in Arduino (ESP8266) code. I tried to mimic the idea of setting the reference needle on a real barometer, waiting an hour, then seeing which way the pressure needle had moved with respect to the reference. The wrinkle is that "the last hour" is a moving window that updates every 10 minutes.

The BMP085 sensor is polled every 10 minutes. Until there are six observations (eg after a reboot) the code returns "training".

After that, the code does a least-squares regression on the last six observations (ie the last hour of data) to find the linear equation of best fit. In effect, the algorithm assumes that knowing the time (independent variable on the X axis) at some point in the past hour would permit the pressure at that time (dependent variable on the Y axis) to be estimated with some degree of

@Paraphraser
Paraphraser / NodeRED_MidnightredTheme.md
Last active Dec 8, 2020
Recipe for installing Node-RED Midnight-red theme under IOTstack
View NodeRED_MidnightredTheme.md