Looked at the code and I understand what you mean. Agree that this separation would indeed make the code cleaner as well as more testable.
Let me know if I can help in any way, review the code or similar. When you have separated parsers from the rest, let me know and I can have a look.
Btw, it might be that the maven central part is actually not so important for me personally since I probably have to distribute the parser .jar inside the openHAB/eclipse smarthome code base (maven <dependencies> are not used there for whatever OSGI/setup reason).
Yeah now that I think about it probably the first step is to simply copy/refactor the code out into another repository as a “pre-release version”, then do the cleanup/documentation, write tests, etc. to eventually make it a “clean 1.0 version” of the library, and once all that is done then publish it to maven central or so and only then refactor RuuviCollector to use the library.
Slightly more work (and duplicate code while working on it) to do it in “individual steps over time” like this, but on the other hand it makes the library usable earlier on before the “stable 1.0 release” is ready and published to maven central. I might actually have time to do the “first step” during this weekend, if so I’ll let you know so you (or anyone else) can review, comment and/or contribute.
Alright I created the repository now: https://github.com/Scrin/ruuvitag-common-java/ and did some light and untested (well, I tested that the code compiles but nothing more ) refactoring and basically set up the base foundation for the library. In theory it might actually already work as it is, but there’s still much to do. Comments, suggestions and contributions are more than welcome (here on the forums, Ruuvi slack, or on Github)
All but given up on this.
Clearly its beyond my level of competence as the link to the raspberrypi website, here:
has several options I cant follow; I am not using a cable and whilst I can see the RuuviGW network but cant connect to and have no wif networks detected on the Rpi GUI, so I end up with no connection on the router.
Its the Rpi instructions I find difficult and obciouslly some of the changes have already been made but some are still needed, static ip addressing etc, so would it be possible for someone to clarify what specific changes to the Rpi are needed?
Thanks in advance
Hi. I don’t seem to be able to get any data to show on Grafana. The InfluxDB is on, RuuviCollector is on and listening. HCItool lescan gives Input/Output error which it didn’t give before I rebooted the machine. I tried to reset it with hciconfig hci0 reset, which worked yesterday in this same error but now it doesn’t. I made the image/built according to https://blog.ruuvi.com/rpi-gateway-6e4a5b676510 . I also tried with the latest Ruuviberry image I could find, but that also had somewhat similar problems.
I tried to fix the hcitool error with restarting bluetooth and dbus but the system went on to some weird limbo and I had to unplug the machine for it to work. I’m kind of in a dead end and would appreciate if anyone is able to suggest something.
As far as I know Grafana / InfluxDB does not support this in an easy manner, you’d probably need some kind of continuous query which creates difference data . @Scrin would you happen to know an elegant way to do this?
As far as I know you are correct, InfluxDB does not support on-the-fly calculation between separate measurements (pressure values from two different measurements in this case), and as far as I know, the InfluxDB builtin Continuous Queries are restricted by this same limitation. The method recommended by InfluxData is to use Kapacitor, which is their data processing engine, to perform this kind of calculations.
I used to have Kapacitor tickscripts created for calculating some of the “extra values” (such as dew point and absolute humidity), but I have since implemented them straight into the collector itself because Kapacitor tickscripts are rather clumsy to work with compared to doing the same with Java straight in RuuviCollector.
so, adding “temperature” in “field(value)” didn’t work.
We showed the project to our teacher and his opinion was that somehow the RuuviCollector isn’t sending data. Now we are trying to build the ruuvicollector again, but now the building is giving errors/failures.
We then tried modifying the values inside ruuvicollector properties file, and with modifying “influxBatchMaxSize=2000” to 1234 and “limitingStrategy.defaultWithMotionSensitivity.threshold=0.05” to 0.06. This got rid of two “failures”. The building worked without properties file, but that didn’t give any data last time so that’s why we are trying to get this to work with the properties file.
Also, continuity to my last problem, hcitool. We noticed/remembered that line "sudo setcap ‘cap_net_raw,cap_net_admin+eip’ which hcidump gave an usage error for setcap.
systemctl status ruuvicollector # NB may show last failure even if ruuvicollector is running OK
systemctl status influxdb
ps -el |grep hci # find all things bluetooth
ps -el |grep Ruuvi
ls -ltra /var/log | tail # show last several most recently updated logs
and copy / paste results here ( Not screen print which omits information)
influxdb takes a while to get ready to accept transactions (especially after a powerfail)
I have found it helpful to add this to RuuviCollectorStart.sh just before java -jar target/ruuvi-collector-*.jar
for i in 240 220 200 180 160 140 120 100 80 60 40 20
logger " ++ RuuviCollector sleeping $i more seconds to give influx a start."
To slow down influxdb restarts after failures add this to service section of /etc/systemd/system/influxd.service
so for the first one (I wasn’t sure how much you wanted from it so I copied everything):
pi@raspberrypi:~ $ hcidump |head -30
bash: hcidump: komentoa ei löydy
pi@raspberrypi:~ $ systemctl status ruuvicollector
Unit ruuvicollector.service could not be found.
pi@raspberrypi:~ $ systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series databa
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset:
Active: active (running) since Sat 2019-03-23 14:39:11 EET; 3 days ago
Main PID: 465 (influxd)
└─465 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
maalis 27 10:39:39 raspberrypi influxd: ts=2019-03-27T08:39:39.195924Z lvl=
maalis 27 10:39:39 raspberrypi influxd: ts=2019-03-27T08:39:39.196382Z lvl=
maalis 27 11:09:39 raspberrypi influxd: ts=2019-03-27T09:09:39.195830Z lvl=
maalis 27 11:09:39 raspberrypi influxd: ts=2019-03-27T09:09:39.196198Z lvl=
maalis 27 11:39:39 raspberrypi influxd: ts=2019-03-27T09:39:39.195891Z lvl=
maalis 27 11:39:39 raspberrypi influxd: ts=2019-03-27T09:39:39.196299Z lvl=
maalis 27 12:09:39 raspberrypi influxd: ts=2019-03-27T10:09:39.195862Z lvl=
maalis 27 12:09:39 raspberrypi influxd: ts=2019-03-27T10:09:39.198984Z lvl=
maalis 27 12:39:39 raspberrypi influxd: ts=2019-03-27T10:39:39.195894Z lvl=
maalis 27 12:39:39 raspberrypi influxd: ts=2019-03-27T10:39:39.196274Z lvl=
I can’t get status for ruuvicollector as it cannot be compiled with the errors I’m having, so it’s not running. If I recall correctly it compiles without the properties file, but I want to have it with the properties file. The errors should be in my previous command. I still have them if you would prefer them in text. For the first command
hcidump |head -30
I have the bluez installed, but I don’t know why it doesn’t work, though in the end it gave me
pi@raspberrypi:~/Documents/bluez-5.50 $ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-03-27 13:07:27 EET; 8s ago
Main PID: 3473 (bluetoothd)
└─3473 /usr/local/libexec/bluetooth/bluetoothd --experimental
maalis 27 13:07:26 raspberrypi systemd: Starting Bluetooth service…
maalis 27 13:07:27 raspberrypi bluetoothd: Bluetooth daemon 5.50
maalis 27 13:07:27 raspberrypi systemd: Started Bluetooth service.
maalis 27 13:07:27 raspberrypi bluetoothd: Starting SDP server
maalis 27 13:07:27 raspberrypi bluetoothd: Bluetooth management interface 1.14 initialized
maalis 27 13:07:27 raspberrypi bluetoothd: Failed to set privacy: Rejected (0x0b)
maalis 27 13:07:27 raspberrypi bluetoothd: Endpoint registered: sender=:1.39 path=/A2DP/SBC/Source/1
should work without any “usage errors”. After these RuuviCollector should be able to get the data.
If not, you can try troubleshooting it by first stopping ruuvicollector and then running:
hcitool lescan --duplicates --passive
in one terminal window, it should print some lines as it receives various BLE data. While that is running in one terminal window, run this in another:
this should print out all the raw data that’s received (as long as hcitool is running in another window!). If you encounter any erros with these, you could try googling for help. Once those works, then RuuviCollector should work too, as RuuviCollector runs those two commands internally.