Ruuvi and RPi3 w Grafana & InfluxDB

Hi gang -

First time poster here and newbie to Ruuviā€¦

As part of my first project, I followed this post on setting up my Ruuvi/RPi3: https://blog.ruuvi.com/rpi-gateway-6e4a5b676510

This works great initially, but after a couple of days, Iā€™m no longer recording data. Checking the status of the Grafana server shows the following error: ā€œJan 31 13:25:55 rpri-ruuvi grafana-server[431]: t=2020-01-31T13:25:55-0600 lvl=info msg=ā€œAlert Rule returned no dataā€ logger=alerting.evalHandler ruleId=1 name=ā€œBattery Voltage (mV) alertā€ changing state to=no_dataā€

Using the Ruuvi app, works fine. Any suggestions on what to do to troubleshoot? Please keep in mind that Iā€™m a newbieā€¦

Thanks!

Hello,

Thereā€™s a growing number of reports about HCITool crashing in Pi installations since summer 2019. Thereā€™s probably some underlying problem with the Raspbian or HCItool, but how to fix it is yet on known. As a workaround you can have a cron job restart the collector.

1 Like

Thanks for the response Otso. Can you provide steps for creating the cron job?

That was it. I restarted the collector and now Iā€™m getting data again.

Hello, hereā€™s one example with nightly reboots: https://askubuntu.com/questions/13730/how-can-i-schedule-a-nightly-reboot. It might be enough to run hciconfig reset instead of full reboot, but I havenā€™t had a chance to verify that yet.

1 Like

Thank you very much!

sudo hciconfig reset # didnā€™t help in my case on 1/30/20.

My plan, rather than periodically (by cron ) reset/restart,
is to periodically check at lowest level and take corrective action only if failure is present.

At this time that means running hciconfig and checking output and if it times out invoking:

sudo logger -p kern.alert " " ++ rebooting due to HCI hangup "

sudo shutdown --reboot +5m " ++ rebooting due to HCI hangup "

I would love to hear from anyone with a more ā€œgentleā€ corrective action.

1 Like

Thanks for the ideas dgermanā€¦ How do you determine if the failure is present? Complete newbie, but learning.

To check if bluetooth is hung :

Option #1 : Check output from lowest level device query like hciconfig -a. This normally reports 17 lines. If Bluetooth is hung reports much less.
I seem to have lost the example I created when it hung for me.

Option#2: Check if any data is being processed by background running hcitool lescan which is started by RuuviCollector using hcidump

To Check that RuuviCollector is updating database. For example:

echo "select temperature from ruuvi_measurements where time > now() -2m" |
influx -precision rfc3339 -database ruuvi >temperatureRecent.log

Is that detailed enough?

By newbie do you mean new to Ruuvi or linuxā€¦?

2 Likes

Newbie to both actuallyā€¦ I can follow the guides easy enough and know enough to be dangerous. Love learning new stuff and enjoy playing around with this tech.

Is there a way to automatically check these connections via your commands and then issue the restart, based upon a lack of connections? Iā€™ve never built a cron job yet.

There is nothing special about a cron job. Itā€™s just any script which is invoked periodically by the cron daemon. The schedule is managed with
crontab -e
See the best documentation (I wrote it! :slight_smile: ) crontab

Are you still seeing hangups? If so what are the responses to the checking options I suggested?

2 Likes

No hangups in the last three days (of course I fully expect it to crash now that I 've said it out loud)ā€¦

hciconfig -a results look good so far:
RX bytes:6225293 acl:1 sco:0 events:203621 errors:0
TX bytes:142465 acl:0 sco:0 commands:19221 errors:0

When I run the ā€œselect temperatureā€¦ā€ command you provided, I get: -bash: syntax error near unexpected token `(ā€™

ARGH! STUPID forum editor changed my quotes to fancy left quote and right quote.

I fixed them, try again.


re hciconfig: it's not errors you are looking for but rather the fact that it reports 17 lines!
1 Like

Perfectā€¦ When I run the ā€œselect temperatureā€, nothing returns, which means itā€™s writing to influx?

hciconfig, returns the 17 lines.

Thanks for the ā€œbestā€ contab link! Iā€™m gonna check that out and try to incorporate it into my setup.

The last part of the command
>temperatureRecent.log
redirects the standard output (STDOUT) which should contain something like:

name: ruuvi_measurements
time                           temperature
----                           -----------
2020-02-07T15:37:16.29571043Z  18.49
2020-02-07T15:37:21.399290325Z 8.815

If there are no measurements selected the file will be empty - a bad thing!

You can then use grep to find the lines containing a colon (like in the time of the data)

grep ':' temperatureRecent.log
RS=$?

This command saves the return status from the command which will be 0 if it is successful and nonzero if grep is unable to find a : in the file.
You can then use a command like:

 if [ $RS -ne 0 ] ; then echo no recent entries in influxdb ; fi

More details about bash if statement are at: bash if

If this is run by cron the output of the echo will be emailed to you. (if you have mail configured).

2 Likes

Hi All -

Iā€™m reviving this topic, as Iā€™m having trouble getting my configuration working. Iā€™m not getting any output to the Grafana report. Please keep in mind that Iā€™m still a newbie to Ruuvi and linux.

Iā€™ve run ā€œhciconfig -aā€ and receive 15 lines in the response, including:
RX bytes:1594 acl:0 sco:0 events:104 errors:0
TX bytes:5258 acl:0 sco:0 commands:104 errors:0

Running ā€œhcitool lescanā€ returns several lines such as:
5D:F6:33:4C:AC:5C (unknown)
77:77:0E:1B:47:DA (unknown)
69:2C:96:B6:F4:19 (unknown)

Running ā€œsystemctl status ruuvicollector.serviceā€ returns the following:
Feb 12 09:00:39 svp-rpi java[469]: 2021-02-12 09:00:39.300 DEBUG [Main] Starting dump with: [hcidump, --raw]
Feb 12 09:00:39 svp-rpi java[469]: 2021-02-12 09:00:39.342 INFO [Main] BLE listener started successfully, waiting for dataā€¦
Feb 12 09:00:39 svp-rpi java[469]: If you donā€™t get any data, check that you are able to run ā€˜hcitool lescanā€™ and ā€˜hcidump --rawā€™ without issues
Feb 12 09:00:56 svp-rpi java[469]: 2021-02-12 09:00:56.236 INFO [Main] Successfully reading data from hcidump
Feb 12 09:16:45 svp-rpi java[469]: 2021-02-12 09:16:45.160 WARN [Main] Uncaught exception while handling measurements from MAC address ā€œ70722D707673ā€, if this repeats and this is not a Ruuvitag, consider blacklisting it
Feb 12 09:16:45 svp-rpi java[469]: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 4
Feb 12 09:16:45 svp-rpi java[469]: at fi.tkgwf.ruuvi.utils.Utils.getMacFromLine(Utils.java:53)
Feb 12 09:16:45 svp-rpi java[469]: at fi.tkgwf.ruuvi.Main.run(Main.java:98)
Feb 12 09:16:45 svp-rpi java[469]: at fi.tkgwf.ruuvi.Main.main(Main.java:45)
Feb 12 09:16:45 svp-rpi java[469]: 2021-02-12 09:16:45.231 DEBUG [Main] Offending line: > 04 0E 07 01 23 0C 00 00 00 1C

Any ideas on what to check?

You have some very special weirdness going on.
as mentioned in Nordic DevZone article MACs have high order 2 bits set, i.e. first digit will always be C , D, E or F!
Please run hcitool lescan a little longer and report additional addresses.

Love it when Iā€™ve got ā€œspecial weirdnessā€ā€¦ Iā€™ve been running hcitool lescan for about 5 minutes and received a couple of devices:

38:68:A4:1A:C0:6D [TV] Samsung Q80 Series (65)
22:31:6A:08:5C:F9 (unknown)
5C:F9:38:AF:28:B1 (unknown)
40:B8:9A:59:F7:A0 (unknown)
80:2B:F9:25:05:30 (unknown)
80:2B:F9:25:05:30 (unknown)
34:03:DE:2D:69:E1 (unknown)
5C:F9:38:AF:28:B1 (unknown)
B8:3A:9D:26:1A:27 (unknown)
34:03:DE:2D:69:E1 iBBQ

Iā€™ve had my tag for about a year and half. Is it possible that the battery is too low? It works on the Ruuvi app and is showing battery voltage of 2.9v.

Do you know the MAC of your RuuviTags? Like from an mobile phone app?

Regarding the battery: have you read FAQ Battery

Basically wither the battery is good enough or not (if not it may run periodically depending on temperature)

ps ā€œSpecial weirdnessā€ is a highly technical term,

I donā€™t know the Mac address, as the mobile app states that RAWv2 mode is required. Iā€™m in the process of upgrading the firmware now, so that Iā€™ll be able to get the MAC.

Guess I knew more technical terms than I thoughtā€¦

Got the firmware updated and can now see the MAC of the tag: Itā€™s showing up in the LE scan.

C8:2B:6B:37:B5:F9 (unknown)