jarkko-hautakorpi / iBeacon-indoor-positioning-demo

Indoor positioning of iBeacon tags (tagged people, dogs, cats and objects) by trilateration, using ESP32.
MIT License
183 stars 99 forks source link

Stations not showing up on dashboard #5

Closed brianh94 closed 5 years ago

brianh94 commented 5 years ago

I got the beacons to show up once on the dashboard, but the location of the beacon wasn't accurate. Unfortunately, I can't get any of the scanners to show up on the dashboard now, even though they are posting to the mosquitto server.

Here is a screenshot of the mosquitto server: image

The only errors I see are from the ESP32s: image

I'm not sure if this is related. Any help would be greatly appreciated. Thanks!

jarkko-hautakorpi commented 5 years ago

Try debugging JS to see what messages the dashboard is receiving. Are all three stations reporting some BT beacon/device? image

brianh94 commented 5 years ago

Yes, all stations show the beacon I'm using in the serial monitor. I noticed that when I did get the stations to show up, the stations were sending PUBLISH to the MQTT server (see img). However this behavior seems random and will go back to only pinging each station as seen in my original post. Does this mean the stations are scanning the device but not sending results to the server?

image

I will check the JS console as well to see if anything comes up there.

Thanks, Brian

brianh94 commented 5 years ago

I think I have found (part of) the issue. It seems that when the stations detect only one BT device, it is able to publish to the MQTT server successfully (PUB Result: 1). However, when the stations detect more than one device, it is unable to publish (PUB Result: 0). I'm not sure if it is because the payload is too large, it doesn't seem like it since the max length is 1844. What do you think might be the issue? I've attached a screenshot of the ESP32 serial monitor.

image

Thanks, Brian

brianh94 commented 5 years ago

I found a workaround to my previous comment by filtering the mac address I want so it only sends one device per publish. All three stations now seem to publish correctly and shows up in the dashboard.

However, my issue now is that the location is way off. It always shows near the middle no matter where I put the beacon. I moved it from the top of one station to another and the location in the dashboard didn't change.

I notice that the signal strengths do change when I move the beacon but there seems to be a problem when calculating the location. Any ideas?

image

Console: image

Thanks, Brian

jarkko-hautakorpi commented 5 years ago

What is the distance between the stations? Bluetooth RSSI is not accurate enough, for precise positioning, it is better for just "presence". Longer distances work "relatively more accurate". That's why companies have developed their own radio solutions. The distance between stations should be at least 7-15 meters to get somewhat reasonable direction of position.. First, use an Android- or iPhone to inspect your beacons, what is the transmit power (RX power). Then change this transmit power to file Positioner/PositionCalculator.js -file. Try adjusting the numbers in calculateDistance(rssi) -function for better results for your room/space.

brianh94 commented 5 years ago

With some tweaking to PositionCalculator I got much better results. Thank you!

simonbogh commented 5 years ago

I have the same problem, the station will only publish to MQTT when it finds only one device, tried to control it via bufferIndex because I have several devices in the area. Only then will the station show up in the list in the web interface. Also, the station will not show up as a black circle in the map layout. This is the only error I get in the JS console:

JSON Parse error: Unexpected identifier "Dashboard"          render — Floorplan.js:62
simonbogh commented 5 years ago

Learning more and more about the implementation :)

To answer my own questions:

  1. Stations only show up in the dashboard when you have 3 or more stations connected (makes sense)
  2. The problem with publishing more than one beacon is related to the PubSubClient library as mentioned in #4. To fix this I changed #define MQTT_MAX_PACKET_SIZE in PubSubClient.hto e.g. 2048 instead of 128. Even though MQTT_MAX_PACKET_SIZE is set in the Arduino sketch, it seems to get ignored

@brianh94 what did you do to improve the accuracy?

brianh94 commented 5 years ago

@simonbogh I was able to improve accuracy slightly by playing with the values in the calculateDistance function in Positioner/PositionCalculator.js (See @jarkko-hautakorpi's comment)

Ultimately I was not able to get the accuracy I wanted using bluetooth, primarily due to the large amount of noise in my environment. I am currently using a UWB-based solution from Decawave for indoor positioning.

simonbogh commented 5 years ago

Sounds interesting. Would you be able to share more, I am looking for an alternative and more precise solution as well.

brianh94 commented 5 years ago

@simonbogh I am using the Decawave MDEK1001 connected to a Raspberry Pi to read locations.

https://www.decawave.com/product/mdek1001-deployment-kit/

sourabhmisal commented 5 years ago

@brianh94 I am not getting the esp32 on the floor map even after filtering out the beacon which i want the stations to scan . I noticed that you got the output on pi , so i also tried running on pi but while running the react app , when i am installing the node modules , there are many errors popping like 'type error of eslint' and 'webpack not a function'
i am searching the internet for resolving the errors but with no success Did you face such problems ? if yes , could you guide me to run it seamlessly?...

sourabhmisal commented 5 years ago

And @simonbogh thank you for guiding me to this issue , from this issue , i could get the idea of scanning the beacons i want to show on the floor map How did you get the beacons showing on the map? Could you also guide me to it?

sourabhmisal commented 5 years ago

@brianh94 , @simonbogh and @jarkko-hautakorpi what should be the server address entered in MessageStack/config.js for a) When i am running on the same computer (pi) where the mosquitto broker is running ? (Is it 127.0.0.1) b) When i want to access the mosquitto broker from another computer on the same network? (is it xxx:xx:xx:xxx:9001) I tried both the ways but the stations are not appearing on the react app.. Any solutions please?...

sourabhmisal commented 5 years ago

The hardware side is working perfectly and showing on the terminal and the react app also works fine but the esp32 stations are not showing on the floor map... Please help me out in figuring out the correct way of connecting the react app to the mqtt server , there are no proper way shown for connecting the react app to the mqtt server...

simonbogh commented 5 years ago

@sourabhmisal

  1. For the mqtt broker with Mosquito i only changed the conf file to the correct path as mentioned on the front page
  2. For the ESP32 i changed credentials.h with my wifi info and the ip for the computer running Mosquitto
  3. Changed MQTT_MAX_PACKET_SIZE to 2048 in PubSubClient.h. I added the library next to my arduino sketch.

After that, check the Javascript console in Chrome or another browser and check if it says something like: num stations. The stations will not show in the map until three stations are connected.

From the serial console you should also see the ESP32 connect and send to the mqtt server. Check if it says PUB result 1.

sourabhmisal commented 5 years ago

Thank you @simonbogh Did you change the server address at MessageStack/config.js before running the react app or just ran it without changing anything? And i am doing all the things u mentioned above , i ll tell u the results in 2 hours..

simonbogh commented 5 years ago

No, I left config.js at its defaults, nothing changed.

sourabhmisal commented 5 years ago

2019-04-19-104116_1366x768_scrot i am getting socket error .. did you face this issue?

sourabhmisal commented 5 years ago

2019-04-19-120132_1366x768_scrot @simonbogh I got the output , thank you so much for guiding me since @brianh94 mentioned about the usage of uwb solution for tracking , i will search for it

simonbogh commented 5 years ago

Glad to hear it is working now @sourabhmisal.

Yes, UWB (ultra-wideband) sounds very promising. After reading more about it, it sounds like you can get accuracy at around +/- 10 cm and over much larger distances than Bluetooth.

One downside is price though, as it looks like the devices are perhaps a factor 10x more expensive than cheap ESP32 devices.

simonbogh commented 5 years ago

@simonbogh I am using the Decawave MDEK1001 connected to a Raspberry Pi to read locations.

https://www.decawave.com/product/mdek1001-deployment-kit/

Very interesting @brianh94. Do you need a Raspberry Pi for each unit or only the anchors or maybe units you want to track?

brianh94 commented 5 years ago

@simonbogh

The anchors are standalone since all calculations are done within the provided firmware. I currently have a Pi connected to the tag I am tracking to read location data from the API and display on a screen. You can take a look at the quick start guide and other documentation in the link above to get a sense of the set-up.

I agree the price is much higher than an ESP32 but this is actually on the cheap side for UWB transceivers and this level of accuracy is just not possible with Bluetooth or WiFi.

This article does a great job explaining why: https://www.electronicdesign.com/communications/what-s-difference-between-measuring-location-uwb-wi-fi-and-bluetooth

simonbogh commented 5 years ago

@brianh94

That is nice, so it is fairly easy to get up and running.

You are right, the price is quite good for UWB. I found some commercial systems using UWB, and it is quite pricy.

Thanks for the link and info, will check it out.