#106 RS485 Serial Data Transmission – on wires (no radio waves)


If data transmission via radio waves is not for you (see video #73 on the nRF24L01+ modules) then maybe good old 2-wire transmission using the RS485 interface is a better choice.

The modules are to be had for pennies, the coding is simple and no libraries are required although we do use the SerialSoftware library to create a new serial port on arbitrary GPIO pins – not needed if you have a Mega 2560 as that four hardware serial ports built right into the hardware.

Data transmission speed can be quite high (115200 bps) and distances quite long (1.2km) but not both at the same time!

All in all, this can be a solution for outlying buildings, sheds, barns and the like as long as they have power.

As a bonus, you get first look at my new blog which I’m going to use to fill the gaps between videos. Yes, I know, I’m spoiling you.

All code can be found in my Github:

Interesting links about stuff I mention in my video:

Wikipedia article on RS485

Bangood RS485 modules

Nick Gammon’s excellent article on RS486 including libraries and multidrop example

My new blog! All about stuff I never get to video about.

Here’s one I made earlier… classic childrens TV

My channel and blog are here:


Nguồn: https://rmacct.org/

Xem thêm bài viết khác: https://rmacct.org/cong-nghe/

  • Excellent tutorial on RS485. I am justing a project that will be using RS485 and your video was a big help. Thanks so much..

    David Sammet July 4, 2020 1:58 pm Reply
  • Very nice tutorial, 1 quick question, If you had more then 1 slave how to determine the slave id?

    Graciano Romero July 4, 2020 1:58 pm Reply
  • RS485 !!!

    Kenn Mossman July 4, 2020 1:58 pm Reply
  • Thx for the good video! i tried it out immediately but unfortunately only got This: Received:?
    in the Responders Serial Monitor. Did i wire something incorrectly? pls help

    Dominik July 4, 2020 1:58 pm Reply
  • Thanks but it’s just too long and rambling for me

    Mark Hall July 4, 2020 1:58 pm Reply
  • Thank you Sir for another great video!!! Question: what is the relation between baud rate and admissible transmission distance? Half baudrate means double distance or is it more complicated? Here's an idea for some future video: PCA9615 that converts I2C to a differential line. Looks quite nice for long distance communications with sensors and there's surprisingly little amount of info online. Best regards

    Alex July 4, 2020 1:58 pm Reply
  • Thanks to you and Gammon, I got my RS485s working. The absence of that delay that Gammon found out was the culprit of the failed communication.

    Ildefonso Zanette July 4, 2020 1:58 pm Reply
  • thanks, but i shock see price on banggood, in my country maybe equal $0.3

    Rabizza 2016 July 4, 2020 1:58 pm Reply
  • love you man.. wanna give you hug right now.. been battling rs485 for over a week now and getting nowhere.. this opened up the opportunity for me to go to the next phase in my home automation system im building. go to this link. https://www.dropbox.com/s/3renihvj2xt1y7h/20191007_031146.mp4?dl=0

    want to have remote arduino nanos around the house detecting motion and writing a numeric code back to main controller with 8 ch dimmer board. codes will specify which rooms detect motion and which havent… if (motion_livingroom == High) write 10001 across rs485 to dimmer control panel. if (motion_kitchen == high) write 20001 …ect..ect
    need help with if statements to write certain codes for certain conditions…

    Spencer Roberts July 4, 2020 1:58 pm Reply
  • Hi, great video, I have a question, is it possible to connect multiple slaves (rs485 output sensors) to MAX 485 (to A- B), and read slave values from Arduino, Thanks in advance

    PURVEYOR ENTERPRISE July 4, 2020 1:58 pm Reply
  • Release the magic smoke from it!

    Adam Bryant July 4, 2020 1:58 pm Reply
  • What Arduino plugin are you using for your eclipse IDE installation? Didn't know there was even a plugin for eclipse prior to this video.

    Ri5ux July 4, 2020 1:58 pm Reply
  • Amazing video! Which ide are you using?

    Boi Watcher July 4, 2020 1:58 pm Reply
  • Check my RS485-CAN Module: https://youtu.be/nAYsmBIwneQ

    Inno Maker July 4, 2020 1:58 pm Reply
  • Great project Ralph, Can you help me fixing issue. My master somehow not receiving anything back. It only sending. Not sure if slave is even getting message.

    Akshay Rudraksha July 4, 2020 1:58 pm Reply
  • Hi, have you used the RS232 shield for sending and receiving serial data, I am looking for help as I want to get an Arduino Uno to talk to an 8080 kit computer.

    Susan Amber Bruce July 4, 2020 1:58 pm Reply

    This is a HUGE subject to try to cover briefly in a comment. Suffice to say the following.

    1. MASSIVE inductive spikes (10's thousands of volts) can appear on the outdoor connections that can blow your circuitry (literally) to smithereens. Research for example opto and galvanic isolation of RS485 lines.

    2. Protect your circuits and youselves as much as possible by fitting suitable lightning arrestors and transorbs (tranzorbs, TVS diodes) with suitable fuses in series – Google for more info.

    3. Even when any outside mains power supply has been properly and professionally installed with maybe individual bonded earth in addition to any SWA earth cable back to the consumer unit, NEVER, NEVER, NEVER assume that there is ZERO voltage between ground potential in the outbuilding and ground potential in the house!! It MIGHT spike to several thousand volts difference during an overhead lightning storm!!

    It's why it's not such a good idea necessarily to have an outside supply from an MCB covered by an RCD feeding other internal circuits as well. Use a separate supply feed altogether from the main isolator or use an RCBO connected BEFORE the main RCDs. Otherwise you may find spurious whole or half house power trips happening all the time.

    Hope this doesn't confuse people too much but please research on line as it is important for YOUR life and safety as well as to protect your gear.

    Bob Lewis July 4, 2020 1:58 pm Reply
  • Hi Ralph I do think RS485 deserves to be revisited to scratch a little deeper below the surface. You had a defective module first time round so you were unable to create a multidrop network. Additionally, you never overcame the buffered delay in printed characters.

    Brian Oldford July 4, 2020 1:58 pm Reply
  • Hi, thanks good information

    sunil satalkar July 4, 2020 1:58 pm Reply
  • Cool, reminds me of my old days when I ran Land-line teletype over in Vietnam, we dealt with a sort of ancient version of this using tube sets that amplified the signals after they had been processed by the crypto gear, I also did some time in the Brigade Headquarters Switchboard room as an operator for a few months, this was where I was exposed to the phantom and phantom simplex circuits using the earth as one side of a land line phone circuit it was really amazing, we could go from the Cam Rahn Bay to Saigon and to Phu Bi using just the earth for one side of the circuit. Basically one wire communications. Of course we did use special gear that got it done, I still recall the glow from the tubes in those boxes….

    Jerry Ericsson July 4, 2020 1:58 pm Reply
  • Nick's page says he is using an LTC1480 and that is a 3v3 part. the boards from Aliexpress are 5v because they use the MAX485 chip

    Dave -in-NJ July 4, 2020 1:58 pm Reply
  • SoftwareSerial doesn't work with big sketches

    ellpancha July 4, 2020 1:58 pm Reply
  • Used RS485 for my original home grown home control system, about 9 years ago. Had the same problem with the output buffer.
    RS485 worked well for a few devices but found CAN bus a lot easer and more reliable for multiple devices. The MCP2515 CAN bus Module are a bit more expensive but still less than a £1 each (from AliExpress) and go up to 1Mb/s and use the same number of com wires.
    If you use a micro controller with built in CAN bus (e.g. ESP32) you can just use a SN65HVD230 CAN bus buffer about the same cost but requires fewer pins.

    Nick Burton July 4, 2020 1:58 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *