Creating a Simple Chat Server with your Arduino
Posted on January 19, 2014
In this tutorial, you will learn how to use your Arduino as a simple chat server.
For this tutorial you will need an Arduino, an ethernet shield, an ethernet cable, and a USB cable to connect your Arduino to your computer. You will also need a second device (smartphone, tablet, or another computer) with terminal software installed on it.
Make sure all the devices you will be using, including the Arduino, are on the same network. This will not work otherwise.
Plug the Arduino (with ethernet shield attached) into your computer, and into your router/hub via an Ethernet cable. Get your second device ready.
The Arduino sketch software provides a simple chat server program for us (navigate to File -> Examples -> Ethernet -> Chat Server to locate it), but before it will work, you need to assign your Arduino its own IP address. (Note: if you have more than one Arduino on your network, you will also want to assign each one its own MAC address.) Make sure the address you use is available, and not taken by another device on the network you’re on.
Circled in red is the IP address you need to change:
Hit ‘upload’ to load the code onto your Arduino, then open the terminal interface on your computer and second device. On both of them, telnet into the IP you selected for your Arduino — simply type telnet and then the IP; for instance, in my case, I typed telnet 192.168.1.89 and hit enter.
After that, any text you type in on one device’s terminal should show up in the terminal window of the other, and vice versa. Voila, you have created a simple little chatroom!