Can Arduino Connect To The Internet? Simple IoT Guide

What do you think of a regular thermometer? It’s not that impressive and appears to be really simplistic. How about a thermometer that is connected to the Internet? That means you can install that fancy thermometer in your house, go on vacation to Argentina, and still be able to know what temperature it is in your house. That’s so much cooler!

Can our Arduino do the same? “Can an Arduino connect to the internet?

An Arduino board can connect to the Internet. You can do so by using a device called ESP8266. This is necessary because some types of Arduino boards like the Uno R3 don’t come with Internet connectivity built-in. What’s even better is that you don’t need an Arduino board to use the ESP8266 tool. You can directly program it with the Arduino IDE (Integrated Development Environment).

The rest of this article will go further in detail about how IoT works and all the introductory information necessary for the ESP8266 module.

Introduction To The Internet of Things

As I’ve mentioned before, many Arduino boards cannot connect to the Internet themselves. There are some you can buy with built-in internet compatibility like the Uno Wi-Fi, the Ethernet, or the Yun boards. Most of the time, you’ll need an external device like a Wi-Fi, shield or, in this case, a Wi-Fi module like the ESP8266.

Note: Smaller Arduino boards like the Nano or Mini are not compatible with shields, but they’re compatible with breadboards.

These devices all fall under the category of “Internet of Things” or IoT for short. I’m sure some of you have heard of it, but don’t completely understand what it is.

In essence, the IoT is just a collection of gadgets (like the ESP8266) that can connect to the Internet and send or receive data through it. This is very useful if you’re collecting a lot of data and want to upload it to the World Wide Web and share it with everyone.

However, in order to use IoT devices, you’ll need to utilize an online tool called ThingSpeak. Using this software will allow your IoT-enabled devices to graph the data they collected.

Let’s go back to the example I used in the first paragraph. Suppose you’re talking about your home, and someone you met in Argentina asks you:

“What temperature is it in your house right now?”

Instead of giving them a rough estimate, you can just go onto the ThingSpeak page on your phone and tell them confidently “It’s 71 degrees Fahrenheit!”

All of these things sound cool and all, but do you know how the Internet works? Up until I started working with IoT, I didn’t bother learning what the Internet truly was. I just understood that if I wanted to learn about something or be entertained, the Internet had it all. Now that we’re working with it, we should understand what it does.

Let me show you how the Internet actually works in the grand scheme of things.

Introduction To The Internet

In this explanation, I’ll be using my computer as an example since it’s a common item, and it connects to the Internet. My computer is Wi-Fi-enabled, which means it can connect to the Internet whenever a Wi-Fi network connection is available. It’s able to connect to the Internet because I have a router in my house.

The router creates a hotspot that my computer can connect to, and the hotspot is also called an access point (AP). My router also is a cable modem, which is like a network bridge that connects my computer to the Internet. This is directly connected to my Internet Service Provider (ISP).

In this case, my ISP is Verizon, and they create and assign my computer an Internet Protocol address or an IP address. Because Verizon created it, they have the rights to it. Just like my home address, the IP address is completely unique and billions of devices have their own special IP address.

Here’s the interesting part: ISPs like Verizon also have their own assortments of routers. More specifically, they have local routers for their consumers in a particular area and regional routers to round up all the local routers.

After that, the Internet Service Providers themselves have to buy bandwidth, which is a frequency range for sending signals, to connect to the Internet from their network service provider (NSP for short). The NSP has to connect to network access points (NAP), and these NAPs have to connect to other NAPs.

As you can see, this gets very complicated. There are millions if not billions of connections that have to be made in order for me to use my computer to surf the web.

Because there are so many connections, many different protocols are needed to establish order. Due to the sheer number of protocols needed, they need to be stacked on top of each other, which forms what is called a protocol stack.

Now, communicating through the Internet requires many different software layers. In fact, the four layers are the application layer, like a web browser, the transmission control protocol (TCP) layer, the Internet protocol (IP) layer, and the hardware layer.

When my computer is transmitting or receiving data over the Internet, the information goes through all 4 layers. When it’s being moved, it’s called a packet of information. Here’s the general flow process:

The information starts out on a web browser like Google Chrome, which is the application layer. Next, a port address is added to the info by the TCP layer. This directs the information to the computer it needs to go to, which allows the computer to receive it. But in order for the computer to obtain it, the IP address of the receiving computer is added by the IP layer. Finally, the data goes through the hardware layer where it’s made understandable by the computer.

What I mean by this is that the information will translate into electrical signals (i.e. highs and lows) so that the computer understands it better. After that, the info goes through the router. To do that, the router uses what’s called a router table, which is a collection of all the IP addresses linked to the router.

With this list, the router can determine whether the IP address of the data I’m sending has a matching IP address with its connected computer. If not, the router will toss it to a different router, and that router will repeat the process until it has found a receiving computer with the same IP address as that of the data.

When the router has found the computer, the data will go back through the layers, which means it has to go through the hardware layer first, then the IP layer, the TCP layer, and finally the application layer, which displays it on the web browser of the receiving computer.

However, if you have the receiving computer and you’re receiving my data, you’ll see a web browser with a URL like chargedwarrior.com. You may be wondering, how did the URL become an IP address and then transform back to a URL?

You can thank the Domain Name Service (DNS) for this. It’s basically a big database that takes these URLs that you typed in and matches them with their IP address.

After all this long explanation, you’re probably wondering:

“What does this have to do with the Internet of Things and ESP8266?”

Well, when we’re working in the application layer with IoT and our ESP8266, we’ll have to go through the HyperText Transfer Protocol (HTTP). This uses a client, which is known as the web browser, and a server, which is a place that stores the Internet’s web pages.

When we use the ESP8266 module, we’ll need to make it a client and turn ThingSpeak into a Web server.

Overview Of The ESP8266 Module

You keep hearing me talk about ESP8266, and you’re probably wondering what’s so special about it. I am dedicating this section to help you understand it better and hopefully convince you to use it in your IoT adventure.

When I first heard of the ESP8266 module, I thought it was going to give my Arduino board special ‘sixth sense’ abilities.

It turns out that ESP8266 is just a wireless microcontroller that can connect to the Internet. The company Expressif Systems created this beautiful tech.

Similar to other microcontrollers, it utilizes pins that can either be used as inputs to read data or as outputs to talk to other circuits. In fact, the ESP8266 chip has 17 General Purpose Input/Output (GPIO) pins.

Yet, the usability of the pins can become limited and the board itself may take on different physical appearances because other companies may use the ESP8266 microcontroller on different breakout boards.

For example, you can only use 2 of the 17 GPIO pins on the ESP1 breakout board whereas you can use 9 out of the 17 GPIO pins on the ESP12 breakout board.

To learn more about the pins on the Arduino, check out my pin guide. I’ll go over ways you can test the pins, basic information surrounding these pins, and tips for when you’re using Arduino pins.

If you’re not convinced of the ESP8266’s awesomeness yet, here are another 3 reasons why it is great:

  1. It’s very affordable.
    1. Money is a big factor whenever I make a purchasing decision. Thankfully, this Wi-Fi module doesn’t break the bank, and it adds a cool feature to your Arduino project.
    2. You can buy it around $7 on Amazon, but it’s even cheaper if you go on AliExpress (I’ve found some ESP8266 modules between 1 to 2 dollars).
  2. It’s compatible with the Arduino IDE, and can be used by itself.
    1. Compatability with the IDE is great because you dont have to learn a whole new programming language or download a different text editor. That means that all the skills you’ve learned programming with your Arduino board is still applicable to the ESP8266.
    2. Moreover, the standalone feature is very convenient because you don’t have to hook it up to an Arduino board to use it.
  3. It is 802.11 Wi-Fi enabled.
    1. All this means is that you can connect the ESP8266 module to any place with Wi-Fi hotspots.

Still, there are other factors you’ll need to take into consideration when looking to buy an ESP8266. Notably, you should be asking yourself what you plan on doing with it when you purchase it because there are two different categories.

The first category is the inclusive breakouts like the Feather ESP breakout or the Adafruit HUZZAH. They cost more than the second category (between the 6 to 13 dollars range), but they are easier to use. That’s because they come with cool features like built-in USB (universal serial bus) serial converters (so you can plug it directly into your computer), voltage regulators, and great lithium-ion connections. This is like using an iPhone!

On the other hand, the second category doesn’t give you all these cool capabilities. You’ll have to install your own 3.3V voltage regulator and battery hookup, and you’ll need to provide an FTDI cable to connect the ESP8266 to your computer. The FTDI (Future Technology Devices International Limited) cable basically allows the device to talk to your computer. Fortunately, you’ll find these breakout boards between the prices of 1 to 3 dollars.

This is like using a landline phone.

Summary – tl;dr (Too Long; Didn’t Read)

Here are the key takeaway points you should keep in mind after reading this article:

  • Arduinos can connect to the Internet if you use IoT modules like ESP8266
  • Some Arduino boards have Internet connectivity built into the board like the Uno Wifi, the Ethernet, or the Yun
  • Communicating through the Internet requires 4 layers:
    • Application layer
    • TCP layer
    • IP layer
    • Hardware layer
  • ESP8266 is great because:
    • It’s very affordable.
    • It’s compatible with the Arduino IDE, and can be used by itself.
    • It is 802.11 Wi-Fi enabled.

Because I want to give you bite-size digestible information, I’ll be going over how you can use an ESPE8266 module with the Arduino IDE or Arduino board in my second guide.

Now, go play around with the Internet some more. Be like spiders at a beach and surf the web!

Similar Posts