EspWifiTracker: Difference between revisions

From RevSpace
Jump to navigation Jump to search
(Add link to datasheet)
No edit summary
Line 29: Line 29:
I'm basing this off an inexpensive [http://nodemcu.com/index_en.html NodeMCU] clone.
I'm basing this off an inexpensive [http://nodemcu.com/index_en.html NodeMCU] clone.
The NodeMCU is basically an ESP8266-module on a break-out board with an USB-serial converter and a proper 3.3V power supply.
The NodeMCU is basically an ESP8266-module on a break-out board with an USB-serial converter and a proper 3.3V power supply.
The ESP8266 is a WiFi-capable microcontroller, capable of running at 80 MHz and having 1 MB of flash onboard.
The ESP8266 is a WiFi-capable microcontroller, capable of running at 80 MHz, it has 1 MB (or more) of flash onboard which enough spare flash sectors to hold a file system.


To wake up periodically, I'm using a ZS-042 clock module, containing a Maxim DS3231 RTC chip
To wake up periodically, I'm using a ZS-042 clock module, containing a Maxim DS3231 RTC chip
[https://datasheets.maximintegrated.com/en/ds/DS3231.pdf datasheet].
[https://datasheets.maximintegrated.com/en/ds/DS3231.pdf (datasheet)].
This module is attached to the NodeMCU through the I2C-bus on pins D1 (SCL) and D2 (SDA).
This module is attached to the NodeMCU through the I2C-bus on pins D1 (SCL) and D2 (SDA).


Line 46: Line 46:
My prototype software can be found at:
My prototype software can be found at:
https://github.com/bertrik/wifitracker
https://github.com/bertrik/wifitracker
It runs a simple command interpreter, type 'help' at 115200 bps to get a list of supported commands.


== Server backend ==
== Server backend ==
Line 61: Line 63:


The REST service could have two endpoints:
The REST service could have two endpoints:
* one to upload data from the tracker to the server
* one to upload collected WiFi data from the tracker to the server
* one to provide configuration data from the server to the tracker
* one to download configuration data from the server to the tracker


Configuration data can be made specific for each tracker, and could consist of things like:
Configuration data can be made specific for each tracker, and could consist of things like:
Line 72: Line 74:
== Challenges ==
== Challenges ==
Some things to solve yet:
Some things to solve yet:
* first of all make a working prototype
* first of all make a working prototype, not necessarily optimized yet for size / appearance / battery usage / etc
* using "WiFi hotspots": bypass so-called captive portals. Many open web services spoof DNS after connecting to the access point and re-direct you to a webpage where you either need to log in or click some 'I agree' button. It's easy for a human to understand this, possibly not so easy for an embedded device.
* when using "WiFi hotspots": figure out how to handle so-called captive portals. Many open access points spoof DNS after connecting to the access point and re-direct you to a webpage where you either need to log in or click some 'I agree' button. It's easy for a human to understand this, possibly not so easy for an embedded device.
* figure out how to run everything from a battery, like can we run it directly off an LiFePO4 battery, or use a lithium-cobalt battery with an LDO, etc.
* make it lower power: so we can use a smaller battery or get longer tracking time
* make it lower power: so we can use a smaller battery or get longer tracking time
* make it smaller and lighter: so it can be attached to smaller items (e.g. a migrating bat)
* make it smaller and lighter: so it can be attached to smaller items (e.g. a migrating bat)

Revision as of 12:56, 6 March 2016

Project EspWifiTracker
350px
Location-tracker based on WiFi station ids
Status Initializing
Contact bertrik
Last Update 2016-03-06

Introduction

The idea of this project is to create a simple and low-cost WiFi location tracker.

It tracks location by periodically scanning for WiFi station ids, storing those in internal memory and using one of the various location services (google, mozilla, openwlanmap, etc.) to determine a geographical location from this.

This can be used to track various things, for example:

  • track your own bicycle
  • know where your cat goes
  • monitor movement of wild animals for research purposes, like bats or stone martens.

The basic operating principle is this:

  • the tracker is in deep-sleep most of the time, keeping only a low-power real-time-clock running.
  • every once in a while (say once a day) it wakes up, takes a reading of all WiFi stations in range and their signal strength. It stores these in internal memory.
  • if the tracker wakes up to find an open WiFi station (or one that it knows the WiFi password of), it tries to upload all previous readings to a server.
  • the server resolves the uploaded data into geographical locations using a service like Google or the Mozilla Location Service.

Tracker prototype

I'm working on a prototype of this.

Hardware

I'm basing this off an inexpensive NodeMCU clone. The NodeMCU is basically an ESP8266-module on a break-out board with an USB-serial converter and a proper 3.3V power supply. The ESP8266 is a WiFi-capable microcontroller, capable of running at 80 MHz, it has 1 MB (or more) of flash onboard which enough spare flash sectors to hold a file system.

To wake up periodically, I'm using a ZS-042 clock module, containing a Maxim DS3231 RTC chip (datasheet). This module is attached to the NodeMCU through the I2C-bus on pins D1 (SCL) and D2 (SDA).

Software

The NodeMCU can be conveniently programmed from the "Arduino" development environment using the Arduino core for ESP8266 WiFi chip

This already comes with a library for WiFi that allows you to scan for WiFi stations

Other libraries used:

My prototype software can be found at: https://github.com/bertrik/wifitracker

It runs a simple command interpreter, type 'help' at 115200 bps to get a list of supported commands.

Server backend

The server backend receives uploads from the tracker and resolves the WiFi station ids into locations by using a location service, for example:

The MAC address of the ESP8266 should be unique and can be used to identify a specific tracker.

Communication between the tracker and the server is always initiated by the tracker. The protocol is REST (HTTP) and the format is JSON. I'm thinking of writing this in Java, with the use of Jackson 2.0 (JSON), Jersey 2.0 (REST) and Jetty libraries.

The REST service could have two endpoints:

  • one to upload collected WiFi data from the tracker to the server
  • one to download configuration data from the server to the tracker

Configuration data can be made specific for each tracker, and could consist of things like:

  • a new periodic wake-up schedule
  • list of known WiFi stations + passwords
  • WiFi station whitelist, list of stations which are known to be really open to the internet
  • WiFi station blacklist, list of stations which are open (unencrypted), but not really open to the internet

Challenges

Some things to solve yet:

  • first of all make a working prototype, not necessarily optimized yet for size / appearance / battery usage / etc
  • when using "WiFi hotspots": figure out how to handle so-called captive portals. Many open access points spoof DNS after connecting to the access point and re-direct you to a webpage where you either need to log in or click some 'I agree' button. It's easy for a human to understand this, possibly not so easy for an embedded device.
  • figure out how to run everything from a battery, like can we run it directly off an LiFePO4 battery, or use a lithium-cobalt battery with an LDO, etc.
  • make it lower power: so we can use a smaller battery or get longer tracking time
  • make it smaller and lighter: so it can be attached to smaller items (e.g. a migrating bat)