commit
d0d09eb205
|
@ -1,7 +1,7 @@
|
|||
# Tracking an Android phone
|
||||
<img src="./images/beacon_scope_android.jpg" style="float:right;margin:24px;" width=200>
|
||||
<img src="./images/beacon_scope_android.jpg" style="float:right;margin:24px;width:200px">
|
||||
|
||||
It is possible to track your Android phone by installing a simple beacon broadcasting app. I have used [Beacon Simulator](https://play.google.com/store/apps/details?id=net.alea.beaconsimulator) and [Beacon Scope](https://play.google.com/store/apps/details?id=com.davidgyoungtech.beaconscanner).
|
||||
It is possible to track your Android phone by installing a simple beacon broadcasting app. I have the best results from the [Beacon Scope](https://play.google.com/store/apps/details?id=com.davidgyoungtech.beaconscanner) app. You may also want to try [Beacon Simulator](https://play.google.com/store/apps/details?id=net.alea.beaconsimulator), although I've experienced some issues with it.
|
||||
|
||||
### Setup
|
||||
You can use any iBeacon UUID in the app. Whatever you choose, ensure that it matches exactly with your entry in the Home Assistant configuration, including both the `major` and `minor` version numbers. An example phone configuration could be:
|
||||
|
@ -25,3 +25,6 @@ Both Android and iPhone use a strategy of [Bluetooth MAC address randomization](
|
|||
|
||||
### Known Issues
|
||||
With the release of advanced battery management, Android now has a habit of killing background processes. This means that you may not be able to track your phone consistently. I have yet to find a solution for this problem - if you know of one, please open an issue.
|
||||
|
||||
### Troubleshooting
|
||||
See the [troubleshooting page](./troubleshooting) for some strategies to help debug problems.
|
||||
|
|
|
@ -10,7 +10,7 @@ If you have a different BLE-enabled piece of hardware that you have gotten to wo
|
|||
## Device ID
|
||||
To track generic BLE advertisements, you will need to know the hardware MAC address of the device. You can use an app on your smart phone to scan for and identify the correct device - I recommend [NRF Connect](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) from [Nordic Semiconductor](https://play.google.com/store/apps/dev?id=7265678888812659353) for Android (and I believe there is an iOS version as well).
|
||||
|
||||
Alternatively, you can subscribe to the `room_presence` topic and view what devices are being reported there. Note that modern smart phones will randomize their hardware MAC address when broadcasting advertisements, so you must use a beacon app to track your phone (see the [section on tracking phones](./android.html) for more information).
|
||||
Alternatively, you can subscribe to the `room_presence` topic and view what devices are being reported there. Note that modern smart phones will randomize their hardware MAC address when broadcasting advertisements, so you must use a beacon app to track your phone (see the [section on tracking phones](./android) for more information).
|
||||
|
||||
To track the device, specify the `device_id` entry as the hardware MAC address, without the colons.
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 85 KiB |
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 160 KiB |
|
@ -3,6 +3,22 @@
|
|||
<a href="https://github.com/jptrsn/ESP32-mqtt-room" title="View the project on GitHub"><img src="./images/github.svg" style="position:fixed;top:16px;right:25%"></a>
|
||||
An ESP32 based presence detection node for use with the [Home Assistant](https://www.home-assistant.io/) [`mqtt_room` component](https://www.home-assistant.io/components/sensor.mqtt_room/) for localized device presence detection.
|
||||
|
||||
# Contents
|
||||
1. [Requirements](#requirements)
|
||||
2. [Getting Started](#getting-started)
|
||||
1. [Flashing the Hardware](#flashing-the-hardware)
|
||||
2. [Define Settings](#define-your-settings)
|
||||
3. [Flashing the device via USB](#flashing-the-device-via-usb)
|
||||
4. [Flashing/updating via OTA](#flashing-via-ota)
|
||||
3. [Home Assistant Configuration](#home-assistant-configuration)
|
||||
4. [Trackable Devices](#trackable-devices)
|
||||
1. [Beacons](#beacons)
|
||||
2. [Generic BLE Devices](#generic-ble-devices)
|
||||
3. [Android Phones](#tracking-android-phone)
|
||||
4. [iPhones](#tracking-iphone)
|
||||
5. [Credits](#credits)
|
||||
6. [Troubleshooting](#troubleshooting)
|
||||
|
||||
|
||||
## Requirements
|
||||
You're going to need the following items:
|
||||
|
@ -14,7 +30,7 @@ You're going to need the following items:
|
|||
|
||||
## Getting Started
|
||||
|
||||
### Flashing the Hardware (ESP32)
|
||||
### Flashing the Hardware
|
||||
You can get started by cloning this repository to your local machine using git. Alternatively, you can [download the zip](https://github.com/jptrsn/ESP32-mqtt-room/archive/master.zip). To get the code onto your device, thanks to some great work by [kylegordon](https://github.com/kylegordon), you can now build and upload using PlatformIO.
|
||||
|
||||
### Define your settings
|
||||
|
@ -23,22 +39,21 @@ Create a copy of the `Settings.h` file, and rename it to `Settings_local.h` or s
|
|||
### Flashing the device via USB
|
||||
Open the project folder in Atom, using the `open project` option in the PlatformIO Home screen. Modify the settings in the `Settings_local.h` file to match your environment. Set the correct port in the `platformio.ini` file (or remove the line to use auto-detection), and upload to the board. Open the serial monitor after successful upload to check for success.
|
||||
|
||||
### Flashing/updating via OTA
|
||||
### Flashing via OTA
|
||||
It is possible to update the device using "Over the Air" (OTA) updates from the command line interface of PlatformIO. You will need to know the IP address of the device itself (check your router). From the command line, enter the command `platformio run -t upload --upload-port {{Device IP Address}}`. During the update process, you will see the on-board LED blinking slowly. Once the update has completed, you should see the device reconnect and update its telemetry.
|
||||
|
||||
## Home Assistant Configuration
|
||||
See the section on [configuring Home Assistant](./home_assistant.html).
|
||||
See the section on [configuring Home Assistant](./home_assistant).
|
||||
|
||||
## Trackable Devices
|
||||
### Beacons
|
||||
See the section on [tracking beacons](./beacons.html)
|
||||
|
||||
### Generic Bluetooth Low-Energy (BLE) Devices
|
||||
Some other devices that advertise as BLE (such as the Mi Flora plant sensors or the Mi Band fitness tracker) can also be tracked, as long as you can scan the device and see its hardware ID. See the section on [tracking generic BLE devices](./generic_ble.html).
|
||||
See the section on [tracking beacons](./beacons)
|
||||
|
||||
### Generic BLE Devices
|
||||
Some other devices that advertise as BLE (such as the Mi Flora plant sensors or the Mi Band fitness tracker) can also be tracked, as long as you can scan the device and see its hardware ID. See the section on [tracking generic BLE devices](./generic_ble).
|
||||
|
||||
### Tracking Android Phone
|
||||
[Read more here](./android.html) about getting your Android phone configured and tracked.
|
||||
[Read more here](./android) about getting your Android phone configured and tracked.
|
||||
|
||||
### Tracking iPhone
|
||||
Unfortunately, Apple does not allow devices to advertise iBeacon data in the background. As I do not own an iPhone, I will not attempt to implement scanning and reporting by device name, but I welcome pull requests.
|
||||
|
@ -51,3 +66,6 @@ This depends heavily on the hard work done by a number of people.
|
|||
* **Benoit Blanchon** [(GitHub)](https://github.com/bblanchon/ArduinoJson) - provided the Arduino JSON library
|
||||
* **Me No Dev** [(GitHub)](https://github.com/me-no-dev/AsyncTCP) - provided the async TCP library
|
||||
* **Kyle Gordon** [(GitHub)](https://github.com/kylegordon) - PlatformIO support
|
||||
|
||||
## Troubleshooting
|
||||
If you're having difficulty getting things set up and work properly, check out [the troubleshooting section](./troubleshooting) before you open an issue. It will help you determine what information you need to provide to identify and fix what's gone wrong.
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# Release Notes
|
||||
|
||||
### V0.0.6
|
||||
#### 2019-07-18
|
||||
|
||||
- Updated platform `espressif32` to 1.9.0
|
||||
- Fix for issue #14 OTA updates
|
||||
- Updated `.pioenvs` folder
|
||||
|
||||
### V0.0.5
|
||||
#### 2019-03-19
|
||||
|
||||
- Updated ArduinoJSON dependency to version 6.
|
||||
|
||||
### V0.0.4
|
||||
#### 2019-02-10
|
||||
|
||||
- Added `maxDistance` setting to `config_local.h`. Unit is a non-zero integer in meters.
|
||||
- Fix for AsyncTCP update with breaking changes
|
||||
|
||||
### V0.0.3
|
||||
#### 2018-12-10
|
||||
|
||||
- Improved stability for the watchdog timer issue.
|
||||
- Self-recovery for most crashes.
|
||||
- Configurable LWT topic
|
||||
- Over-the-Air updates are now possible from the command line of PlatformIO.
|
||||
- On-board LED as status indicator
|
||||
|
||||
### V0.0.2
|
||||
#### 2018-12-10
|
||||
- Improvements to prevent watchdog timeout as in #1.
|
||||
- PlatformIO build and upload support.
|
|
@ -0,0 +1,67 @@
|
|||
# Troubleshooting
|
||||
It can be a challenge to troubleshoot problems with tracking a beacon, as the problem can exist in different places in the "information pipeline." The flow of information can be visualized in the following way:
|
||||
|
||||

|
||||
|
||||
1. Beacon broadcasts an advertisement packet.
|
||||
2. ESP32 collects the broadcast (green arrow)
|
||||
3. ESP32 verifies connection to WiFi (orange arrow)
|
||||
4. ESP32 verifies connection to MQTT (yellow arrow)
|
||||
5. MQTT publishes data to `room_presence` topic (purple arrow)
|
||||
6. Home Assistant parses information and reports configured sensorsiot
|
||||
|
||||
## Logging
|
||||
There are various logs that can help identify the step in the information flow that is the broken link in the chain. If you're submitting an issue, be sure to include the logs that show the problematic behaviour
|
||||
|
||||
### Broadcasting (green arrow)
|
||||
To view the advertisements coming from your beacon, you can use an App on a BLE-enabled device. I recommend using [NRF Connect](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp) for Android to view all advertised devices in your area. Once you've found the device you're interested in, you can use [Beacon Scope](https://play.google.com/store/apps/details?id=com.davidgyoungtech.beaconscanner) to connect to and view information about your beacon, which can help in determining the correct setup.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
If you do not see your device advertising, then you know that the problem lies in your beacon device itself, rather than with this project.
|
||||
|
||||
### ESP32 WiFi (orange arrow)
|
||||
Your ESP32 will attempt to connect to the wireless network you specified in your configuration file. While disconnected, the on-board status LED (if available) should be lit, in addition to the power LED (which is always on when the ESP32 is powered up).
|
||||
|
||||
You can connect to your ESP32 over a USB cable and open a serial monitor (there is one built into PlatformIO, or you can use another serial monitor such as the Arduino IDE or putty on Windows). Reset the device (using the on-board reset button), and watch the messages that are logged. You should see a message indicating that it connected to your WiFi, and the IP address it has been assigned.
|
||||
```
|
||||
Connecting to WiFi...
|
||||
[WiFi-event] event: 0Wifi Ready
|
||||
[WiFi-event] event: 2STA Start
|
||||
[WiFi-event] event: 4
|
||||
[WiFi-event] event: 7
|
||||
IP address: 192.168.1.104
|
||||
Hostname: esp32_d
|
||||
Connecting to MQTT
|
||||
Stopping wifi reconnect timer
|
||||
```
|
||||
|
||||
If your device won't connect to your wireless network, copy and paste any logs you see into your issue.
|
||||
|
||||
### ESP32 MQTT (yellow arrow)
|
||||
To report devices, the ESP32 must be connected to your MQTT server. It will attempt to connect once it has established a connection to your wireless network. Once connected, the device will publish a status message ("CONNECTED") to the `availabilityTopic` as defined in your settings. It also publishes your configuration information to the `telemetryTopic` which consists of:
|
||||
* **room**: the configured room name
|
||||
* **ip**: the assigned IP address of the device
|
||||
* **hostname**: the host name, used for WiFi as well as client ID for MQTT (must be unique on your network)
|
||||
* **scan_dur**: the scan duration, in seconds
|
||||
* **wait_dur**: the wait duration between scans, in seconds
|
||||
* **max_dist**: the maximum distance within which to report devices, in meters
|
||||
* **disc_ct**: the number of devices discovered in the last scan
|
||||
* **rept_ct**: the number of devices reported in the last scan (this is all discovered devices where the distance is beneath the max_dist threshold)
|
||||
|
||||

|
||||
|
||||
If you do not see any information being published to either the `availabilityTopic` or `telemetryTopic` then you will want to connect to the serial monitor and check the logs. Verify that your MQTT user name and password is correct, and check the logs on your MQTT server itself. You should see it reporting a new client connected from the ESP32's IP address:
|
||||
```
|
||||
New client connected from 192.168.1.104 as esp32_d (c1, k60, u'my_mqtt_username').
|
||||
```
|
||||
|
||||
### Home Assistant (purple arrow)
|
||||
In order to see devices, you will need to [configure Home Assistant correctly](./home_assistant). You can add a device as an iBeacon, or you can add [generic BLE hardware](./generic_ble) using its hardware MAC address.
|
||||
|
||||
To view what devices are being reported on the MQTT topic, you can use a tool such as [mosquitto_sub](https://mosquitto.org/man/mosquitto_sub-1.html) to connect to and view what is being reported. This will provide you with the data format you'll need to follow when writing the configuration:
|
||||
```
|
||||
mosquitto_sub -h {{mqtt server IP address}} -u {{my mqtt user}} -P {{my mqtt password}} -i presence-information -v -t "room_presence/#" | ts
|
||||
```
|
Loading…
Reference in New Issue