Help needed- Sending notification/advertising to RaspberryPi-


#1

Hi all,

First of all, I am fairly new to all this and I am working on a project using ruuvitag and a RaspberryPi. I am trying to detect movement and send notification/advertising from ruuvitag which then RPi receives (python script).

  1. instead of Pi and ruuvitag connected to each other and sending the raw accelerometer all the time, is it possible to process accelerometer data on the ruuvitag side and send advertising when necessary?
    or is the other way more efficient?

  2. and is it possible for ruuvitag to use NRF advertising on Espruino firmware?

I would appreciate any help or suggestion.

Thanks


#2
  1. I’m pretty sure your RuuviTag and RPi are not connected. RuuviTag is just advertising manufacturer specific Bluetooth packets (RAW mode) and the RPi listens. It’s more than possible to modify the firmware and then advertise only if certain accelerometer thresholds are exceeded but it’s a lot easier to just leave the Tag as it is listen and trigger alerts on the RPi side.

  2. Yes :muscle:


#3

Hi again, I am reading data broadcasted by ruuvitag from RPi using ruuvitag sensor python lib, however it takes long time to receive a new broadcasted data (10-15sec). is there a way to minimize this latency?. I would like to get realtime feedback from the tag. I am using modified weather station firmware shared in the forum.


#4

If latency is critical, you should use connectable GATT profile and notifications. We’re building a GATT profile, you can follow the progress at ruuvilab


#5

Hi,

There should be no problem with that firmware. I use it everyday and the only problems I have are battery problems.
Which python library/program are you using? The one I use is the one I wrote. It can be found at https://github.com/frawau/aioblescan . You can also install it via
pip3 install aioblescan

To test try

 python3 -m aioblescan -r

This expects your BLE hardware to be hci0 and it has only been tested on Linux

Cheers
François


#6

Hi,

I was using this ruuvitag sensor library. I was not able to try out aioblescan library since my project is written in python2. I will give it a try and if it works fine, I might as well move to python3 instead.
Since you mentioned battery problem, how long does it last approximately?

Thanks
Heekwon


#7

Hi,

I said that I only had battery problems just because those are to be expected. The firmware was “power profiled” by otso and the battery should last 2 - 3 years. My personal experience is that it is a bit shorter (1 year) , but the tags were used for development and that probably drained the battery faster.

To test aioblescan you only need to have python 3 installed, but in my experience python3 with asyncio is really fast.

Let me know how the test goes.

Cheers


#8

Hi frawau,

your firmware and python library aioblescan works great. I will be setting the tag side-way-up on to the door or a desk drawer for example, but acceleration data received is not accurate and yes I understand this is due to the orientation of the tag. Would you mind asking how you would go about solving this? I ‘sort of’ applied high-pass filter to zero out and detect any movement regardless of orientation but sometimes data is not responsive enough.

Thanks,
Heekwon


#9

Hi Heekwon,

Here is how I did in my system (AutoBuddy)

First I “calibrate” the tag. I use samples (200 in my case) and I average the value on each axis. I then use that as the “zero” value and subtract it from subsequent measurements to normalize them.

After that I detect movement using the “vector” (i.e. sqrt(x^2 + y^2 + z^2) with x,y,z normalized) If I get a vector > 200 I detect movement.

You could bypass the normalization step and compare the vector value to 1000 (milli g) which should be the vector value at rest.

Hope this help.

François

#10

Also… make sure you use mode 3 of the firmware.