An installed RuuviCollector with Grafana
for Raspberry Pi Zero W

This SD image includes several features I consider important and helpful.

To get your system running

  1. Get the best 16GB or bigger SD card you can (Pi Zero needs all the help it can get)
  2. Be sure that the download size is exactly 3,694,717,621 bytes no need to uncompress it if you use balenaEtcher
  3. I have had the best luck writing the image to an SD card using balenaEtcher.
    It is easy (accepts a gz file and runs on mac os, windows and linux), safe(it finds your SD card) and free.
  4. If you are going to connect via wifi create /boot/wpa-supplicant.conf which the boot process will use to overwrite /etc/wpa_supplicant/wpa-supplicant.conf and then deletes it.

    For example:

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
        ssid="my-netname"
        psk="Myi-wifi-NetPass"
    }
    Check for matching quotes
  5. The hostname is damonitor2
  6. ssh is already enabled so you can use ssh or windows version of putty to login
  7. username pi and ruuvicoll will get you in to the bash shell with command lind editing using vi

When issuing influx from the shell be patient


    "special" configuration information

  1. The boot partition (which is readable and writable by non-linux systems) includes
    1. rc.local.boot
      This is invoked by /etc/rc.local upon boot
      You can add commands if you need to.
    2. a log directory
      contains output from /boot/rc.local.boot (includes network configuration ) as well as emerg and alert syslog messages.
  2. ruuvicollector configuration
    1. ruuvi-collector.properties
      1. measurementUpdateLimit=30000 Restrict number of updates per tag to a more reasonable frequency and consider perfomance
      2. storage.values=raw don't include calculated values in the database which reduces the size
      • Not included but you might consider:
      1. RuuviCollector inserts data into the influxdb for any RuuviTag for which it receives data .
        If you have Ruuvi tags you don't want included add filter.mode blacklist | whitelist
      2. influxUrl=http://localhost:8086 relocate the database (and grafana) to another system to ease the load.
      3. You should consider adding tag names to ruuvi-names.properties.
  3. influxdb considerations
    1. You should decide if you want year to year (or multi year) comparisons and
      influx -precision rfc3339 -database ruuvi
      alter retention policy autogen on ruuvi DURATION 4320h0m0s
      (or whatever)
    2. After you experiment with my data already in the influxdb, You might
      influx -precision rfc3339 -database ruuvi # rfc3339 uses better time display
      select mac,last(temperature) from ruuvi_measurements group by mac tz('America/New_York');
      # show list of ruuvi tags
      delete from ruuvi_measurements where mac = 'D3517872EC0F'

      Command line editing in influx is done using emacs commands.

    3. Starting influx is a heavy processs. Using it from command line gives SQL command flexability.
      Using curl is much less resource intense and is a better choice for cronjobs.
      For Example:
      curl --get 'http://localhost:8086/query?' --data-urlencode "db=ruuvi" --data-urlencode "q=SELECT mac,last(temperature) \
      FROM ruuvi_measurements tz('America/New_York') " 
  4. grafana is accessable at http://DaMonitor2:8888
  5. systemd considerations:
    1. I have found it helpful to delay starting RuuviCollector until after influxdb is able to handle queries (which can take a long time) Rather than starting up the java program directly I use a script /home/pi/RuuviCollector/RuuviCollector
    2. /etc/systemd/system/multi-user.target.wants/ruuvicollector.service contains:
      Restart=always
      RestartSec=300
      prevent rapid restart up failiure
    3. /etc/systemd/system/ruuvicollector.service.requires/influxdb.service
  6. crontab
    1. pi user includes
      07,17,27,37,47,57 * * * * RuuviCollector/checkPorch.sh
      Which uses influxdb to extract the last(temperature) from a particular tag and uses syslog to send a message to my syslog server. You probably want to change that.
  7. syslogd
    1. messsages are disbursed to various files in /var/log
    2. emerg and alert messages go to /boot/log so they can be viewed from a non-linux system
    3. warning (and above) messages go to my syslog server via UDP (You should probaly remove or change that)
  8. Partitions
    You should consider changes to minimize root system becoming full and the system becoming inaccessable
    1. Create a serperate partition and migrate influxdb files there.
    2. Create a seperate paritition and migrate syslogd messages there
    Don't create a seperate swap partition instead of using /var/swapfile as discussions on the Raspberry Pi forum dispute any advantage.

Be sure to let me know if you have any problems or suggestions.