💬 Building a wired RS485 sensor network
-
@pjr i dont know what is this "for(byte w=0; w<3; w++)" because i am beginner but i see after change this , my network work better. very better. but no perfect
-
@kimot also do you have idea for improve wireless transport(nrf24)?
because for wireless also i have 50% error for commands.@Reza
Sorry, I do not know.
I am not using radio now (but RS485 too not).
I only look to code and try some RS485 library things,
but only two nodes connected through serial lines.
I am trying understand like MySensors code works to write my own library for CAN bus.https://forum.mysensors.org/topic/5327/can-bus-transport-implementation-for-mys/17
-
@Reza
This code makes, that your node sends three SOH bytes on beginning of message instead of only one SOH. -
@Reza
Like someone writes here, your module maybe includes all needed resistors for the bus on PCB.http://yourduino.com/sunshop//index.php?l=product_detail&p=323
For two nodes it ok and you must not connect any terminating resistors.
For three and more, you must remove this resistors from PCB exclude those nodes, which are on the ends of bus.
Maybe you can divide your "big" problem to several "small" problems.
RS485 is tested bus and MUST work even on long cables.
It must be problem with electricity circuit or software.
Maybe software switchs direction pin to receiving mode early and not all data are send on the bus.
In MyTransportRS485.cpp maybe it is wrong .
It is "hard coded" for crystal 20MHz and bus speed 9600 bd. Try put your values.
//
_dev.flush();
delayMicroseconds((20000000UL/9600)+1);
//Try examples from AltSoftSerial library with different lengths of cables and do not forgot handle your DE pin.
https://github.com/PaulStoffregen/AltSoftSerialOr connect your two nodes only through serial wires and check functionality of your code without rs485 converters.
-
@Reza
Like someone writes here, your module maybe includes all needed resistors for the bus on PCB.http://yourduino.com/sunshop//index.php?l=product_detail&p=323
For two nodes it ok and you must not connect any terminating resistors.
For three and more, you must remove this resistors from PCB exclude those nodes, which are on the ends of bus.
Maybe you can divide your "big" problem to several "small" problems.
RS485 is tested bus and MUST work even on long cables.
It must be problem with electricity circuit or software.
Maybe software switchs direction pin to receiving mode early and not all data are send on the bus.
In MyTransportRS485.cpp maybe it is wrong .
It is "hard coded" for crystal 20MHz and bus speed 9600 bd. Try put your values.
//
_dev.flush();
delayMicroseconds((20000000UL/9600)+1);
//Try examples from AltSoftSerial library with different lengths of cables and do not forgot handle your DE pin.
https://github.com/PaulStoffregen/AltSoftSerialOr connect your two nodes only through serial wires and check functionality of your code without rs485 converters.
@kimot how remove resistors from PCB ? :O there is resistor onboard? so for first and end dont need connect external resistor ? in other means i must for example for 10 nodes , any change in node 1 and 10 ! and remove resistor for node 2 - 9 with soldering?
i test with some hardware. for 30 meter cable i dont use sheild cable. this is without sheild? may be problem for 30 meter is related to this ! is this true ?
i dont change any things in mytransport rs485 just W<3. also sketch is from site
im my transport is:
_dev.flush();
delayMicroseconds((20000000UL/9600)+1);your last experience how many nodes you use ? with how much wire? and how % error for send and receive you have?
-
I agree regarding your rs485 network you may need to adjust resistors. But i've not this setup, even if i would like to try it!
about removing smd resistor..if you have a solder iron, a simple trick :
Let's assume you want to push and remove your resistor to the right..- Add a blob of solder to the right pad (take a magnifier if you're not confident or smd is too small)
- Heat well this pad. Not like hell, lol, but enough so solder will still be melted, for,
- Then quickly move to the left pad, heat it, and push the resistor to the right for removing it.
Be careful with others parts around of course ;)
I hope it's clear :)
-
I agree regarding your rs485 network you may need to adjust resistors. But i've not this setup, even if i would like to try it!
about removing smd resistor..if you have a solder iron, a simple trick :
Let's assume you want to push and remove your resistor to the right..- Add a blob of solder to the right pad (take a magnifier if you're not confident or smd is too small)
- Heat well this pad. Not like hell, lol, but enough so solder will still be melted, for,
- Then quickly move to the left pad, heat it, and push the resistor to the right for removing it.
Be careful with others parts around of course ;)
I hope it's clear :)
-
@Reza
I recommend nothing solder or unsolder now.
Simply start with two Arduinos on two ends of cable.
When your communication will work for these two devices, then you can go further.
For one Arduino write simple sketch, which will periodically send something ("Hello World/n" )
to the bus. Other Arduino with sketch witch will receive characters and sends then through USB serial port to serial monitor on PC. Only with AltSoftSerial library, not with MySensors.
When this communication will work on any length of cable ( I suppose you have not cable longer then 1km at your home ), you can go further.
You do not need drive DE and RE pins by software, simply on transmitting Arduino set it for transmit ( to +5V ) and on receiving Arduino to ground. -
@Reza
I recommend nothing solder or unsolder now.
Simply start with two Arduinos on two ends of cable.
When your communication will work for these two devices, then you can go further.
For one Arduino write simple sketch, which will periodically send something ("Hello World/n" )
to the bus. Other Arduino with sketch witch will receive characters and sends then through USB serial port to serial monitor on PC. Only with AltSoftSerial library, not with MySensors.
When this communication will work on any length of cable ( I suppose you have not cable longer then 1km at your home ), you can go further.
You do not need drive DE and RE pins by software, simply on transmitting Arduino set it for transmit ( to +5V ) and on receiving Arduino to ground. -
Hi, i have a Gateway running and the motion-sensor. The Sensors talks with the Gateway. (Arduino Pins: D2,D8,D9)
Now i have to switch to another Hardware. On the Arduino-Pro Mini i have easy access to 0-RX, 1-TX, 2-D5, 3-D5, 4-D7, 10-13, A1-A3)
Which combination of this pins would be the best, and how can i define it in the sketch ?
Im happe for each hint. -
The 510 ohm pull up and pull down resistors are usually mounted on the master side. Theoretically it
would be best to install it in the middle of your bus line. The 120 ohm termination resistor must always
be used on distances greater than 1 meter and/or baud rates higher than 9600. It’s best to install it as a
norm as noise and reflections will cause havoc on your communication once implemented in the field.
The termination resistors should be mounted at both ends of the bus line. Please note that adding bias
resistors will load the driver IC output. With the indicated values the max number of units on the bus
line is limited to eight 12kΩ, sixteen 24kΩ, or thirty-two 48kΩ units.
For further protection transient suppressors can be installed across the differential lines, from the Vcc to
D+ and from GND to D-.!

