Close
0%
0%

External IP Address Tracker

Arduino with an Ethernet shield is used to send an email to let you know when the external IP address of your internet connection changes

Similar projects worth following
This project uses an Arduino with an Ethernet shield to obtain the external IP address of your internet connection. It checks the address periodically and if it changes, an email will be sent via SMTP, indicating the new IP address. An LCD is also attached to the Arduino that displays the external IP. This project was done because my father had purchased a video camera system for some property he has in a rural area. He wants to monitor the video remotely. The only reasonably priced internet connect he can get is DSL. Unfortunately the connection isn’t very stable and the external IP address changes frequently. Once it changes there is no way to know what address has changed to and no way to access the camera system unless you have local access to the network. I looked into DDNS services but most require a client running on a PC 24/7. This is undesirable because of power consumption and if the power goes out, which occurs frequently, the PC will shut off. My solution was to build this

This project was originally done in 2012. The original version had all of the parameters hard coded in the Arduino sketch. The new version adds a setup shell that is accessible via the Arduino's serial port. This allows the user to enter their own parameters which get stored in the Arduino's EEPROM. I've also added an LCD display that shows the current IP address and connection state. The LCD isn't super useful but it looks cool.

How it works…..
The Arduino starts and enters the setup() function. The serial port is initialized then the existing parameters are read from the EEPROM and copied into string variables. Since the parameters vary in length the starting address for each parameter in EEPROM is dynamic. To address this, the first seven bytes of EEPROM contain the length of each parameter. The length of each parameter is first read out of EEPROM. Then the start address of each parameter is calculated and stored in RAM so the Arduino know what portion of EEPROM each parameter occupies.

The parameters are then spit out of the serial port and the user is prompted to edit the parameters. If the user sends an “S" (for setup) , the Arduino will enter a configuration function that prompts the user to change the parameters one at a time. After all of the new parameters are recorded, they are displayed via the serial port and the user is prompted to save them to EEPROM. If the user selects no, the changes are discarded and the values from EEPROM are reloaded . If the user selects yes, the new values are written to the EEPROM. The length of each parameter is calculated and written to the first seven bytes of EEPROM. From here the rest of the setup function is executed, an Ethernet connection is established and a local IP address is obtained from the LAN DHCP server.

The loop function is entered, a connection to checkip.dyndns.org is attempted. If connection is successful an HTTP request is made. The Textfinder library is used to search the returned text and identify the external IP address. The newly read IP address is compared to the last recorded IP address. If the addresses are different, the sendmail() function is evoked.

The sendmail() function establishes a connection to the SMTP server, login commands are sent. The saved username and password are BASE64 encoded and submitted to the SMTP server. Commands are sent to the SMTP server to send an email based on the saved configuration values. The new external IP address is included in the email. Once the email is sent, the connection to the SMTP server is severed. The sendmail() function ends and the sketch returns to the loop() function. After each command is sent to the SMTP server, the response is pushed out of the Arduino serial port to help with troubleshooting. The sketch waits for a reply from the SMTP server before moving to the next command. If the server does not respond, a timeout will occur. The sketch will continue to run if a timeout occurs. A configurable delay occurs and the loop repeats.

An LCD display is attached to the Arduino to display the current external IP address and various connection states. The LCD is driven by a 74HC595 shift register to conserve pins on the Arduino.

Other considerations...

I didn't put any effort into protecting the user from themselves. It is possible that if significantly long strings are entered for the parameters, a memory overflow could occur or the entire EEPROM could be filled up. These scenarios shouldn't occur under normal use but are possible.

If I were to start this project today, I would use a Raspberry Pi or ESP8266 instead of an Arduino with an Ethernet Shield. The Raspberry Pi is about half the cost and offers some other interesting functionality the ESP8266 is even cheaper but a bit more difficult to program. At the time this project was originally done, the Raspberry Pi was fairly new and a somewhat difficult to obtain, the ESP8266 didn't exist (at least I wasn't aware of it). One day in the future I may port this application...

Read more »

View all 2 project logs

Enjoy this project?

Share

Discussions

Stefan Misch wrote 03/11/2015 at 10:09 point

Wouldn't it be easier to just write a DDNS client for Arduino + Ethernetshield?

E.g. with freedns.afraid.org it's as easy as an HTTP GET request: wget -O /dev/null -q https://freedns.afraid.org/dynamic/update.php?<YOUR_TOKEN_HERE>

There's no need to keep a PC running 24/7.

Please, don't get me wrong, it still looks like a great project. :) I just think it's a bit over-engineered for this very purpose.

  Are you sure? yes | no

bayres wrote 03/11/2015 at 12:45 point

Yeah, I think you're right. I had no idea it was that easy. I will try this out. Thanks for the tip.

  Are you sure? yes | no

Gogan wrote 03/05/2015 at 20:14 point

Hello

Congrats for the project!

This is exactly what I was looking, for a very similar application.

I've never used an arduino before but I have some experience with micro controllers and coding. I would like to order the arduino, shield and display while I do some research and get familiar with it. For what I understand I need a arduino R3, internet shield (W5100? W5100 R3?) but I'm a little confused about the rest. Could you please share a link? 

Thanks a lot!

  Are you sure? yes | no

bayres wrote 03/05/2015 at 23:30 point

Thanks!
I used an Arduino Uno R3 and a W5100 R3 internet shield. I shouldn't matter which rev of these boards you use as the Arduino platform is good about backward compatability. The LCD board is somewhat custom. I used the Sparkfun ProtoShield Kit (https://www.sparkfun.com/products/7914) and a Basic 16x2 Character LCD (similar to this one https://www.sparkfun.com/products/790). I needed to add a set of stackable headers above the internet shield because there wasn't enought clearance above the ethernet connector. I used the circuit and library found here http://rowansimms.com/article.php/lcd-hookup-in-seconds to drive the LCD.

  Are you sure? yes | no

bayres wrote 03/05/2015 at 17:51 point

This project was featured on Wiznet's museum site! Wiznet is the manufacturer of the ethernet chip on the Arduino Ethernet shield. http://wiznetmuseum.com/portfolio-items/external-ip-adress-tracker/

  Are you sure? yes | no

emeyedeejay wrote 12/17/2014 at 21:07 point
I'd love to see the code too please - looking to do exactly the same thing and this will be a great quick-start :thumbs up:

  Are you sure? yes | no

Curtis Leo wrote 12/15/2014 at 05:29 point
Do you still have the source code for the Arduino Ethernet?

  Are you sure? yes | no

bayres wrote 12/15/2014 at 17:37 point
Thanks for your interest. I've been meaning to post the code but never got around to it. I'll have it up in a day or two.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates