SoftwareSerialRS485Example
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
VirtualWire library for Arduino and other boards
dnvodcwan
2020-07-08 06:57:59
Arduino RF decoder
基於Arduino 開源平臺下的射頻解碼,目前可以解PT2262等通用碼, 開關類使用最好的力沃,窗簾類最好的杜亞.奧新. QQ:27706646
dnvodcwan
2020-07-08 06:19:12
RS485-Modules
dnvodcwan
2020-07-08 06:19:00
樹莓派和Arduino使用USB進行通信基於Python——For初學者
a_52hz
2020-07-08 01:04:16
Arduino和ESP8266引腳圖
Archger
2020-07-07 07:37:15
ARDUINO電路板及編程語言
lchu55
2020-07-06 20:43:48
【Arduino基礎】arduino開發板初次使用-真小白
Yellow_pig#
2020-07-06 19:05:41
【Arduino基礎】蜂鳴器發聲實驗
Yellow_pig#
2020-07-06 19:05:41
【Arduino基礎】超聲波測距實驗
Yellow_pig#
2020-07-06 18:28:48
【Arduino基礎】一位數碼管實驗
Yellow_pig#
2020-07-06 18:28:48
【Arduino基礎】按鍵控制LED燈亮滅實驗
Yellow_pig#
2020-07-06 18:28:48
【Arduino】基於4*4鍵盤製作計算器
Yellow_pig#
2020-07-06 18:28:48
【Arduino基礎】DHT11溫度傳感器實驗
Yellow_pig#
2020-07-06 18:28:48
【Arduino基礎】LCD1602液晶驅動實驗
Yellow_pig#
2020-07-06 18:28:38
SoftwareSerialRS485Example
RS485 is a physical connection standard for Serial data transfer. It can be used between 2 or more Arduinos and to various I/O devices that support it.
The example on the right shows two Arduinos connected with low-cost RS485 "Electronic Bricks" or "breakout boards" that use a MAX485 chip. See it HERE:
RS485 uses a pair of wires in a differential configuration that allows long distance communication (up to 1.2 Km) and very high speeds. It also allows multiple senders/receivers along the same cable: "Multi-Drop". It also needs Ground - but that usually can be the local electrical ground, so only the two wires (usually a twisted pair in some type of cable) are needed.
In the example these are the red and green wires connected to A and B at the bottom. Also note the connection details on the right photo and refer to the pin connections shown in the software examples below:
RS485 in this example we show is Half-Duplex. This means it can send or receive on the same wires, but in only one direction at a time. See more about these modules and RS485 networksHERE:
The example Software Sketches below use the Software Serial library that is provided with the Arduino IDE. This allows use of almost any Arduino pins for Serial Data connections, and allows simultaneous use of the standard Arduino USB Serial communications. The example here uses the Arduino serial monitor to allow you to type in data to send to the Master Arduino. Another serial port is created with the Software Serial library, using pins 11 and 12.
This port sends the data to a second remote Arduino over RS485. That Arduino sends the same data back to the Master Arduino where it is sent back to the Serial Monitor for you, the user to view.
NOTE: A working system with your application running over multiple Arduinos should have some organized data movement and error-checking. Nick Gammon has a nice library that does this here: http://www.gammon.com.au/forum/?id=11428
The two Arduinos are connected by 3 wires: Ground, and pins 11 and 12.
The second Arduino runs the code in the second example below. You can copy and paste these into the Arduino IDE. (NOTE: You can run two copies of the Arduino software at once if you wish. Keep track of which Arduino is on which Serial Port!).
You use this by bringing up both connected Arduinos and running the Serial Monitor on the "Master". Type in the top window of the Serial Monitor and it should be echoed back as it is sent to the second Arduino and looped back. You should see the Pin13 LED on the Remote Arduino blink as the data is received and sent back.
Master Arduino Sketch:
Remote Arduino Sketch: