indoor location sensor (BLE scan + RSSI to MQTT publishing)

bietiekay
Posts: 1
Joined: Fri Mar 17, 2017 1:34 pm

indoor location sensor (BLE scan + RSSI to MQTT publishing)

Postby bietiekay » Tue May 09, 2017 12:54 pm

I am currently trying my first little project with ESP32 devkit-c and i am running into a multitude of trial-and-error aspects.

What I want to do is this:

(1) make esp32 connect to wifi access point, get IP
(2) connect to an mqtt broker and subscribe to a topic to receive commands
(3) run this loop:
- start BLE scan to scan for BLE device announcements and get the RSSI of the received signal
- send this id (xx:xx:xx:xx + RSSI) to a specific MQTT topic for each found device
(4) keep the loop running and constantly scan for devices - everytime its found the information is sent again to the mqtt topic

(5) on a separate machine/pc the mqtt topic messages are consumed and used to (with knowledge of the location of the esp32 in the house) calculate estimated locations of the devices measured - and moreso, with enough ESP32 also the movement inside the house.

So it will end up with something like this on the mqtt topic:

/location/device_scan/63537dd710ac -74
/location/device_scan/6fd0d06583d0 -68
/location/device_scan/8863dfc2a182 -71
/location/device_scan/55da923818d1 -77
/location/device_scan/62c54c174775 -90
..
..
..


My first tries implementing this can be found here:

https://github.com/bietiekay/hcs-esp32- ... ensor-node

But its constantly crashing and overall behaving erratically. I would really appreciate any help possible to get this stable running and just doing the above job.


Daniel

ESP_Sprite
Posts: 9703
Joined: Thu Nov 26, 2015 4:08 am

Re: indoor location sensor (BLE scan + RSSI to MQTT publishing)

Postby ESP_Sprite » Wed May 10, 2017 2:11 am

How is it 'constantly crashing and behaving erratically'? Do you have crash logs, backtraces, ...?

A quick glance over your code: It seems you try to send the mqtt response from the gat event handler, right? From memory, this runs in one of the BT tasks, not in the main task where you have started mqtt. I could be wrong (don't know the mqtt code that well), but this probably leads to concurrency issues on the MQTT side of things. It's better to let the BT code dump its data into a FreeRTOS queue or something, then read the data from the queue in the main thread to send it to the mqtt code there.

Who is online

Users browsing this forum: Accound and 75 guests