New walk – the London Loop

Although the Thames Path and Grand Union Canal walks were very interesting and passed through some wonderful scenery, as the walking route went further from my home, the ‘commuting’ time to get to and from the walk increased. It was around 3 hours each way with the final sections of the walks, meaning I had to set off early each day to guarantee having enough time to walk each section. It also meant that the walks were really confined to the summer months when there is light for many hours each day.

So, for my next walking route, I was boggled to find that the London LOOP (London Outer Orbital Path) passes very close to my house – just two roads away! The walk is contained within the TFL Zones, meaning that I can always use my Oyster card to pay for trips, and can use a combination of trains, tubes, trams and buses to get to/from the walk. It also means that the ‘commuting’ time can be as little as 30 minutes and probably not much longer than 2 hours. It means I can get some walking done in the shorter days of the seasons either side of summer.

I’ll be following the route in the official clockwise direction, with each section coming in order, but rather than start and end the whole loop at the Thames at Erith/Purfleet, I’ll be starting and ending in Fulwell. Also due to short walking hours away from the summer, some walks will start/end at the intermediate points.

So, here we go!

01 Fullwell to Heathrow
02 Heathrow to Cowley
03 Cowley to Uxbridge
04 Uxbridge to Harefield
05 Harefield to Moor Park
06 Moor Park to Hatch End
07 Hatch End to Stanmore
08 Stanmore to Elstree
09 Elstree to High Barnet
10 High Barnet to Cockfosters
11 Cockfosters to Endfield Lock
12 Enfield Lock to Chigwell
13 Chigwell to Harold Wood
14 Harold Wood to Rainham
15 Rainham to Purfleet
16 Erith to Bexley
17 Bexley to Petts Wood
18 Petts Wood to West Wickham
19 West Wickham to Hamsey Green
20 Hamsey Green to South Coulsdon

Output from multiple DS18B20 to Cacti

If you need to read multiple (variable number) of sensors into Cacti, the following python script will read the sensors and format the output ready for Cacti. Be aware though that the sensor numbering is based on their serial numbers - the order will change if sensors with different serial numbers are added or removed!!!


#!/usr/bin/env python

from os import path, listdir, system
from time import sleep


# Borrowing some elements from https://github.com/timofurrer/w1thermsensor/blob/master/w1thermsensor/core.py
THERM_SENSOR_DS18S20 = 0x10
THERM_SENSOR_DS1822 = 0x22
THERM_SENSOR_DS18B20 = 0x28
RESOLVE_TYPE_STR = {"10": THERM_SENSOR_DS18S20, "22": THERM_SENSOR_DS1822, "28": THERM_SENSOR_DS18B20}
BASE_DIRECTORY = "/sys/bus/w1/devices"
SLAVE_FILE = "w1_slave"

# function to find how many sensors are connected, works for 3 types of sensor
def get_available_sensors():
 types = [THERM_SENSOR_DS18S20, THERM_SENSOR_DS1822, THERM_SENSOR_DS18B20]
 is_sensor = lambda s: any(s.startswith(hex(x)[2:]) for x in types)
 return [(RESOLVE_TYPE_STR[s[:2]], s[3:]) for s in listdir(BASE_DIRECTORY) if is_sensor(s)]

# function to return the initial 2 letters of the device ID ("28" for DS18B20 sensors)
def slave_prefix(mytype):
 return "%s-" % hex(mytype)[2:]

# function that grabs the raw temperature data from a sensor, requires full path+filename
def read_temp_raw(device_file):
 f_1 = open(device_file, 'r')
 raw_reading = f_1.readlines()
 f_1.close()
 return raw_reading

# function that checks that the reading of a sensor was good and strips out the temperature
def read_temp(device_file):
 lines = read_temp_raw(device_file)
 while lines[0].strip()[-3:] != 'YES':
 time.sleep(0.2)
 lines = read_temp_raw(device_file)
 equals_pos = lines[1].find('t=')
 temp = float(lines[1][equals_pos+2:])/1000
 return temp

