Starting with WiFi communication

Hey guys,

I've been doing some things with the Arduino UNO lately and I've already completed some simple projects. At this moment I would like to be able to send and receive some data on my WiFi network and in the future to an MQTT server.

From what I've been researching, people use the ESP8266 a lot with a serial-WiFi bridge.

My question is what is the best ESP for me to use with the Arduino UNO?

What is the best or most used library for the ESP family?

consider using a ESP32 which has onboard WiFi, Bluetooth Classic and BLE

Put the UNO away and get an esp8266 or esp32 board. Trying to add WiFi to the UNO just doubles the problems.

It is a simple application in which I only have some digital inputs and outputs, with an analog input and transmit these values ​​via WiFi to perhaps an MQTT broker

What are the complications?

Of the Uno? Tiny memory, very slow processor.

And I'm a newbie and I see some videos where people used a Uno connecting to the ESP-01, as an example

Uno + ESP-01 is a kludge.

What...
In most cases an ESP board can replace the Uno.
Leo..

But the ESP8266 (ESP-01) does not have the number of pins that the one has. How can it replace Uno?

With the UNO ESP-01 combination the application is split across two processors and you need a communication protocol between them. This leads to unnecessary extra work than if you have one processor.

There are other boards than the ESP-01 that bring out more of the I/O pins. For example

how many pins do you require - have a look at ESP32 pins
having to implement code on two microcontrollers (a UNO and ESP-01) with associated communications protocol makes the task an order of magnitude harder

The ESP8266 has more pins, but on an ESP-01 board they are not exposed to the user.

Other ESP8266 boards, like the WeMos D1 mini, have more pins.
Those boards also have a USB connector, so you can directly program them.

For even more pins you step up to an ESP32 breakout board, but I recommend you use a more simple ESP8266 board first.
Leo..

what sensors etc do you wish to attach to the microcontroller?

I suggest this tutorial to get you started with the ESP8266:
https://tttapa.github.io/ESP8266/Chap01%20-%20ESP8266.html
I used the tutorial when I first used one and found it very helpful. The author is active on this forum.

I agree about not using 2 boards, doing so adds to the complication of your project. By all means use a second board once you understand the ESP8266 and how to implement communication with another board, but don't try to do so from the start.

I answer my friends' question, today there is an application that uses the Uno connected via serial with a nextion display.

I use 6 digital inputs, 4 digital outputs, an analog input and a PWM output

Can I use which version of ESP8266? or can I go directly with the ESP32?

Another question, with my code that I have for Uno, it is simple for the ESP8266 or the ESP32.

I just want a value of a variable that I have to be transmitted over the internet, to an mqtt and then I can track this variable

what are the attached devices and their logic levels?
the UNO uses 5V logic the ESP32 3.3V logic
you have to be careful connecting 5V logic devices to an ESP32 either use a potential divider for simple logic input or a bi-directional level shifter, e.g. for I2C

In both the digital outputs and digital inputs I am using optical coupling, so it is easy to operate in 3V3.

But regarding programming made for the UNO, is it easy to migrate to the ESP8266 or the ESP32?

Why don't you buy a $2.50 Wemos D1 mini, and try for yourself. It's not that hard to upgrade to an ESP8266. Then upgrade to ESP32 (if you need more I/O).
Leo..

In general it is fairly simple to move code to the ESP series. Some problem areas...

Some libraries that use direct port I/O.

Long loops - the ESP will time out if the WDT is not regularly reset. Calling functions or normal loop control will reset it, so it is normally not a problem.

Bad pointers and accessing outside an array are likely to give an exception rather than just hanging or randomly causing errors. I think this is a plus because the exception decoder can give you a clue to the error.

ESP32 watchdogs are useful if for some reason the code gets stuck in a loop e.g. a faulty sensor not responding to a request in a polling loop (recommend avoid polling loops - use none-blocking IO) - the WDT resets the ESP32 and action can be taken to raise alerts etc

if for some reason polling loops are used the WDT can be reset by calling esp_task_wdt_reset(); in esp_task_wdt.h - see Implementing ESP32 hardware watchdog timer using Arduino IDE

also remember the general recommendation of keeping interrupt and callback routines short - do not call complex IO functions (e.g. LCD IO) in such routines