Beaumast Part 2

The main challenge installing guy wires onto a tiled roof was how to make anchor points. I went to a local antenna supplier and they told me the usual method is with these long self tapping o-ring bolts. So that’s what I did, it was much easier than I expected.

I used a diamond hole saw from eBay to make 2 holes in the roof tiles, and made use of an existing satellite dish mast for the final mounting point. I used threaded rod to attach a tapped o ring (or whatever you call it) to the satellite mast. Using a wet finger I was able to mold silicon around the anchor bolts in the roof tiles.

Part 1 ->

From my understanding it’s better to be earthed than not… I tried running conduit through this cement path using only an angle grinder and a chisel. This would have taken waay too long. Ended up buying a jack-hammer from gumtree (cheaper than renting). The second earth wire is from a UBNT Ethernet protector in the roof-space. This goes to a separate earth rod a small distance from the mast earth rod.

Project Secure Backup. Part 6

I moved the project to some acrylic in what is possibly the final stage for the project.While I thought the software reset for the Ethernet chip would suffice for connection problems, it appears this isn’t the case. I’ll try reprogramming the chip with an interrupt reboot for the main program loop, currently the device isn’t sending info to ThingSpeak.

Once the code is running smoothly (for at least a week) I’ll add email notifications. In the future I won’t use this Ethernet chip, there is a similarly priced chip I have which is much more capable.

Continue reading “Project Secure Backup. Part 6”

Project Secure Backup. Part 5

Starting the electronics part..
Arduino
The famed Atmel 328p Arduino – ‘Pro Mini’ version

This part of the build requires sending temperature data to the internet. This requires 3 things:

  1. Thermocouples for measuring temperature.
  2. A microcontroller for processing the thermocouples values.
  3. A hardware connection to the internet.

 

The thermocouples simply have a change in electrical resistance dependant on temperature. This can be measured using an analog input on a microcontroller. To get sensor data into the micro I used a library called thermistor.h which gave me the number crunched readings in degrees C. the values I’m getting are currently accurate to around 3 degrees C, so I may need to do some work on the maths here.

I have several microcontrollers sitting in boxes waiting for a suitable project. Without making this a diatribe about buggy software libraries for TI micro controllers, I went with the trusty Atmel 328p aka the Arduino.

The Ethernet module I’m using to connect is the ENC28J60 chip, available very affordably from ebay.

Initially I was using an Arduino pro mini set to 5volts. While the board I bought claimed to be able to be set to 3.3 volts, this was outside the spec for the 16Mhz crystal it uses. Eventually I moved to a 3.3v 8Mhz Arduino which seems the most trouble free, using a 5v Arduino with a level shifter for the 3.3v ENC28J60 was completely unreliable.

Bugs

So this bug fix by chuyrg resets the ENC28J60 by pulling a normally high reset pin low for a brief period. This hard reset of the ENC28J60 solves for the temperamental connection issues the ethercard Ethernet library seems to give. Interestingly this bugfix was already in the code :/ just needed to uncomment it… placing this reset code in the right place meant I didn’t need to implement a timer interrupt reset on the whole code…

Using the example code for ThingSpeak coupled with some thermocouple code, I used is able to throw up 2 data fields to ThingSpeak with a frequency of around 60 seconds.

Since ThingSpeak doesn’t send emails, I used this method to trigger a pushingbox.com ‘scenario’ to send email. I also added ThingSpeak ‘react’ events for a ‘No Data Check’ at 1 hour and 12 hours, in case I stop receiving data to ThingSpeak.


So now I have a seemingly reliable 5v low power temperature sensor, with hard wired email alerts, all for around $10 worth of parts. I’m happy with this not only because of the low electrical power consumption, but also because it uses low processing power – no RPi needed.

Needing to reset the Ethernet module in code is a¬†somewhat duct-tape style solution and if it works for extended periods of time that will be fine. After all, the internet in many ways is often referred to as a crazy Rube Goldberg machine which somehow usually works. I’m guessing the ENC28J60 is needing a reset possibly due to a buffer issue, which may have been fixed with a different Ethernet library, although I don’t feel like migrating the ThingSpeak code I’ve got over to that library.. it works, it appears solid, now I’ll field test it.

Hardware shutdown switch for RPi

Sometimes I need to power off one of my Raspberry Pis, and since I run these computers headless, going to a remote SSH terminal to issue a shutdown command can be extra work. I saw a webpage mentioning using a simple 2 pin jumper to initiate a shutdown script for the Pi. So that’s what I did (green tab on the GPIO pins), I chose python due to the wait_for_edge function.

This script will shutdown the RPi when the tab is pulled. Strangely the RPi will boot if you plug the jumper back in after it has shutdown, or if you pull it out after it has completed shut down (putting it back before it has completed shutting down). If there is no jumper in during boot, then the script will close.

#!/usr/bin/env python
#note crontab for superuser required a new PATH variable as here http://unix.stackexchange.com/questions/43392#answer-43394
import subprocess
try:
 import RPi.GPIO as GPIO
except RuntimeError:
 print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")

#http://raspberrypi.stackexchange.com/questions/12966/what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering
GPIO.setmode(GPIO.BOARD)
GPIO.setup(5, GPIO.IN) #Hardware Pullup on this pin..

ShutdownCommand = ['shutdown', '-h', 'now', '"System halted by GPIO action"']

if GPIO.input(5) == 0:
 #run script waiting for jumper removal
 GPIO.wait_for_edge(5, GPIO.RISING)
 GPIO.remove_event_detect(5)
 KillProcess = subprocess.Popen(ShutdownCommand, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 MountData, MountError = KillProcess.communicate()
 GPIO.cleanup() 
else:
 GPIO.cleanup()

Then I simply added this script to the bottom of my root crontab (sudo crontab -e) to run at reboot:

@reboot python /usr/local/sbin/ShutdownJumper.py

DIY USB charger

20160920_222327-2I got a hold of a USB outlet from ebay, and I wanted to use it basically as a hub for charging. I sourced a 3A 12V plug-type power supply which I figured would work well with the ‘UBEC 5V buck converter I got made for RC plane receivers, changed the UBEC cables to DC barrel jacks and. hmm doesn’t work.. :/

20160920_223545

Monitoring RPi Temp and CPU with Thingspeak

I made the following python script to update CPU Temperature and 5 minute average CPU load of my RPi to Thingspeak:

#!/usr/bin/env python
import subprocess
import httplib, urllib

GetTempCommand = "cat /sys/class/thermal/thermal_zone0/temp"
GetCPUCommand = "cat /proc/loadavg"

GetTempProcess = subprocess.Popen(GetTempCommand.split(), stdout=subprocess.PIPE)
GetTempOutput = GetTempProcess.communicate()[0]
Temp = float(GetTempOutput) / 1000
#print Temp
GetCPUProcess = subprocess.Popen(GetCPUCommand.split(), stdout=subprocess.PIPE)
GetCPUOutput = GetCPUProcess.communicate()[0]
CPU = GetCPUOutput.split()
#print CPU[1]

params = urllib.urlencode({'field1': CPU[1],'field2': Temp, 'key':'######'})     # use your API key generated in the thingspeak channels for the value of 'key'
# temp is the data you will be sending to the thingspeak channel for plotting the graph. You can add more than one channel and plot more graphs
headers = {"Content-typZZe": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn = httplib.HTTPConnection("api.thingspeak.com:80")                
try:
    conn.request("POST", "/update", params, headers)
    response = conn.getresponse()
    data = response.read()
    conn.close()
except:
    print "connection failed"

The script is run every 5 mins using cron ($ crontab -e):

*/5 * * * * python "/home/ubuntu/logging/TempCPUtoThingspeak.py"

I borrowed some script from here and here.

LinkyMcLinkFace Part 2

So my initially Nanobridge factory reset itself, before resetting itself every minute or so. I assumed it was due to my crappy wiring initially. First thing I did was get a Ubiquiti ETH-SP Ethernet Surge Protector, this really is more related to the safety of the LAN than anything else, except that now I have the Ethernet port for the NanoBridge accessible from my ceiling. When I went to install the ETH-SP I found one pair of the network cable wasn’t connected properly.

Continue reading “LinkyMcLinkFace Part 2”

Raspbian on RPi3 for NAS

Note: I have swapped the RPi3 for a RPi2 due to Ubuntu compatibility. Even the supported RPi2 with Ubuntu is proving problematic, I want to move to something more reliable.

20161025_134850
Using a Western Digital PiDrive Cable to power the setup.
  • Raspbian comes with default user:pass = pi:raspbian so this needs to be changed
  • I confirmed SSH was installed and working.
  • Following these instructions;
    • I installed ufw
      sudo apt-get install ufw
      sudo ufw allow ssh
      etc..
    • I confirmed NTP configuration.
  • Installed autoupdates, similar to this with different config.
  • Installed postfix, kind of like this.
  • the rest of the steps are basically the same that I used for Ubuntu – except that there isn’t a proper Ubuntu release for RPI3 yet.

LinkyMcLinkFace

Monday a wifi stumble returned some surprisingly decent numbers, initially my idea was to have a mast up by Tuesday. I repaired my hammer drill and got to constructing. This effort resulted in a total of half a hole drilled once I’d gotten up to the roof.

I’ve been looking at the lovely new Makita hammer drill I bought and feeling a bit guilty. Oh well I bought it now, lets hope Makita doesn’t pull any planned obsolescence schemes on the batteries any time soon.

It’s now Thursday, I was able to run a cable to my LAN and stumble a connection. Initially I was getting signal around 80dBm, I went to google earth so I knew at least which direction to aim and zing we’re online!