n = 0
for sensor in get_available_sensors():
 n = n +1
 sp = slave_prefix(sensor[0])
 sensorpath = path.join(BASE_DIRECTORY, sp + sensor[1], SLAVE_FILE)
 print('T'+str(n)+':'+str(read_temp(sensorpath))),

Reading multiple DS18B20 sensors

Some people have been asking for some Python code that can read multiple temperature sensors.
The following code will work for up to 10 sensors (maximum allowed under the kernel driver)



#!/usr/bin/env python

from os import path, listdir, system
from time import sleep


# Borrowing some elements from https://github.com/timofurrer/w1thermsensor/blob/master/w1thermsensor/core.py
THERM_SENSOR_DS18S20 = 0x10
THERM_SENSOR_DS1822 = 0x22
THERM_SENSOR_DS18B20 = 0x28
RESOLVE_TYPE_STR = {"10": THERM_SENSOR_DS18S20, "22": THERM_SENSOR_DS1822, "28": THERM_SENSOR_DS18B20}
BASE_DIRECTORY = "/sys/bus/w1/devices"
SLAVE_FILE = "w1_slave"

# function to find how many sensors are connected, works for 3 types of sensor
def get_available_sensors():
   types = [THERM_SENSOR_DS18S20, THERM_SENSOR_DS1822, THERM_SENSOR_DS18B20]
   is_sensor = lambda s: any(s.startswith(hex(x)[2:]) for x in types)
   return [(RESOLVE_TYPE_STR[s[:2]], s[3:]) for s in listdir(BASE_DIRECTORY) if is_sensor(s)]

# function to return the initial 2 letters of the device ID ("28" for DS18B20 sensors)
def slave_prefix(mytype):
   return "%s-" % hex(mytype)[2:]

# function that grabs the raw temperature data from a sensor, requires full path+filename
def read_temp_raw(device_file):
   f_1 = open(device_file, 'r')
   raw_reading = f_1.readlines()
   f_1.close()
   return raw_reading

# function that checks that the reading of a sensor was good and strips out the temperature
def read_temp(device_file):
   lines = read_temp_raw(device_file)
   while lines[0].strip()[-3:] != 'YES':
       time.sleep(0.2)
       lines = read_temp_raw(device_file)
   equals_pos = lines[1].find('t=')
   temp = float(lines[1][equals_pos+2:])/1000
   return temp

for sensor in get_available_sensors():
   sp = slave_prefix(sensor[0])
   sensorpath = path.join(BASE_DIRECTORY, sp + sensor[1], SLAVE_FILE)
   print("Sensor %s has a temperature %.3f" % (sensor[1], read_temp(sensorpath)))

Solving Cacti problems on the logger – full s/w install details & SD image

Some people have been having problems getting the Cacti graphs on the data logger to update correctly – they are missing graph lines and numerical outputs. I remember having similar issues when I was first messing around setting up the loggers. So to try to fix this, I went through a complete software install from scratch starting with a completely fresh Raspbian install on a bare Pi to which I connected the various items of hardware.

It is a tedious process going through a full install AND documenting it in detail at the same time!

Anyway I did it, and I also encountered the issue of non-updating Cacti graphs. After a bit of fiddling around, I managed to get them working. Not sure exactly what step of the debugging was responsible, but the various steps were all recorded. So if you follow these instructions:

https://www.dropbox.com/s/5gzl8mfj1chaxq9/R-Pi%20software%20install.docx?dl=0

you should be able to get to the point I have here – a working Pi reading and graphing the temperature and humidity data. I also include details of installing the LCD driver script and the code for the pressure sensor, but these are optional.

If you still struggle to get it to work and can withstand a 1.2 GB download, I have placed a ZIPped copy of the SD card image on OneDrive:

https://onedrive.live.com/redir?resid=2E3466E51A503CA7!3241&authkey=!APvujrDX8j05ggc&ithint=file%2czip

Thanks for your patience!

Andrew