Shubh Patni
Shubh Patni

Shubh Patni

How to Get an Arduino and Your Smartphone to Talk to Each Other

A comparison of various Arduino communication methods

Shubh Patni's photo
Shubh Patni
·Nov 2, 2020·

4 min read

How to Get an Arduino and Your Smartphone to Talk to Each Other

Imagine being able to communicate with any device from anywhere in the world. You can control your TV, lights, washing machine, dishwasher, toaster, coffee machine — anything you want — just for a few bucks.

You can do it with Arduino. I have a lot of these lying around in my room, ready to automate another device of mine.

In one of my previous articles, I covered how you can use Arduino as a switch to turn any device on or off.

Today, I will discuss the pros and cons of various wireless methods used to create communication between Arduino and smartphones. This would not only allow you to use your phone as a switch, but it would also enable it to send specific commands for operations and get the state from Arduino.

Various Ways to Send and Receive Data

There are multiple ways to set up communication between Arduino and a smartphone, and each one of them is useful in certain cases. Here are a few of them.

HTTP requests

You can send and receive data using the HTTP protocol. HTTP POST and GET requests are used to establish communication. For this, you can use an ESP8266-NodeMCU module. This module can facilitate the connection and even has GPIO ports.

HTTP (advantages)

  • It is a stateless platform (i.e. the communication between devices is closed when the message is received by the receiver). HTTP is best for scenarios where the data does not need to be fetched frequently.

  • It requires less computational power.

HTTP (disadvantages)

  • HTTP is comparatively slower than web sockets. A new connection has to be made every time you need to send or receive data.

A good analogy would be chatting: You send a message and wait for the reply to send another message. ESP32 HTTP GET and HTTP POST with Arduino IDE | Random Nerd Tutorials In this guide, you'll learn how to make HTTP GET and HTTP POST requests with the ESP32 board with Arduino IDE. We'll…randomnerdtutorials.com

Bluetooth (advantages)

  • You can buy Bluetooth modules for Arduino for very cheap on Amazon or eBay and connect them to your smartphone, PC, or smartwatch.

  • Bluetooth consumes less energy than most wireless communication technologies (2.5 mW).

  • It is less prone to the interference of data, which can be the case with other wireless methods. It is best for short-range wireless communication.

Bluetooth (disadvantages)

Online services

You can also use services such as Blynk, which has a mobile app for smartphones and a library for Arduino to set up communication.

Online services (advantages)

  • Online services usually won’t require much coding and hard work. Everything is done for you. You just need to connect the dots.

  • Paid services will regularly update and bring more features with time.

  • Allows you to control devices from anywhere in the world, anytime you want.

Online services (disadvantages)

  • These services are often not free or have restrictions or friction.

  • The service may not have certain features you need.

  • You are at the mercy of a third-party service, which may not be good if you are looking for commercial applications.

WebSocket (advantages)

  • WebSocket is a stateful protocol (i.e. the connection is open until one of the devices disconnects). Unlike HTTP, web sockets do not need to make a new connection every time they want to send some data.

  • It the best choice for real-time applications such as gaming and trading, where there is a continuous flow of data.

A good analogy would be a phone call: Until a party disconnects, both the parties can talk and communicate.

WebSocket (disadvantages)

Conclusion

To use these technologies, you can either create a mobile app or use ESP8266 as a web server (for HTTP and WebSockets).

Let me know if you need any help.

 
Share this