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

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

  1. Sebastian

    So with this I should theoretically be able to put all the components tgether and load this image and have a working unit correct? What If i don’t want the pressure sensor or the humidity sensor but I want a total of 5 different temp sensors? Would you be able to provide some guidance on mods for the additional temp sensors?

    Thanks in advance! This has been the most comprehensive build i’ve found and glad to have done so!

    /s

    Reply
    1. wpadmin Post author

      Yes, but I have to approve them. You are correct, provided your components are all correctly connected, you should be able to boot straight from the SD image.

      To add more sensors, have a look at the python code in the instructions and also where I set up the channels in cacti. Cacti won’t log anything which is missing but you will need to edit the LCD.py code to remove references to missing sensors or it will complain and stop. Good luck!

      Reply
  2. Sebastian

    I guess my next question is, when I’m looking at the lcd.py i don’t want to display time/temp. I want to display labels across the top line and corresponding temps along bottom line for example:
    HT MT BK CI CO
    50 60 100 98 40

    Could you give me a good reference to find how to modify the .py or perhaps an idea to go about it?

    Thanks!!!

    Reply
    1. wpadmin Post author

      Well, I think you will need to mess around in lcd.py around these lines:

      # Send basic date and temperature 1
      lcd_byte(LCD_LINE_1, LCD_CMD)
      t_string = format(temp[0], “0.3f”)
      lcd_string(now.strftime(“%d %b “)+’T1=’+t_string)

      # Send basic time and temperature 2
      lcd_byte(LCD_LINE_2, LCD_CMD)
      t_string = format(temp[1], “0.3f”)
      lcd_string(now.strftime(“%H:%M “)+’T2=’+t_string)
      #lcd_string(str(temperature))

      Changing the top line is easy:

      lcd_byte(LCD_LINE_1, LCD_CMD)
      t_string = ‘HT MT BK CI CO’
      lcd_string(t_string)

      You will need to change the formatting command format(temp[0], “0.3f”) which gives 3DP display to something else that just gives 2 digits and no decimal

      format(temp[0], “2.0f”)

      You’d need to do this for all five temperatures. There is probably a more efficient way but I don’t have much time at the moment.

      So you could use:

      t1s = format(temp[0], “2.0f”)
      t2s = format(temp[1], “2.0f”)
      t3s = format(temp[2], “2.0f”)
      t4s = format(temp[3], “2.0f”)
      t5s = format(temp[4], “2.0f”)

      lcd_byte(LCD_LINE_2, LCD_CMD)
      lcd_string(t1s + t2s + t3s + t4s + t5s)

      Reply
  3. Sebastian

    Awesome! Thanks for the heads up… I tested the original script (“new_temperatures.py”) with two probes successfully, then added three more (I need a total of five) but I get the following error:

    Traceback (most recent call last):
    File “new_temperatures.py”, line 38, in
    temp = read_temp() #get the temp
    File “new_temperatures.py”, line 31, in read_temp
    lines = read_temp_raw()
    File “new_temperatures.py”, line 16, in read_temp_raw
    f_3 = open(device_file[2], ‘r’)
    IndexError: list index out of range

    Below is the Script and how I modified it:

    #!/usr/bin/python
    # This file is: /usr/share/cacti/site/scripts/new_temperatures.py
    import os, glob, time, sys, datetime
    #set up the location of the five 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’]
    def read_temp_raw(): #a function that grabs the raw temperature data from the sensors
    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()

    f_3 = open(device_file[2], ‘r’)
    lines_3 = f_3.readlines()
    f_3.close()

    f_4 = open(device_file[3], ‘r’)
    lines_4 = f_4.readlines()
    f_4.close()

    f_5 = open(device_file[4], ‘r’)
    lines_5 = f_5.readlines()
    f_5.close()

    return lines_1 + lines_2 + lines_3 + lines_4 + lines_5

    def read_temp(): #a function that checks that the connection was good and strips out the temperature
    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
    temp = read_temp() #get the temp
    print(‘T1:’+str(temp[0])+’ T2:’+str(temp[1]))+’ T3:’+str(temp[2])+’ T4:’+str(temp[3])+’ T5:’+str(temp[4])

    Any and all helps is appreciated!!!

    Thanks again

    /s

    Reply
  4. Sebastian

    Not to waste your time any further but I think where I was having a problem is that I wasn’t adding the “device_file” entry for the other temp sensors, so I added one at a time (as you’ll see in the code) but when I add the final ‘ T3:’+str(temp[2])) to print the temp in the command line I get:

    Traceback (most recent call last):
    File “new_temperatures.py”, line 35, in
    print(‘T1:’+str(temp[0])+’ T2:’+str(temp[1])+’ T3:’+str(temp[2]))
    IndexError: tuple index out of range

    The following is the Script with the addition of one “device_file” at this point it’s easier to add one at a time then to do the whole shebang and hope it works. The other thing I noticed is if I change str(temp[2]) to str(temp[1]) I get a readout for T3! Anyway, below is the script: Thanks again for your help!!!

    #!/usr/bin/python
    # This file is: /usr/share/cacti/site/scripts/new_temperatures.py
    import os, glob, time, sys, datetime
    #set up the location of the five 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’, device_folder[2] + ‘/w1_slave’]
    def read_temp_raw(): #a function that grabs the raw temperature data from the sensors
    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()
    f_3 = open(device_file[2], ‘r’)
    lines_3 = f_3.readlines()
    f_3.close()
    # f_4 = open(device_file[3], ‘r’)
    # lines_4 = f_4.readlines()
    # f_4.close()
    # f_5 = open(device_file[4], ‘r’)
    # lines_5 = f_5.readlines()
    # f_5.close()
    return lines_1 + lines_2 + lines_3# + lines_4 + lines_5
    def read_temp(): #a function that checks that the connection was good and strips out the temperature
    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

    temp = read_temp() #get the temp
    print(‘T1:’+str(temp[0])+’ T2:’+str(temp[1])+’ T3:’+str(temp[2]))

    #+’ T4:’+str(temp[3])+’ T5:’+str(temp[4]))

    Reply
  5. Jane

    the link for the dropbox no longer works, can you email the docs to me? Please… Thank you. I’d like to take on this project.

    Reply
    1. wpadmin Post author

      Ooops, I was reorganising my Dropbox folder for this project. I have updated the links. Happy to email if still a problem.

      Reply

Leave a Reply

Your email address will not be published.