-
Google for simple Modbus Master dcouments (arduino forum)
The MAX485 is not the best RS485 chip because of it's own internal impedance.
The chip in the diagram can be change by MAX485, MAX...

https://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf
-
Hi, I'm building my home automation system and I have UTP cables cat5e in walls going to my wall switches. I have four cables, 5 nodes on one cable, 2 nodes on the second cable, and one node on 3rd and one 4th cable. 9 nodes. I know that the RS485 should be connected in parallel on single twisted pair but i cant change cables now cause my walls are painted etc.. So I have few problems, nodes stops working, i need to reset them few times, after few days the network stops to work and i start to search for an answers here. I changed numbers of SOH from 1 to 3 in 274 line of MyTransportRS485.cpp and now I think the network working better. I have 120ohm resistor in every node. You think that I should remove them ? Nodes are max 10 meters from the gateway so the cable lengths aren't so long.
-
Hi, I'm building my home automation system and I have UTP cables cat5e in walls going to my wall switches. I have four cables, 5 nodes on one cable, 2 nodes on the second cable, and one node on 3rd and one 4th cable. 9 nodes. I know that the RS485 should be connected in parallel on single twisted pair but i cant change cables now cause my walls are painted etc.. So I have few problems, nodes stops working, i need to reset them few times, after few days the network stops to work and i start to search for an answers here. I changed numbers of SOH from 1 to 3 in 274 line of MyTransportRS485.cpp and now I think the network working better. I have 120ohm resistor in every node. You think that I should remove them ? Nodes are max 10 meters from the gateway so the cable lengths aren't so long.
-
@nofox
If you have got one free pair of wires in cat5e cable, it is easy to convert your "star" topology to pure 485 bus topology with terminal resistors on both ends only. -
@nofox it's what gohan stated, the 120ohm resistors should only put on the first and last node of you network. And you can only use a "bus" network topology for RS485.You should use the other wires of you Ethernet cable to accomplish this like kimot wrote.
