11

(Marcin) #1

Way Home Meter


TUTORIAL


To get a Telegram Bot token, download the Telegram
app on your phone and set up an account. Open the
app and press the search button on the top-right
of the screen. Search for ‘botfather’. Type /newbot
and follow the on-screen instructions. The botfather
will provide you a link to the bot and an access
token. The link is for the chat where people will
share their location; the access token is used in the
sketch to authenticate your ESP8266 as the bot you
just created.
Next, you will need to get a Google Maps API
key. Start by going to the following URL:
hsmag.cc/mPqFqh.
Check the Routes option and click Continue.
You will then be asked to create a project; you can
give this any name. You will need to add a billing
account, but this device will comfortably operate on
the free allowance given by Google. You will then
get an API token that can be used in the sketch.
And finally you will need to get your home’s GPS
location. A simple of way of doing this is using
Google Maps. Using a web browser (not the app),
navigate to your house on Google Maps and right-
click and click ‘Directions from here’. This will modify
the URL, which will now contain the coordinates
of your home; copy and paste these from the URL
e.g. 51.5546466,-0.2794867.
You now have everything you need to configure
the WayHomeMeter. Open up the WayHomeMeter
sketch and click on the config.h tab. First thing you
will need to enter is your WiFi details so that the
ESP8266 is able to connect to your WiFi.

Google maps gives a free monthly allowance of
credit – equivalent to 20 000 requests. That is just
under what’s required to send a request every two
minutes in a month (about 22 000). This device only
makes the request every two minutes that it is actively
monitoring someone’s home journey, so should stay
under the limit if used occasionally. It’s possible
this limit will change in the future. How often it
checks can be configured in the sketch by changing
delayBetweenGoogleMapsChecks.

GOOGLE BILLING


Above right
This is a custom
PCB that breaks out
all the pins of the
D1 Mini to screw
terminals, but it can
be easily recreated
with a standard
protoboard
Above
The address pins of
the LEDs should be
able to reach each
other without the
need for extra wire.
The power pins need
to be joined by wire

After installing these libraries, you should click
the ‘verify’ button (shaped like a tick) on the
WayHomeMeter sketch to make sure that
everything compiles fine.

SOME CONFIGURATION REQUIRED
You will need to make some configurations to get
this sketch to work for you, but you will first need
to get:


  • Telegram Bot token

  • Google Maps API token

  • GPS coordinates of your home

Free download pdf