1

For one of my projects, I need to transmit data from NodeMCU to my Arduino Nano, in real time, I used S-Bus, but it quite unsatisfies me, as, slight latency is taking place. I am transmitting a JSON file, with 4 signed 16 bit integeres.

Now,I need to know, what is the fastest and most reliable way to transmit data from NodeMCU to an Arduino Nano. Any detailed description, or even suggestion will be very much helpful. Thanks in advance !

asked Jul 19, 2020 at 8:11
2
  • 1
    what does the Nano do, what the NodeMcu can't do by itself? Commented Jul 19, 2020 at 8:49
  • What do you mean with "slight latency" exactly? And what S Bus library did you use? As the library, that I have found uses UART underneath, so with interface did you use at which baud rate?and do you really need to transmit JSON? using a binary protocol wiuld be way faster Commented Jul 19, 2020 at 14:42

1 Answer 1

0

If it comes to speed and reliability you have to choose an interface that is handled in hardware on both sides. For the arduino nano you have the following options (nodeMCU supports all of them):

  • UART:
    • not very fast (order of 10kbit/s), but it's full-duplex (asynchronous communication in both directions)
    • implementation is trivial due to Serial.h
    • long distance (order of meters)
  • I2C:
    • not very fast either (order of 100kbit/s), but not full-duplex
    • implementation is straight forward because both slave and master are implemented in arduino library
    • only over short distance (order of cm)
  • SPI:
    • quite fast (>1Mbit/s), full-duplex
    • implementation might require some experience (as far as I know, slave mode is not supported by SPI.h)
    • long distance (order of meters)

Which of those is the best option still depends on your specific requirements, but personally I like SPI very much because it is very fast and stable.

answered Jul 19, 2020 at 8:57
3
  • SPI is full duplex. All of those protocols can reach into the megabits-per-second (with the exception of UART if using SoftwareSerial.h which has an upper limit of about 9600 baud). Commented Jul 19, 2020 at 9:37
  • @Majenko you're right about SPI being full duplex, I will edit my answer. But I doubt that you are able to run either UART or I2C in the order of Mbit/s reliably on an atmega328. Also SPI might work at >10Mbit/s, I just made conservative estimations Commented Jul 19, 2020 at 10:09
  • Sure you can run it reliably at Mbaud. Why wouldn't you be able to? The fact that it's an 8-bit MCU doesn't mean that the hardware peripherals are slow too. It's more a question of if you can process the data you have received fast enough for Mbaud to make any real-world sense. As long as the baud rate error percentage at both ends of the connection are within tolerable amounts (which can just mean selecting the right baud rate to run at) you can go into the 1-4Mbaud range. The 16MHz clock speed limits your upper end more than anything else. Commented Jul 19, 2020 at 10:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.