PlatformIO Community

How to use ESP8266WiFi.h library with arduino mega board (megaatmega2560)?

Sorry this topic looks so basic, this is my first attempt using platformio IDE, btw this is my platformio.ini content

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino

As far as I know esp8266 base library (https://github.com/esp8266/Arduino) are automatically included on platform = espressif8266, but megaatmega2560 board are not supported on platform espressif8266. Is there any way to use esp8266 base library with megaatmega2560 board?

The ESP8266-Arduino Core can not be used with the ATmega board. These are two entirely different types of chips.

Do you expect WiFi functionality on the Mega board when using the ESP8266 core? Or do you want to use a library written for the ESP8266 on the ATmega?

1 Like

I want to use a library written for the ESP8266 on the ATmega, because I’m using ESP8266 module with arduino mega, not programming ESP8266 as an independent platform, here is a connection sketch between arduino and ESP8266 to explain what I mean

  • Above schematic will destroy the ESP8266 because you’re putting in 5V levels from the Mega’s TX pin to the 3.3V device that is the ESP8266. You must use a voltage divider to convert the voltage.
  • You cannot simply port a library which uses direct sockets etc on the ESP8266 to the Mega, you need to re-implement using a library which lets you create these sockets. See https://github.com/itead/ITEADLIB_Arduino_WeeESP8266 or https://github.com/ekstrand/ESP8266wifi for a library.
  • which ESP8266 library do you mean?
  • It may be easier for you to flash the ESP8266 with a custom firmware which has this library and accepts the to-be-sent data via UART.
2 Likes

Thanks for this question, because your question I began looking for the ESP8226 modules, all this time I’m only using ESP-01 and what I know that very device are what every people call ESP8266, turns out there are a few type.

I’ll try this out, thank you very much :+1:

Eh sorry I was missing the word “library” here. But anyways yeah, you might find working with a NodeMCU (ESP-12F) way more confortable and might not actually need the Mega at all depending on your application.

2 Likes