Member-only story
Dynamic IP Address Code
This is a sub-tutorial for my Door Unlocker App tutorial. Please read that first.
What’s different with this code?
This version is the same as the static IP address version, just with a couple of extra steps:
- Every 6 minutes, check if your public IP address has changed.
- If it has changed, send an email to your email address notifying you of the new IP address.
This is important because if you don’t have access to wifi from the main entrance door and your IP address has changed, you won’t be able to use the old URL to open the door.
Why every 6 minutes?
The maximum number of requests you can make to http://bot.whatismyipaddress.com (the API that tells you your IP address), is one every 5 minutes. So to be on the safe side, the request is made once every 6 minutes.
Set up an email address
You’ll need to set up an email address which will be used to send the notification email. You can use gmail to create a free email.
You can make it as anonymous as you want, and make sure you set “allow less secure apps” to “on”.
Obviously don’t choose 2 factor authentication. You want this email address to be as insecure as possible, so that the code can access it.