Arduino Uno + ESP8266 send/receive data from laptop


I am interested in a project where a laptop sends and receives data (mostly various servo values) from the Arduino Uno that uses ESP8266.

I have managed to connect the ESP8266 to my Wifi and I got a static IP. How do I go about this project? I want the laptop to send/receive data using python3. When I search for a similar project, the results show [laptop <-> website <-> Arduino] communication. I would like to skip the website unless there are some valuable reasons for it?

do you need the UNO?

start a TCP server on esp8266 and send data to that server.

TCP server examples for the ESP8266WiFi library are WiFiTelnetToSerial and PagerServer.

and my TelnetStream library has a little different purpose but is a TCP server too.

The project adds WiFi to an Uno using ESP8266 so that you can connect it and send serial data as you would to the USB
ESP8266-01 Wifi Shield

Yes, UNO will be the controller with all the servos attached to it.

Just a dumb question to your answer, but why do you suggest to use esp8266 as a server instead of trying to send it directly?

can't the ESP do this too ?

directly where? directly how?
other option is for the esp8266 to connect as client to a TCP server you start in python. example is WiFiClient.

this is about communication of two esp8266 but the principle is the same:

You might be onto something. Another dumb question, how do I connect around 5 different servos to the ESP? By the use of a breadboard?

I would not use a breadboard for anything related to motors in general. They tend to require lots of current and you don't want lots of current flowing through your breadboard

You would power the Servo directly (possibly separately from the Arduino) and have a wire for the command pin directly to the Servo. Of course GND must be joined

Ok, good point, but the ESP only has like 8 connections, how do I connect 5+ separate servos to it? Wouldn't I need 5 different signal connections to the ESP to make sure I connect the specific servo?

Yes you need 1 pin per servo or you could use an extra board through I2C, for example the PCA9685 would let you drive up to 16 servos. (you can find those for less than 3€ from Asia)

you can also find a version for 8 channels

Hi Maria,

if you would give an overview about your hole project much better advice can be given.
It is really OK to be a beginner and to ask simple questions. (There are no "dumb" questions for me just simple ones).

From your questions I can conclude that you are somehow a beginner. That is the reason why it is so important to give an overview about your project. What does it do all in all?
There are always multiple ways of realising things. maybe sending the data by UDP is simpler.
maybe using ESP-NOW is simpler. If you have given an overview about your project better advice can be given.
best regards Stefan

Hi StefanL38,

The idea of the project has 3 main components:

  1. The ROBOT
  2. The LAPTOP
  3. The Radio Controller (RC)

The ROBOT with 5+ servos sends messages to the LAPTOP. The LAPTOP displays the servos' output in a nice UI.

At the same time, the LAPTOP sends the input values of the servos to the ROBOT. For example, the LAPTOP can send a message that goes like this: "Servo:1, angle:45"

The RC has a dedicated switch, that if the switch is off, the controls are coming from the LAPTOP, but if it is ON, then the RC overrides any messages sent from the LAPTOP and then you're only able to control the ROBOT through the RC. When the switch is off again, the ROBOT waits for the message from the LAPTOP.

Still not enough details.
With "RC" do you mean a classical radio-control-device for model driving / flying something like this?

This means the Robot has the RC-receiver onboard and the servos are connected to the RC-receiver?

Or do you mean to have something different as RC control?

The Laptop shall be able to control the servos too?

How is the laptop connected to the robot?
By a wire?
Wireless? If wireless based on what wireless-technology? nrf24?, WiFi?, ESP-NOW?, bluetooth. ZIGbee?
What is the maximum distance between the robot and the laptop?
Do they both have a sight-connection or are there walls between robot and laptop? What material do the walls have thing wood? or 30 cm of steel-concrete?

So if all this is just a basic idea of you.
How much time in working hours are you willing to invest into finishing this project?
Just a rough estimtation
10 hours?
50 hours?
300 hours?

best regards Stefan

Hi again Stefan,

Q: Whats the RC you're going to use?
A: Something like this:

Q: The Laptop shall be able to control the servos too?
A: Yes

Q: How is the laptop connected to the robot?
A: Wirelessly. My initial thought was to use Wifi. Use a modem to which both the laptop and the robot (via esp8266) connect. I have only just now learned about ESP-NOW, so I am reading about it more.

Q: What is the maximum distance between the robot and the laptop?
A: I'd say max distance is 20m. There may be some metal on the robot. But in general they would be in the open area.

Q: How much time in working hours are you willing to invest into finishing this project?
Just a rough estimtation
A: 100h +

You have to make a basic decision:

Spektrum-RC-Receiver mounted on the robot or mounted near to the laptop?

There are different possabilities to create a combined use of RC-control and the laptop

one ESP32-module (that is near your laptop) is connected to the RC-receiver and in parallel to the laptop.

depending on your RC-switch ESP32 takes RC-signals from the rc-control or from the laptop
connection towards the robot is established over WiFi or ESP-NOW where a second ESP32 is mounted on the robot.
The ESP32 will create all the servosignals

RC-receiver mounted on the robot and an ESP32. Depending on the rc-control-switch the servosignal-wires get switched between RC-receiver and ESP32.
When switching from RC-receiver to ESP32 or back the servosignal can differ which will make the servos jump to the new position.

Both ways are possible.

What do you think?
best regards Stefan

My first thought was going for the 2nd option.

OK. So one idea to avoid sudden jumping of the servos is: that the ESP32 is still sensing the RC-receivers servosignals and starts his own signal creation adapated to the RC-receiver.

I was giving you a lot of initial input what is important. I will not plan it all through for you.
I will be in standby mode for hours, days, weeks months until you post



As an example for a specific question:

"I tried to compile the following code (code pasted as a codesection) and get an error-message.
What do I have to change to make the error-message go away?

As an example to a way too much demanding question:

"Can somebody write the code (for me) that does .....?"

So let's see what is your first


best regards Stefan

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.