Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)
Target Amount: $2000
Amount Raised: $1802.10
Top Donor: C.C. $100
Created on: 22 February 2015
This tutorial explains how to connect an Arduino web server to the Internet. The example Arduino sketch reads two temperatures and displays them on dial gauges on a web page.
The Arduino web server temperature measurement project can easily be tested on a local network, but you may want to be able to access the Arduino web page from the Internet using a smart phone, tablet or external computer – i.e. use the project for remote temperature monitoring over the Internet.
An Arduino Ethernet board and two MCP9700 temperature sensors are used as an example web server for this tutorial. The tutorial should work for other Arduino boards with an Arduino Ethernet shield and any other computer or board that has an Ethernet connection.
Temperature measurement is used for demonstration purposes, but other projects can just as easily be connected to the Internet in the same way, e.g. voltage measurement, a light switch, control a relay, etc.
This is a brief overview of what needs to be done to connect the Arduino board to the Internet. The tutorial follows in the next section.
The Arduino is set up as an HTTP web server that hosts a web page containing the temperature gauges. The following list contains some resource on how to use the Arduino as a web server.
It is assumed that you are using an ADSL router or similar device as you Internet connection. Port forwarding must be enabled on the router so that your Arduino can be "seen" on the Internet.
You will need to log into your router using a web browser and then set up and enable port forwarding. After setting up port forwarding, you will be able to load your Arduino web page from a device connected to the Internet and external to your own network.
Most ISPs (Internet Service Providers) will assign you a dynamic IP (Internet Protocol) address when you log in with your ADSL router. This means that they will change the IP address every so often. The IP address will also change if you switch the router off and then on again later.
After enabling port forwarding on your router, you will be accessing your Arduino using the IP address that your ISP assigns to you. Every time that the dynamic IP address is changed, you will need to find out what it is and then surf to it to see your Arduino web server on the Internet.
External services (such as NoIP and others) can be used for free to give your Arduino a domain name (e.g. myduino123.somednsservice.com) and take care of the dynamic IP address at the same time by associating the new IP address with the same domain name every time that it changes.
The next section in this tutorial shows how to complete the above steps to connect your Arduino to the Internet.
A NETGEAR router is used in this tutorial. If you have a different make of router, you will need to find the equivalent settings in your routers menus.
Open a web browser and log in to your router. The IP address or domain name to use to log into the router as well as the default user name and password will be in your router documentation.
The NETGEAR router used in this tutorial can be reached at http://routerlogin.net Other routers may need you to enter an IP address such as 192.168.0.1 or 10.0.0.1 to bring up a login page.
You will be prompted for a user name or password which may be admin and password or similar – check your router documentation.
After logging in to the router, you will see a default page and menu for the router.
The following instructions are for a NETGEAR genie DGN2200v4 router – for a different router read the router documentation or search on the Internet to complete the steps below.
In the web browser after logging into the router, click the ADVANCED tab at the top of the page. Here you will be able to see the dynamic IP address that your ISP issued you when your router connected to the Internet. This is shown as xxx.xxx.xxx.xxx in the image below.
The dynamic IP address will be used to access the Arduino. If you can't find the IP address in your router setting, Google "what's my IP".
Now click the Advanced Setup menu item at the bottom left of the router web page as shown in the image above. This will expand the menu.
Click the Port Forwarding / Port Triggering menu item. Now set port forwarding as follows:
With the above setting done, the Arduino web server should be able to be reached from the Internet at the IP address that your ISP provided to your ADSL router.
Enter the IP address into the address bar of a web browser from a device that is not connected to your local network, e.g. use a smart-phone with cellular data connection.
You should now be able to see your Arduino on the Internet. If you have a static IP address, then you can always find the Arduino at this address as long as the Arduino and router are powered up.
If you have a dynamic IP address, then every time that your IP address is changed, you will need to find the new IP address to connect to your Arduino web server.
The video below shows the Arduino being accessed over the Internet using a PC and a smart-phone to display the two temperatures being measured by the Arduino.
Can't see the video? View on YouTube →
The next section of this tutorial explains how to sign up for an external service to give your Arduino a domain name that will always point to your current IP address.
NETGEAR routers allow you to use one of several external services that will give you a domain name for your Arduino and update the domain name with the dynamic IP address every time that it changes.
For other routers, consult the router documentation or search the Internet for a solution.
On the NETGEAR router, you can either sign up for a service within the router menu, or sign up by visiting the service providers website. In this tutorial, noip (www.noip.com) is used and signing up is done through their website.
To sign up directly in your router, click the Dynamic DNS menu item below the port forwarding menu item that we used in the previous section. Here you will be able to use the noip service through NETGEAR (NETGEAR has an agreement with noip to use their service).
Whether you sign up from the web page or in the router, we will need the same Dynamic DNS settings page.
Visit the no-ip website and click the Dynamic DNS menu item.
Under Free Dynamic DNS click the Free Sign Up button.
You will now need to provide a user name, password, email and hostname. The hostname will be the name that your Arduino will be accessed with through your browser in the form xxxx.ddns.net where xxxx is the name that you choose.
When finished entering the above details, click the Free Sign Up button.
You will need to confirm your account by checking the email for the email address that you signed up with and then clicking the link in the email address.
Log into your router again, click the advanced tab, then advanced setup menu item and then Dynamic DNS
Now click the Use a Dynamic DNS Service checkbox and then select NoIP.com from the drop down list to the right as shown in the image below.
Fill in the Host Name (name_you_chose.ddns.net), User Name (no-ip user name you signed up with) and Password (no-ip password you signed up with). Click the Apply button to finish.
You should now be able to access your Arduino from any web browser using your new domain name name_you_chose.ddns.net. You may have to wait for a few minutes until it starts working.
Whenever your IP address changes, your domain name will point to the new IP address, so you will always be able to access your Arduino web server.
Now that your Arduino is on the Internet, it is accessible by anyone who knows its domain name or who scans a range of IP addresses that includes your Arduinos IP address. You will need to take some precautions to keep others from accessing your Arduino.
Be sure not to let anyone know what your IP address and even more importantly what your domain name is. Don't publish it anywhere on the Internet.
Some sort of password protection would be ideal to try and prevent unwanted access to your Arduino.
It may not be a big problem if you are only displaying some temperatures, but if you are displaying information that you want to keep private, or your Arduino web server allows you to switch anything on and off, then you would not want anyone to be able to access your web page.