Freeze Mon

Raspberry Pi based freezer temperature monitor:
  • DS18B20 sensor
  • send temp to server one per minute
  • Server displays this, if browsed
  • if temp goes outside range, raspi sends text warning
  • if server loses contact with raspi, server sends text

-- BenDugan - 02 Oct 2017

Key bits of code from here.

So far:
  • set up rpi zero, added sensor, confirmed it reads temps automatically after power up
  • set up shared key so rpi can ssh to elvo

Next:
  • rsync temp file from rpi to elvo every 5 minutes (small python script run by cron)
    • what happens is ssh fails?
    • run scp from bash or from python?
  • cat into log file in case net breaks
  • write program on elvo to
    • convert file to time & temp, cat to end of data log
    • detect alarm conditions, send emails (texts)

-- BenDugan - 08 Oct 2017

Most of above working now, except:

  • detect alarm conditions, send emails (texts)

Also:

  • add browser output for time now and graph of recent time

-- BenDugan - 10 Oct 2017

The rpi has disconnected at least twice and not reconnected automatically. The #1 thing this shows is the need to test it here at length before putting it at St Mary's, because there it will be hard to reset and it will be sending warnings that will get annoying. The first time I saw this it happened after ~ 2hours and I thought it might have been a DHCP lease thing, so I changed a setting related to that in the dhcp conf file. Since then it worked for a few days, and I thought that was it. But this morning I see that it stopped at 12:30 yesterday (I think that's after lunch).

Did it keep logging data?

Can I log in now with a keyboard and monitor to debug the network connection?

-- BenDugan - 14 Oct 2017

I had a problem where I had two crontabs running: one for user bdugan and the other for the superuser. Sometimes they stepped on each other and the temperature graph would not update. But for the last two days the display has not updated although the temperatures have continued to be logged. I just ran 'tmon' as su and it did run gnuplot correctly and created the graph, so what happened before? (I think the gnuplot command line was missing the leading directory info so it ran when I tested it from that directory. - Actually, I think it was the missing directory info in the plot_script file.)

Also, I could not ssh to the rpi this morning. It might have been on the network but at a changed DHCP address -- I didn't think to check that until after I rebooted it.

-- BenDugan - 29 Oct 2017

Moving Servers

This has been on 'elvo' and I'm moving it to 'elf', which has been a testbed for a while in order to upgrade the OS to Ubuntu 16.04. foswiki and owncloud are working on elf now and those are the main things. What is needed on the server to support this temperature monitor?

  • crontab entries
  • python scripts
  • bash scripts
  • gnuplot scripts
  • files
    • ~/plot_data
    • ~/temperature_now - ephemeral: single point, gets appended to temperature_log based on crontab
    • ~/temperature_log
    • ~/t.png - output from gnuplot, updated based on crontab, gets copied into /var/www/uchc
    • /var/www/uchc/index.html
    • /var/www/uchc/t.png (copied from ~t.png)

The plot is viewed by browsing to http://uchc.wbwdw.com/index.html. So the apache config needs:

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin bdugan@curdes.com
  ServerName  uchc.wbwdw.com
  ServerAlias uchc.wbwdw.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex /var/www/uchc/index.html
  DocumentRoot /var/www/uchc

  # Log file locations
  LogLevel warn
  ErrorLog  /home/bdugan/public/wiki/log/error.log
  CustomLog /home/bdugan/public/wiki/log/access.log combined

</VirtualHost>

Development status

I'm not sure if the lost-connection problem was solved. As I recall it ran for quite a long time and then got unplugged at my house because of some unrelated thing (rearranging of furniture or something like that). But it should have:

  • numerical time and temp now display (shows last reading time which is important) DONE
  • some easy means to grab log file for importing to spreadsheet DONE

  • text/email from server if readings stop (probably means lost power or lost wifi)
  • text/email from server if temp goes out of range
  • restored connection: send notice when temp received again
  • decision on cable length to sensor
  • waterproof sensor

How This Works - short version

A small single board computer reads the temperature from a digital temperature probe, and logs this reading at regular intervals into a file. This creates a local log file of the temperature without needing an internet connection. But to make the temperature readings available to the outside world the readings are copied to a server, and small scripts on that server display the readings as a graph.

Requirements

  • wifi - there needs to be a reliable wifi signal within range of the monitor
  • password - the wifi password needs to be given to the monitor so it can access the net
  • power - the monitor uses one AC mains connection (120 VAC, < 10W)

Making Connections

First use with a new router is not easy at this point: a keyboard and monitor are needed so that the wifi credentials can be entered. After that, it should just work when plugged in. But could it turn into a WAP if it can't connect? That might allow the wifi credentials to be added using a browser rather than requiring a KVM.

Yesterday I picked this up again -- it hadn't been plugged in since last December -- and it didn't start right up, mostly because I moved the server in the mean time (I think it went elvo -> elf -> elvo) and the keys needed to be updated and the cron files had to be re-setup. And there were file permission issues in the html directory. Little stuff, but it is kind of a fragile setup.

Today I'll try to install a tool that does the WAP-if-no-wifi thing. This is just a good trick to know anyway because it makes rpis more practically useable.

I followed this: http://www.raspberryconnect.com/network/item/331-raspberry-pi-auto-wifi-hotspot-switch-no-internet-routing

It seems to work just as advertised.

This is working quite well but I am waiting to hear from Bob about wifi and power connections before making a longer sensor cable and covering the pcb.

-- Main.BenDugan - 31 May 2018 - 06:46

Trying it out today at St Marys, so want to backup everything that matters from the rpi.
Topic attachments
I Attachment Action Size Date Who Comment
ctabEXT ctab manage 1 K 24 Jan 2018 - 22:01 BenDugan  
plot_dataEXT plot_data manage 59 K 24 Jan 2018 - 22:01 BenDugan  
plot_scriptEXT plot_script manage 157 bytes 24 Jan 2018 - 22:02 BenDugan  
temperature_logEXT temperature_log manage 342 K 24 Jan 2018 - 22:04 BenDugan  
tmonEXT tmon manage 278 bytes 24 Jan 2018 - 22:04 BenDugan  
tmon2EXT tmon2 manage 438 bytes 24 Jan 2018 - 22:02 BenDugan  
Topic revision: r14 - 04 Jun 2018, BenDugan
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback