Hi! I'm trying to use an Arduino Uno with an ESP-01 plugged to an adapter. The problem is, the libraries of the ESP8266 force me to use the ESP as the board and I need to load the code on the Arduino Uno and use it's microprocessor.
Is there a way to install the proper libraries of the ESP8266 to make it act as a "plugin" of the Uno or something like that?? I can't figure it out.
I hope I made sense, i'm kinda new to this programing and eletronics thing. I can upload the code and photos of the hardware if someone wants to see it
Thanks!
You can program the ESP8266 however you like and implement some sort of communication system between the sketch running on the ESP8266 and the sketch running on the Uno. As you've discovered, there are libraries specially written for the ESP8266, which will never compile for the Uno. You can use those in sketches you write for your ESP8266.
The most common way to use an ESP-01 in conjunction with a classic Arduino board such as the Uno is to simply use the ESP-01 as a WiFi adapter running the AT firmware. Then you will program the Uno as you like with the Arduino IDE and make it control the ESP-01 using the AT commands and then read incoming data from the ESP-01.
For that usage, I recommend the WiFiEsp library:
With the Uno, there are a few things you need to be aware of:
The ESP-01 must have the AT firmware installed. Usually the ESP-01 modules come with the AT firmware pre-installed. However, if you have successfully uploaded any Arduino sketches to your ESP-01 then you erased the AT firmware and you will need to reinstall it.
If you connect the ESP-01 to pins 0 and 1 of the Uno, it may interfere with uploading to the Uno and communication with Serial Monitor because those pins are also used to communicate with your computer over the USB cable. If you do use pins 0 and 1 for the ESP-01 connection, I recommend turning off the debug output of the WiFiEsp library, since this is also output on pins 0 and 1 and I've found that interferes with communication with the ESP-01. You can see how to do that here:
The alternative to using the hardware serial port of the Uno on pins 0 and 1 is to use the SoftwareSerial library to create a software serial port on any of the other pins on your Uno. The problem with this is that the default communication speed of the AT firmware is 115200 baud, but the SoftwareSerial library is not reliable at that speed. You will need to use the appropriate AT command to change the baud rate of the AT firmware before you can use it with software serial. See the ESP8266 AT command manual available from the Espressif website for details. The example sketches that come with the WiFiEsp library are configured to use SoftwareSerial on the Uno so you can use them for a reference of how to do that.
So the "take-home" message is that in the ESP-01 itself you have a much more powerful and capable processor than the UNO (which is not the most practical form of Arduino - the Nano is better for serious projects), so you have to ask - why is the UNO necessary at all?
If you want a few more I/O pins, just use a WeMOS D1 Mini and port expanders are a very practical way of having more I/O than that.
Thanks for the help!
I'm taking a partner project from 2 years ago, we are using an UNO because we need a flow sensor.
The thing is, the project was bad documented, so I guess I'll need to start again from scratch :
Here is a pic of the ESP-01 adapter we have, I've found 0 to no tutorials of this especific model in the internet, if anyone has some tips I would be greatfull
fiteque:
The thing is, the project was bad documented, so I guess I'll need to start again from scratch
In which case my comment was singularly relevant - why do you need an Arduino UNO/ Nano and what is a "flow sensor"?
I'm sorry, Water Flow Sensor*
Well I need the UNO for conecting the parts togheter, I don't know any other way. Some sort of adapter, I guess, but I already have the UNO.
Am I making any sense? I'm really newb at this things and english is not my primary language, very sorry must I be haha
EDIT:
Well I guess if i'm expecting help, I need to explain the plan
We want to measure the water flow and send the data by WiFi to an server. So we are using an uno to conect to the water flow and process the data, and an esp8266 to conect in the WiFi and send the information to the server (too many to's and and's lol)
I'm actually having trouble even contacting the ESP-01, maybe I messed it up. I guess I don't have the knowledge to even ask the right questions, so I'll study the basics first. Thanks for all the help guys, I'm open for any sugestions
If the only thing connected is the water flow sensor, then though you have not revealed exactly what it is, it should connect directly to the ESP-01 which is perfectly appropriate for this purpose having two I/O pins available in addition to the serial Tx and Rx - which can themselves be re-purposed if necessary. So the ESP8266 would be far more appropriate to "process the data" and apply it to whatever Web interface you determine.
Let's look at your adapter:
This is a basic serial adapter for the ESP-01 providing a 3.3 V regulator and level conversion for the serial lines in some fashion. I won't investigate the details at this point, but just ordered one for curiosity.
To program the ESP-01, you use one of these cheap adapters.
You could use one of the $1 ones but it is a bit more fiddly and I see you are already having problems.
The Arduino IDE works just fine with these, whatever "processing" is required can be done with the ESP-01.
The adapter you already have just needs your "flow sensor" to connect to it. If you reveal what that sensor is, we can advise how to interface it but I suspect it will be by direct connection to the Tx line on the adapter (or is it the Rx? - depends on what they are supposed to mean!). Conveniently you swap the ESP-01 by plugging between the programming and "application" adapters.
If you are starting from scratch, forget about the ESP-01. Get a Wemos D1 mini, or something similar. It breaks out all usable IO pins, instead of just 4 on the ESP-01, it has much more memory (for uploading sketches over WiFi, for example) and it has an on-board USB interface for easy programming and debugging.
Th best part: you can get one for under $4.
Believe me, I've used both, and there's no way I would go back to an ESP-01.
Pieter
"YF-S201 Water Flow Sensor" is the one i'm using.
Unfortunately I can't change to the Wemos D1 mini as $1 is ~R$4 + shipping and I need 5 x.x
I guess i'll need to buy 1 of these adapters.
Are you sure I can use the ESP alone? i'm getting the "espcomm_upload_mem failed" error when I try to plug it in like this video: Easiest ESP8266 Tutorial (Using arduino) - YouTube (I can't get the LED to blink )
Thanks again!
fiteque:
"YF-S201 Water Flow Sensor" is the one i'm using.
As I suspected, this sensor is dead simple - feed it 5 V and it gives an output stream of pulses. The datasheet is probably one of the most useless I have seen, but the description page is adequate.
You could either connect it to your module using the input pin on that module (not sure at present whether that is "Tx" or "Rx" but when I get one in a few weeks I will know) or connect it to one of the two GPIO pins on the ESP-01 via a diode (cathode to sensor).
fiteque:
I guess I'll need to buy 1 of these adapters.
Guess so!
fiteque:
Are you sure I can use the ESP alone? i'm getting the "espcomm_upload_mem failed" error when I try to plug it in like this video: https://www.youtube.com/watch?v=Ao5XcORsYxA (I can't get the LED to blink)
Of course you need to load the ESP8266 libraries in the IDE and select the ESP-01 and be using the programming adaptor which I gather you do not have yet. So I don't know what you are trying to do!
Will look at the video later.
Paul__B:
Of course you need to load the ESP8266 libraries in the IDE and select the ESP-01 and be using the programming adaptor which I gather you do not have yet. So I don't know what you are trying to do!
I thought I could use the UNO, it has the same pins and... it should work well I guess no lol
EDIT: In the comment section, there are people with the same problem but some said it can work. I guess I'll keep trying