💬 Building a wired RS485 sensor network



  • @pjr thank you for help , i read that topic hardly 🙂 because i am weak in english.
    What I understand , this problem is about collision , command and ack ! and related to transport rs485 and other friends trying to solve this ! is this true ?now , a rs485 network is not complete and Ideal and stable in mysensors.
    i think all problem is related to collision in short wire and long wire. in many short wire i have not problem(between two nodes). in short wire gateway detect node and connect but many command are failed . in long wire gateway can not detect node and can not connect never.



  • @Reza
    Original RS485 library was written so, that multiple SOH characters is sended on start of package.
    In Mysensors library it is only one times and it can be problem for synchronization and arbitration.

    Try in MyTransportRS485.cpp in function "transportSend" change line 274 from

    for(byte w=0; w<1; w++) {

    to

    for(byte w=0; w<3; w++) {



  • @kimot said in 💬 Building a wired RS485 sensor network:

    for(byte w=0; w<1;

    thank you i will test this and again feedback here



  • @kimot this is good. i am testing . in the first test ((just for 2 node: gateway and one relay)) i see this is work well with 15cm wire. other test with 1meter and 5 meter work well.for 30 meter (CAT6) with 120 ohm resistor (first and end bus) dont work 🙂 without resistor work with 15-20% error ( dont receive or send command and ack)
    but i think this is good for 2 nodes and short distance and for more nodes and distance increase % errors. is this true ?



  • @kimot also do you have idea for improve wireless transport(nrf24)?
    because for wireless also i have 50% error for commands.



  • Will the result change if you add more sync(SOH) chars?



  • @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



  • @Reza
    This code makes, that your node sends three SOH bytes on beginning of message instead of only one SOH.



  • @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



  • @kimot thank you for help 🙏



  • @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/AltSoftSerial

    Or connect your two nodes only through serial wires and check functionality of your code without rs485 converters.



  • @kimot how remove resistors from PCB ? 😮 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?


  • Hardware Contributor

    @Reza

    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..

    1. Add a blob of solder to the right pad (take a magnifier if you're not confident or smd is too small)
    2. Heat well this pad. Not like hell, lol, but enough so solder will still be melted, for,
    3. 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 🙂



  • @scalz This is an exciting job 🙂
    thank you
    i hope it is clear too 🙂



  • @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.



  • @kimot this hard for me because i am beginner 🙂 but thank you very thank you for help 🙏 🙏 🙏


  • Hardware Contributor

    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-.!
    0_1491314128147_upload-f4c63383-2b9a-4f3d-bd48-1e25fcf9dc76



  • 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...
    0_1491314500978_upload-db69c9ce-43b6-430d-8807-74438ad83b96

    https://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf



  • FYI
    0_1491315316611_upload-40d28ad1-8ba3-4a11-aa7b-5bd1e84424d2


Log in to reply
 

Suggested Topics

496
Online

7.0k
Users

7.9k
Topics

84.8k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.