I am working on a wireless sensor network project, in which data is collected at a central node using nRF24 modules and the RFNetwork.h library.

I want to post that to the internet using the famous ESP8266 module, which works fine when used as standalone and programmed with Arduino IDE. But the problem is how to transfer my data from Arduino to the ESP8266 as it only has one serial that is already used to program it?

I have tried to use a nRF24 module that uses SPI with an ESP-12 as it has an SPI header, but it didn't work out and I can't figure out the problem. Is there a way to use ESP core libraries like esp8266wifi.h, wifiClient.h, webserver.h etc., just like we can use the esp8266.h library that uses AT commands to communicate to ESP from an Arduino like in a master-slave manner?

  • Maybe another solution is to link your ESP to one of your Arduino (or a new one, with an NRF24). If you have an ESP-1 you can use serial transmission with AT commands. For ESP-12, it must be possible too, through SPI as you mentioned.
    – jfpoilpret
    Oct 15, 2016 at 7:38

4 Answers 4


Several solutions:

  1. Are your SPI components 5V or 3.3V parts? The ESP8266 is 3.3V only, and is NOT 5V-tolerant; you may have already fried it.

  2. In most cases that I've had problems with SPI with the ESP8266 (in particular, the Adafruit 8266-12E HUZZAH board), they went away when I drastically lowered the SPI speed to 8000000.

  3. Once you've programmed the 8266, and assuming you don't use Serial for debugging output, it's free to use to communicate with the world. Again, be careful about signal levels -- the 8266 is NOT 5V-tolerant, and most arduinos have 5V signals. So either use a 3.3V arduino-like part (my favorite is the Teensy 3.2 for larger projects, and the Adafruit Trinket for smaller ones), or use a level converter. If you need debugging output, you can still use Serial1 for output only (and don't forget to change its bit rate -- by default it's something crazy like 74380bps).

  4. Run the 8266 as another SPI slave and have the Arduino write to it. Or come up with your own serial protocol! Again, careful about signal levels.

  5. You can use a different version of the 8266 (or another wifi chip), one that's already meant to be used with the Arduino. Sparkfun and Adafruit have several, as do a lot of other vendors.

I'd still suggest that you try to work out the SPI problems and stick to the 8266.

Also, don't forget that neither serial nor SPI guarantees data integrity. Always use a CRC to make sure your data were transferred correctly, and have some provision for retransmissions if you can't afford to just ignore corrupted data.


  • actually, according to several articles I've read, the ESP8266 is 5V tolerant on GPIO - of course, that's input, if the connected component requires 5v input signals, then you're out of luck Sep 11, 2017 at 5:06

(It sounds like you have already used the esp8266 so I hope this background isn't too simple, but I'm not sure from your question where you're stuck.)

The ESP8266 modules are programmable. They are (usually) delivered with an application program installed that uses the manufacturer-defined set of "AT<something>" commands to operate it as a WiFi station or access point. There are code libraries for Arduinos or other computers to set it up and use it that way.

You can use its one serial port for either job - communicating to its current application program (interpreter, or your own custom program), much as you do an Arduino's port.

You can program your entire application on the chip and operate its WiFi radios directly, just as the AT-command interpreter does. You'll need the specs for programming the radios though; the AT-interpreter does that for you. Once you've loaded an application program of your own, it replaces the interpreter. To put it back to as-delivered, with the AT-command interpreter running in it, you'll need to re-upload the interpreter (which of course will replace anything else you've loaded).


Seems like you have several options:

1. Find a nRF24 library that works on ESP with the "arduino core" or port one yourself.
2. Implement your own Arduino-to-ESP protocol, using Serial (SoftwareSerial if needed), I2C or whatever.
3. Flash the ESP with the standard AT commands firmware and command it from the Arduino.

IMO, option 1 is best (you would ditch the Arduino completely), but may require significant effort.
Option 2 is academically better than option 3, as it will skip the hassle of dealing with AT commands on the Arduino side and will eventually be more efficient in terms of data bandwith between the Arduino and the ESP. In practice, it probably won't matter.
Option 3 might be the easiest - as much as I dislike the AT commands, they work and you won't have to program two devices constantly while developing your code.

So, in short, if you can go with Option 1 - please do so :)
If not - quickly asses which one will be easier / better for you - option 2 or option 3 and just go with it. Both will work, and are relatively easy to achieve.


...but the problem is how to transfer my data from Arduino to the ESP8266 as it only has one serial that is already used to program it.

  1. After you flash a new firmware serial port becomes free so you can use it for whatever you like.
  2. ESP8266 has two serial ports, not only one (although you can use only TX pin from the second one as RX is connected to SPI bus of the flash).
  3. You can use any free GPIOs for software serial communication.

You can find the details about ESP8266's serial porth here, here, here and here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.