About Jartweb

Greetings, Earthling, or…

 

Jartweb was my original attempt at setting up a basic web site, from many years ago. It started out as hand-crafted HTML code on a local server, then passed through one or two free hosting accounts, before being morphed into a wider site managed by Dreamweaver. It then decided to change its citizenship and became fluent in PHP as well as uprooting and settling at Streamline for a while. Having got itchy feet, it packed its bags, booked the removals lorry and moved lock, stock and two smoking keyboards, to Tsohosts, where it is currently settling in, unpacking the cases, and finding small fragile pieces of pottery broken in the bottom of the crate. The new house is about the same size as the previous one, but the rooms are nicer, the neighborhood is better, and there is a fresher air about the place.

 

Now, where did the coffee mugs end up…?

Any feedback – try leaving a comment or alternatively check the Feedback page.

10 thoughts on “About Jartweb

  1. Theresa

    Thankyou very much for the very detailed trip on the slough to cowley pea hey I want to use part of it on my bike with a small trailer thinking of getting on from middle green and finishing at little Britain lake will this be possible many thank theresa

    Reply
    1. wpadmin Post author

      Hi Theresa,

      Thanks for your comment.
      I think you will be OK though I recall that the path is mostly uncovered (i.e. grass/dirt) and there were a few places it was a bit muddy and I had to step to the side to avoid the mud (it was a day after some rain). Also if your trailer is too wide, you might have to get off and walk it under one or two bridges as the towpath is narrow at some points. I recall at least one cyclist on the day I was there but no trailer attached. Worst case, you might need to turn back!
      Andrew

      Reply
  2. David S Blanco

    Hello Andrew,

    Love your canal pics, I’m obsessed with the river lea and grand union canal and its surrounding areas, they truly feel like a land that time forgot.

    So happy to see someone is documenting this…wondering, i am producing a little fanzine for my record label Blank Editions , we are based in hackney…and i wanted to ask if i could use one of your images for the cover of my little home made zine…no bother if not, ill go down there and shoot a pic myself, it just WONT be as good as yours 🙂

    Let me know if thats ok

    Hope to hear from you soon!
    Kind regards
    David

    Reply
    1. wpadmin Post author

      Absolutely fine to use the picture. Let me know if you want me to email you a full resolution copy of a specific picture.

      Reply
  3. Brady

    Hi,

    I have been following your post regarding the temperature monitoring system and must say a big thank you for the very detaied instructions!

    I am after some help though, I am trying to get more than 2 DS18B20’s working and i just cannot figure out the python for it. Have you done this before?

    Thanks

    Reply
    1. wpadmin Post author

      Hi Brady,

      I have not yet tried to run more than the two DS18B20s of my current built. Elsewhere I have seen that the kernel driver for these devices on the Pi is designed to handle up to 10 devices, so it should be possible. I need to built a 10 way device soon so will have a go at the software then. My thoughts are:
      1. Detect how many devices are plugged in (by enumerating the number directories that get set up in the relevant location)
      2. Go through the devices one by one up to the maximum number present, reading them one at at time.
      3. Store the results in an array.
      4. Send the array values, two at a time to the LCD display and store them in the raw data file.

      I am not yet sure how to handle the higher and possibly variable number of devices in Cacti. Perhaps I can set up a maximum of 10 channels (rather than the current 2) and for those that are not present, Cacti will not read any data and hopefully not get too confused?

      The issue for both is that the devices are enumerated based on serial numbers so swapping out one device and swapping in another of an earlier serial number may upset the ordering (i.e. channel 3 becomes channel 4 and the new device becomes channel 3). I could fix this by storing a list of serial numbers and allocating them to specific channels, but my python knowledge is a it sketchy at the moment.

      For the current python code, here is where the code determines the location of the two sensors:

      # set up the location of the two DS18B20 sensors in the system
      device_folder = glob.glob(‘/sys/bus/w1/devices/28*’)
      device_file = [device_folder[0] + ‘/w1_slave’, device_folder[1] + ‘/w1_slave’]

      and this bit does the actual reading, based on the locations returned by the above code:

      # function that grabs the raw temperature data from the sensors – assumes two sensors
      def read_temp_raw():
      f_1 = open(device_file[0], ‘r’)
      lines_1 = f_1.readlines()
      f_1.close()
      f_2 = open(device_file[1], ‘r’)
      lines_2 = f_2.readlines()
      f_2.close()
      return lines_1 + lines_2

      The above code is called by the following:

      # function that checks that the connection was good and strips out the temperature
      def read_temp():
      lines = read_temp_raw()
      while lines[0].strip()[-3:] != ‘YES’ or lines[2].strip()[-3:] != ‘YES’:
      time.sleep(0.2)
      lines = read_temp_raw()
      equals_pos = lines[1].find(‘t=’), lines[3].find(‘t=’)
      temp = float(lines[1][equals_pos[0]+2:])/1000, float(lines[3][equals_pos[1]+2:])/1000
      return temp

      and this is the main piece of code that asks for the sensors to be read and then cleans up the output.
      Several parts of this code (and other code that displays the values) make the assumption that there are just two sensors, so a major re-write is needed!

      Reply
  4. Brady

    Hi,

    Yes I believe there is a lot of room for expansion, and what you have done already is pure brilliant!

    I have been trying to modify the python script to read 4 sensors (0,1,2,3) but just cannot get it to run. I would run the number of channels in cacti that I have sensors I think that would be okay as you mentioned.

    My Python knowledge is to say, non existant but I have tried everything I can think of to get the script to see 4 sensors.

    I will be interested to see how you get on coding the bigger system, as this is of vast use!

    Thanks

    Reply
    1. wpadmin Post author

      Well, I found some spare time and after a quick browse of the internet and a bit of hacking around, the following seems to work OK. I only have two sensors fitted on my test system, but this code should work for any number of sensors (up to the max 10 allowed by the kernel).

      #!/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)))

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *