I am trying to find some info about connecting the esp32 to my Arduino mega in order to add wifi to my project. I need a lot of IOs and the esp does not have them. The obstacle I'm facing now is that I cannot find any solid info on how to wire the two boards together. I want to use the Adafruit HUZZAH32 – ESP32 Feather Board.
The plan is to have both boards mounted on the same breadboard with all sensors connected to Mega and sitting on a shelf in the basement. The ESP will be handling the communications between my PC(which is upstairs) and the Mega.
I want to be able to do data logging (reading all the sensor values and displaying them on a HMI and also record them) but also control the Arduino (if I ever need to force things on and off for maintenance instead of playing with the wires).
I'm new at these sort of things so apologies if it all sounds a bit trivial.
If someone could point me in the right direction it will be greatly appreciated. Thank you.
Apologies if that was to vague. I meant to say to control the Arduino via an app like Blynk or Home Assistant to switch let's say a solenoid off/on or an alarm or relay that are wired to the Arduino. Hopefully this makes a bit more sense.
When you say a serial link do you mean the Rx an Tx pins on the Arduino (19 & 18 for example)?
using two processors is going to require messaging between them as well as messaging to your control application. and then you usually need a serial interface to each processor for debugging and downloading code.
have you considered using an I2C I/O expanders and just the esp32, MCP23017. there can be 8 expander, each with 16 i/o bit, a total of 128
From what I've read a ESP32 is only capable of 3.3V on IO but the relay module that I've got uses 5V th switch coil on and off. Wouldn't that become a bit more complicated when using the IO expanders? If there is a easy way around this problem I would gladly use the ESP32 if not I will probably go with the 8226-01.
As for the number of IO I need about 30 digital(relays+various sensors like float switches and limit switches), about 8 analogue. I want to go with the arduino just because if I need to add more I can and it sounds, based on what I've read so far more robust.
noiasca:
Learn how to program the ESP32, use all the fancy stuff available for the ESP,
I'm sure there are lots of things you can do with an ESP32 that you can't do with a Mega. I have a couple of ESP32-CAM modules and you sure can't do that with a Mega.
But I suspect the standard stuff on a Mega is a lot easier to learn than the fancy stuff on an ESP32 if all you need is the logical capability of a Mega. And the Arduino IDE can program a Mega straight off whereas you have to add extra capabilities to it to program an ESP32. Some beginners may find that quite a challenge.
Is the ESP8266 hard to integrate to my project? Can it be programed with the IDE ? because that's the only thing I know how to use.
How about the esp32 is that difficult to program with the IDE? Which one of these has better defined libraries ?
The reason I'm asking these question is that I'm trying to get an understanding of which of these chips has got more support/ learning material and which one is easier to integrate into this project.
What I got so far is that most people prefer the esp32 but the way I look at it, correct me if I'm wrong I've got the following options:
Arduino + esp8266+ a voltage regulator because it's a3.3V module(esp8266)
Andy_m03:
From what I've read a ESP32 is only capable of 3.3V on IO but the relay module that I've got uses 5V th switch coil on and off. Wouldn't that become a bit more complicated when using the IO expanders? If there is a easy way around this problem I would gladly use the ESP32 if not I will probably go with the 8226-01.
notwithstanding the voltage difference, the current rating of a coil may require a transistor that pulls the coil to ground. A transistor could be driven with a very small voltage. 3.3V is certainly large enough, and would work even if the coil voltage were much higher (e.g. 12V).
However, you still need to connect the 3.3V esp32 to the expanders I2C pins. Fortunately it looks like the MCP23017 can operate at 3.3V
if you communicate with a mega you may need an rs-485 interface to deal with the different voltage levels.
I did a bit of reading and watched a few videos about the 2 boards just enough to make a decision. I will go with the esp32. The question I have for you now is: Which one of the 10s of suppliers would you go with? Adafruit,Sparkfun, amazon,etc. ? Personally I like Adafruit, although they're a bit more expensive than others the quality is much better. Is that a good board to start my project on or are there others with updated versions of the chip or firmware?
I am very happy with the Wemos MINI D1 ESP32 (Wemos MINI D1 ESP32) not least because it is designed such that it can be used as a direct physical replacement for the ESP8266 Wemos D1 Mini in many circumstances, so I can use several of the prototype boards that I have accumulated although it is not breadboard friendly
noiasca:
you could even use the Mega as port expander via I2C, why not. But let the ESP control everything, not the Mega.
+1 for that. Definitely the way I'd go. Use the ESP for WiFi access and to do the project's heavy lifting. Let the little 8-bit Mega do what it's best at ------ handling GPIO port twiddling. It also provides the 5V I/O that's claimed to be needed.
Adafruit has a nice Bi-Directional Level Shifter that's great for I2C and will protect the ESP's I/O from being blown up by 5V I/O from the Mega.
I will go with the esp32. The question I have for you now is: Which one of the 10s of suppliers would you go with? Adafruit,Sparkfun, amazon,etc. ? Personally I like Adafruit, although they're a bit more expensive than others the quality is much better. Is that a good board to start my project on or are there others with updated versions of the chip or firmware?
I don't know their ESP32 module. So can't tell you anything about that. Is there a micro usb on board?
My last order was from here, but currently this could take some time to arrive ^^