How to get data from the sensortag on a raspberry pi

Details for both firmware build and raspberry pi Border router and scripts are provided in the product documentation

First you need to install a boarder router on the raspberry pi or on your sever

A python script is then listening on udp broadcasts

how do u insert the data into influxDB?

once the data is on MQTT, you can use Node-RED with an influxDB plugin which is pretty common for a solution without coding.
The way I’m doing it, I’m using a python script. It’s a script I customized to avoid common issues like enforcing types otherwise errors might happen.
To be more specific, inside the python script, the CliendDB writing happens right here :

The previous multiple elif conditions are there to support different MQTT topics patters. To manage the huge number of sensors, I have a configuration file for the subscription list and a name conversion so that I create a friendly database name from a complex topic name :

is it easier to do a restful call to influxDB? isn’t that what InfluxDBClient does underneath?

I did not understood your question. Python posts data to the influx Database. Then data is used from Grafana dashboard.
You can post data to influx in multiple ways : python, nodered, javascript, command line,… they all go through the network at the end through the influx API.

I was wondering what the influxDB library does that allow a remote rasp pi to insert data into the influxDB, I think it uses a Rest api. if that’s the case, then i can insert data into the database directly with the esp boards. instead of doing mqtt to a rasp pi and run a script to insert it.

btw i haven’t touch much of the rasp pi stuff so i’m still learning how things work. Do u run a python script that handle messages from the sensor tag and decided which script to run?

Yes of course, all those libraries are simply there to make simpler with native language support, but you can do the same with raw REST and write your own, see examples with curl even

But creating such a lib can take some effort but unfortunately as you’re not the first one having thought of that, here’s an Arduino influxDB lib example

Testing on a PC first windows or linux is much easier to get started and understand the concepts before you add the complexity of uC flash, slow test cycles,…

oh that’s great. thanks. i dont hav to worry about it then. I’m still trying to understand how the sensor tag communicate with the rasp pi. so the rasp pi also supports thread?

ok, i think i get it, maybe. so the sensor tag communicates with the nrf dongle which connect to the rasp pi through the usb port and u get data from remote tags using the dongle. am i correct?

Correct, here’s a more detailed explanation on the openthread website about the host dongle communication.
You can see here the whole stack until the ipv6 layer, spinnel is the binary communication protocol with the raspberry pi,

but there are also examples where you have a serial command line dongle to experiment with text commands

did u test the range of the sensor tag to the dongle? how far is it on average?

Me personally I didn’t because it’s way beyond the range I need for my use case in an apartment.
But first important to notice that the range depend mainly on transmission power, then also on bitrate, the lower, the higher the range.

  • nRF51 and nRF52832 have tx +4 dBm
  • nRF52840 has tx +8 dBm

Here is a very good reference of range tests with Zigbee Bluetooth and thread, although they all use the same RF Phy, BLE long range naturally wins due to the usage of low bitrate. Notice that high power and low bitrate are the worst enemies of low power, in other words and in short the longer the range the higher the power.

Max with BLE @ 125kbps (long-range) with +8 dBm 756m

i see. thanks. if i have any success with the nrf51, i may consider trying the ebyte e73 module, it’s the cheapest nrf52 i can find. i’m mostly interested in reducing the power consumption so i will go for the lowest tx power and bitrate, the range doesn’t seem to be an issue for my use cases either. Do u happen to hav a comparison between ble5 and thread? i guess in sleep mode it would be the same since u r using the same module, just the rx and tx mode.

Cool. For nRF52 modules pay attention on the flash and ram size, I usually document the build log that shows flash, ram size and percentage. You can check in case you plan to use big libraries, they don’t all fit everywhere.
For BT and Thread, I don’t have a power comparision, they both have sleepy end device concepts. I’d be interested to see that too.
Note that bitrate is opposed to power, the lower the bitrate the longer you have to keep rf active.
Given my low dev capa (not enough time) I have to skip BT alltogether. For nRF51 and NRF52832 I’ll keep using my custom simplemesh that I updated and now being ported on Zephyr, for NRF52840 and later, I’ll be using openthread. Also, for hard real time RF requirements, it might be that custom rf is more appropriate.

I want to understand how the nrf51 works at the low level. do u hav a very simple example showing how an nrf51 send data to another one or multiple one? there should be example code available somewhere no?

Yes, sure, what I suggest is to start a new Topic because this is now no longer related to the original “How to get data from the sensortag on a raspberry pi”. Something like “nRF5x Radio communication examples”. I created x3 subcategories under the “Network category”

@uni as we already started this topic here, you question about sensors view and analysis relates to it.
If you need to only show average of last day or such simple things, then Grafana can add such measures for the dashboard.
Now for exploring, complex filtering and display, Python is a scientific analysis tool like Matlab in better, even adding machine learning and so on.
Python is multi os, so same code runs on pc and rasp, I usually write Python and test on PC then run on rasp, I even created a config system where I have a different config file for each server which is “config_hostname.json” that way I can alternate between windows pc and all rasp I have with the same repo commit

Also on pc you can run python from a jupyter notebook, which is a practical how how usually people do analysis, I even have some notebook examples for home sensors here (name ml but did not do ml yet, just preparation)

oki. thanks. i will look into it.

@wassfila did u have to setup the rasp so that it automatically run a python script upon starting up?