Arduino Mega with Wemos D1 mini as Wifi shield.

Hi,

So I have a Arduino Mega hooked upto a Wemos D1 Mini, Im using the Wemos as a Wifi shield as I wanted to stop using ethernet for more simplicity. I have the devices connected on SPI, I actually use the SPI header on the Arduino but couldn't get Fritzing to connect to it so did the pins instead I also have no SlaveSelect.

I use Jiri's library.

The Arduino is powered via the USB port, everything is working fine, however I read about issues with 5v tolerance for ESP8266 GPIO so I wanted to ask a few questions before I can decide if I have completed my project or not.

Should I be Level shifting MISO, MOSI and SCK down to 3.3v?

The ESP8266 needs its own 3.3V power supply. The Mega's 3.3V is not enough!

.

ieee488:
The ESP8266 needs its own 3.3V power supply. The Mega's 3.3V is not enough!

it is enough if you don't go to illegal high RF transmit power which requires 180 mA.
the 3.3 V pin of Mega R3 can supply 150 mA.

Kfo:
Should I be Level shifting MISO, MOSI and SCK down to 3.3v?

yes, for long term use, add level shifting on SCK, MOSI and CS (you have no CS on the picture). but not voltage dividers. they distort a fast communication.

I must say, that Jiri's library WiFiSpiEsp is very slow, because the transfers are not optimized. there is much more communication that is really necessary. for example every call to client.available() goes to firmware, data are not buffered so every print o read of a small count of bytes goes immediately over SPI. So it is for example impossible to OTA update the Mega over it.

If you don't need SSL, my WiFiEspAT library, which uses the AT firmware and serial communication is much faster.

Juraj:
yes, for long term use, add level shifting on SCK, MOSI and CS (you have no CS on the picture). but not voltage dividers. they distort a fast communication.

I must say, that Jiri's library WiFiSpiEsp is very slow, because the transfers are not optimized. there is much more communication that is really necessary. for example every call to client.available() goes to firmware, data are not buffered so every print o read of a small count of bytes goes immediately over SPI. So it is for example impossible to OTA update the Mega over it.

If you don't need SSL, my WiFiEspAT library, which uses the AT firmware and serial communication is much faster.

CS? You mean SS? If so I know, I said in the first paragraph I don't use SlaveSelect.

Could I use some form of transistor like a NPN to level shift? Any advice one this would be great as its a very confusing part for me.

I use Jiri's Library as it was the first I found that enabled me todo what I required of the Wemos, also its drop in replacement for the Ethernet library so I have had to make no code changes. I am not worried about OTA, Arduino does all the work, Wemos simply relays information to Influx over WIFI.

I think if I am to use AT I will need to change code?

Kfo:
CS? You mean SS? If so I know, I said in the first paragraph I don't use SlaveSelect.

Could I use some form of transistor like a NPN to level shift? Any advice one this would be great as its a very confusing part for me.

I use Jiri's Library as it was the first I found that enabled me todo what I required of the Wemos, also its drop in replacement for the Ethernet library so I have had to make no code changes. I am not worried about OTA, Arduino does all the work, Wemos simply relays information to Influx over WIFI.

I think if I am to use AT I will need to change code?

the WiFiEspAT library has the same API as all other Arduino WiFi libraries. (it handles the AT commands for you).

Juraj:
the WiFiEspAT library has the same API as all other Arduino WiFi libraries. (it handles the AT commands for you).

Ok cool, I will take a look into it.

Any help with level shifting, or can you direct me to maybe a part picker I can punch in my requirements?

Thanks.

https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide/all

Juraj:
it is enough if you don't go to illegal high RF transmit power which requires 180 mA.
the 3.3 V pin of Mega R3 can supply 150 mA.

You keep writing that and you were told that is WRONG and you persist in spreading false information!

The specs for the Mega says 50 mA !!!!

https://store.arduino.cc/usa/mega-2560-r3

DC Current for 3.3V Pin 50 mA

.

"The Arduino is powered via the USB port, everything is working fine,"

Well, I'd go with that. If it works without issues, then keep using it. Let the other people debate about how many angels can dance on the head of a pin. If you change things, then the way it operates can change. There seem to be cases where the ESP is somewhat ~5v tolerant for some operations.

ieee488:
You keep writing that and you were told that is WRONG and you persist in spreading false information!

The specs for the Mega says 50 mA !!!!

https://store.arduino.cc/usa/mega-2560-r3

DC Current for 3.3V Pin 50 mA

.

Thanks, I saw you reply also regarding the Mega 3.3v not being enough.
I connect using 802.11g, I checked the ESP-8266EX data sheet and see the power consumptions;

TX802.11 g, OFDM 54Mbps, POUT = +15 dBm - 140 - mA
Rx802.11 g, 1024 bytes packet length, –70 dBm - 56 - mA

Could you explain to me how its working although TX is well above the rated current.

zoomkat:
"The Arduino is powered via the USB port, everything is working fine,"

Well, I'd go with that. If it works without issues, then keep using it. Let the other people debate about how many angels can dance on the head of a pin. If you change things, then the way it operates can change. There seem to be cases where the ESP is somewhat ~5v tolerant for some operations.

I am only using 5v 1A at the moment.

Id rather try todo things the 'correct' way but so many debates around, I just don't want failure down the line and be struggling to find what Ive done wrong in terms of the hardware side of things.

ieee488:
You keep writing that and you were told that is WRONG and you persist in spreading false information!

The specs for the Mega says 50 mA !!!!

The information on that page, and on the Uno R3 page, is wrong.

The Mega and the Uno R3 both have a dedicated 5-pin 3.3volt/150mA regulator.
See for yourself, by looking up the datasheet of those LP2985 chips.

The Arduino pages are still referring to OLDER versions of the Arduino,
where the 3.3volt came from the USB<>Serial chip.

We tried to make them correct several mistakes like that, but failed.
Leo..

Wawa:
The information on that page, and on the Uno R3 page, is wrong.

The Mega and the Uno R3 both have a dedicated 5-pin 3.3volt/150mA regulator.
See for yourself, by looking up the datasheet of those LP2985 chips.

The Arduino pages are still referring to OLDER versions of the Arduino,
where the 3.3volt came from the USB<>Serial chip.

We tried to make them correct several mistakes like that, but failed.
Leo..

Thanks, I decided to take a look at the data sheet an you are correct along with Juraj.

Could someone please now help with my original question in regards to level shifting, would something like a 2N7000 be ok for this job?

The 2N7000 is not a very good choice, because it's not really a logic level fet.
The BSS138 is AFAIK normally used for 3.3volt level shifting.
Leo..

Wawa:
The 2N7000 is not a very good choice, because it's not really a logic level fet.
The BSS138 is AFAIK normally used for 3.3volt level shifting.
Leo..

Thank you I will take a look.

Wawa:
The 2N7000 is not a very good choice, because it's not really a logic level fet.
The BSS138 is AFAIK normally used for 3.3volt level shifting.
Leo..

I cant really work with surface mount items yet, I dont have the soldering skills.

I had a thought, an I have a few left from a previous project. Could I use LDO MCP1700-3302E?

Kfo:
Could I use LDO MCP1700-3302E?

No. An LDO (voltage regulator) is not a mosfet.

Kfo:
I cant really work with surface mount items yet, I dont have the soldering skills.

Then your only option is to buy a level shift board.
Leo..

Wawa:
No. An LDO (voltage regulator) is not a mosfet.
Then your only option is to buy a level shift board.
Leo..

Thanks for your input.

Why a WeMos and a Mega.
The Wemos has more processing power and more memory than a Mega.
If more I/O is needed, then an I2C port expander for the WeMos could make more sense than adding a Mega.
Leo..

Wawa:
The information on that page, and on the Uno R3 page, is wrong.

The Mega and the Uno R3 both have a dedicated 5-pin 3.3volt/150mA regulator.
See for yourself, by looking up the datasheet of those LP2985 chips.

The Arduino pages are still referring to OLDER versions of the Arduino,
where the 3.3volt came from the USB<>Serial chip.

We tried to make them correct several mistakes like that, but failed.
Leo..

Thank you.

This is extremely disappointing and makes me lose a lot of confidence in Arduino !

However, I still think it is unwise to use the Arduino's 3.3V.
The ESP-01 was flaky for me when connected to the Uno's 3.3V
Once I used a dedicated 3.3V power supply for the ESP-01 the random problems disappeared.

.

Two small signal diodes in series will drop 5v down to 3.6v which might be close enough for the power situation. The typical ones may be rated for 800ma.