Chatting is fun and interesting, but what if hobbyists can do it using the ultimate IoT enabled platform? We made a chatting project using evive which is a very handy all-in-one platform to build our projects.
With this project, we will be able to send and receive messages between two devices, one using Arduino IDE's Serial Monitor and the other connected to evive via Wi-Fi (ESP8266). Usually, connecting a Wi-Fi module to an Arduino board involves lots of complex wiring and takes huge amount of time, but evive has a dedicated slot (adapter) for it in its Communication Module, making it a plug and play feature. Also ESP is recommended to work on 3.3V signals, but Arduino's serial communication works on 5V TTL for most of the boards. So forget connecting it directly, you will require a potential divider or additional logic level shifter to convert 5V to 3.3V. But evive took care of that for us, it has an inbuilt high speed logic level shifter (74LVC245).
You may also need to install a telnet client (eg. PuTTY) for windows but no such software is required for a Linux machine. You can download PuTTY from here.
- Plug the Wi-Fi module on evive as shown in the picture
- Make sure you see a blue led blinking on the module
- Now, connect to the Wi-Fi network "
AI-Thinker-xxxxx" from the other device [second computer]
- You are now connected to the Arduino Mega via serial 3 (DO NOT connect Bluetooth module or XBee along with the Wi-Fi module)
Now, your first computer is connected to evive via serial and second is connect to evive via Wi-Fi. To know more about ESP, visit: http://www.esp8266.com/wiki/doku.php?id=getting-st...
The good thing is, there are no messy wires around. Thanks to evive, just plug it and play.
The ESP8266 Wi-Fi runs through AT commands. A lot of these commands are available for various functions. You can take a look at this for example. You can try these AT commands in the serial monitor by uploading the following Arduino code.
When you have tried all the AT commands in this code you may proceed to the next step for making the chatting platform.
Using the previous code you can have a chat like experience already. All you have to do is the following:
- First, check whether the ESP module is connected properly by giving command AT in the serial monitor. You should get an "OK".
- Now get the IP Address on which your ESP module is working by giving the command AT+CIFSR=?. If you get "OK" then enable the module to act as a “Station” by giving entering AT+CWMODE=2 in the serial monitor.
- After getting the affirmative response, enable the module to work for multiple connections by entering AT+CIPMUX=1 in the serial monitor.
- Now, start the server using AT+CIPSERVER=1,1338, here 1338 is the port number. You can use any port number of your choice.
- Next, open the telnet command prompt for Windows on the second computer. You can download PuTTY and use the IP address obtained in step 2 and the port number from step 4. For Linux terminals, all you have to do is type the command telnet "IP_address" "Port ".
- Now your telnet session is activated. Sending a message from telnet is very easy. You just have to type the message and press return.
- However for the serial monitor (first computer) you have to give the command AT+CIPSEND=0,"size_of_message" and then the message.
By this time, you know all the magic beneath. We have developed a nice looking platform in this code.
Note that we have included the serial (mentioned in previous step) in the code itself. The remaining commands to begin the chatting are:
You can modify it to work for three or more persons in a chat. This will lead you to a group chat with all your maker friends around. Of course we are trying to do so but you can also develop it.