Legal Removal Request This form is for reporting content posted on the AB Electronics UK forums that you believe violates your personal legal rights or applicable local laws for your country. Post: Hi There are several RS485 communication protocols available that support addressing but the most common protocol is Modbus. On the Raspberry Pi side, you can use the [url=https://pypi.org/project/minimalmodbus/]MinimalModbus[/url] python library with the RS485 Pi. The [url=https://minimalmodbus.readthedocs.io/en/stable/]documentation for MinimalModbus[/url] includes examples of how to talk to slave devices. For the slave devices, there should be Modbus libraries available for esp32 modules. Another option would be to design a simple serial protocol for communicating with your slave devices. To give you an example a few years ago I designed a communication system for a model railway that uses RS485 to communicate between a Raspberry Pi and a range of slave devices using PIC and Atmel microcontrollers. The communication protocol I used was very simple sending ASCII characters over the serial port. Data packets are variable in length. Byte 1: STX character 0x02 Byte 2: slave address character 1 - '0' 0x30 Byte 3: slave address character 2 - '1' 0x31 Byte 4: command Bytes 5+: attributes - variable length where needed Last Byte: EOT character 0x04 Each slave device would monitor the serial port for any incoming serial data. When it received data it would look for the STX character and set that as the first byte in the packet. When it saw the EOT character it would start processing the packet by checking bytes 2 and 3 to see if they matched the address programmed into the device. If the address matched it would check the next bytes to see what the command was sent and carry out any actions necessary. It the address did not match the packet would be ignored and the slave would go back to waiting for the STX character. Once the slave device carried out the action it would send a message back to the master, for example, OK or ERROR. Using this method the slaves would ignore any data packets meant for the master as they would not start with STX or end with EOT. To give you an example of how this worked in practice the point motors on the model railway could receive three different commands, 1 = move to position one; 2 = move to position two; S = get the status of the point motor. So if you want to move the point motor on address 12 to position 2 you would send the data packet [0x02, 0x30, 0x31, 0x30, 0x04] which in ASCII is [STX, 1, 2, 2, EOT]. The point motor would return the string "POS2" if it succeeds in moving the motor to position 2 or "ERROR" if something went wrong. The protocol I designed did not have error detection as I could see if something did not work correctly but that would be easy to add in by adding a checksum byte before the EOT character. Using a ready-made protocol like Modbus will be quicker and allow you to use slave devices that are already designed to work with Modbus but if you only need something simple to talk to a few devices then designing your own serial protocol is a good way to learn about how serial communication works. Select the country where you are claiming legal rights. Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Aruba Australia Austria Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bosnia And Herzegovina Botswana Bouvet Island Brazil British Indian Ocean Territory British Virgin Islands Brunei Bulgaria Burkina Faso Burundi Cambodia Cameroon Canada Canary Islands Cape Verde Cayman Islands Central African Republic Chad Channel Islands Chile Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Cook Islands Costa Rica Croatia Cuba Cyprus Czech Republic Denmark Djibouti Dominica Dominican Republic East Timor Ecuador Egypt El Salvador Equatorial Guinea Estonia Ethiopia Falkland Islands (Malvinas) Faroe Islands Federated States of Micronesia Fiji Finland France French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guyana Haiti Heard Island and McDonald Islands Honduras Hong Kong Hungary Iceland India Indonesia Ireland Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Laos Latvia Lesotho Liechtenstein Lithuania Luxembourg Macau Macedonia Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia, Federated States Of Moldova, Republic Of Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands Netherlands Antilles New Caledonia New Zealand Nicaragua Niue Norfolk Island Northern Mariana Islands Norway Oman Palau Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Poland Portugal Puerto Rico Qatar Reunion Romania Russia Rwanda Samoa San Marino Sao Tome and Principe Saudi Arabia Serbia Seychelles Singapore Slovakia Slovenia Solomon Islands South Africa South Georgia and the South Sandwich Islands South Korea Spain Sri Lanka St. Helena St. Kitts and Nevis St. Lucia St. Pierre and Miquelon St. Vincent and the Grenadines Suriname Svalbard and Jan Mayen Islands Swaziland Sweden Switzerland Syria Taiwan Tajikistan Tanzania Thailand Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu U.S. Virgin Islands Uganda Ukraine United Arab Emirates United Kingdom United States United States Minor Outlying Islands Uruguay Uzbekistan Vanuatu Vatican City Venezuela Vietnam Wallis and Futuna Islands Western Sahara Yemen Yugoslavia Zambia What legal issue or problem do you wish to report? Please select Privacy / Erasure under GDPR Defamation Intellectual Property Hate Speech Other Please enter the following information so we can process your report. Contact Name: Contact Email: Details of complaint: Submit Complaint