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. hcitool and hcidump require additional capabilities:
    sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
    sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcidump`
    The error
    unable to set CAP_SETFCAP effective capability: Operation not permitted
    Means you forgot sudo or need to run as user root To verify that these tools are correctly setup, run each from the command line. The output should be somethinglike:
    
    An error like Could not open device: No such device
    or
    Can't attach to device hci0. No such device(19)
    means that the BLuetooth interface is not found. `
    Set scan parameters failed: Input/output error
    Means that hcitool is already running.
     > hcidump
    
    HCI sniffer - Bluetooth packet analyzer ver 5.43
    device: hci0 snap_len: 1500 filter: 0xffffffff
    > HCI Event: LE Meta Event (0x3e) plen 43
        LE Advertising Report
          ADV_IND - Connectable undirected advertising (0)
          bdaddr E4:D5:6D:EC:6E:29 (Random)
          Flags: 0x06
          Unknown type 0xff with 26 bytes data
          RSSI: -90
    > HCI Event: LE Meta Event (0x3e) plen 42
    
    This will continue until you press ^\ to quit or ^C to interrupt.

    "special" configuration information

  3. 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.
  4. sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
    sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcidump`
  5. 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.
  6. influxdb considerations
    1. INFLUXDB_MONITOR_STORE_ENABLED=FALSE turn off internal monitoring of the database
    2. 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)
    3. 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.

    4. 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') " 
  7. grafana is accessable at http://DaMonitor2:8888
  8. 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
  9. 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.
  10. /etc/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)
  11. Partitions
    Consider adding additional partitions to minimize the chance that the root system fills up and the system becoming inaccessable:
    1. Create a seperate partition and migrate influxdb files there.
    2. Create a seperate smallish paritition (4GB) and migrate syslogd messages there instead of /var/log.
      Simple just edit /etc/syslog
    Don't create a seperate swap partition instead of using /var/swapfile as discussions on the Raspberry Pi forum dispute any advantage.
  12. 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.
  13. influxdb considerations
    1. INFLUXDB_MONITOR_STORE_ENABLED=FALSE turn off internal monitoring of the database
    2. 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)
    3. 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.

    4. 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') " 
  14. grafana is accessable at http://DaMonitor2:8888
  15. 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
  16. 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.
  17. 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)
  18. 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.