It only takes a minute to sign up. I have Raspberry 2B with Raspbian Jessie. I want my Raspberry Pi can communicate with some sensors via RS interface. I tried to use three types of adapters:. At first I tried to communicate with the sensors from my PC Windows and everything works just fine, serial ports and adapters work perfectly. Next I tried to repeat this on my Raspberry Pi. A have done all preparations on the Raspberry Pi to communicate via serial port and RS using this article and others in the Internet.
There is Python code for serial port connection, sender and receiver:. When I connect both adapters to the Raspberry to make an echo this script works fine, I can send and receive messages in both directions. It's OK!
Subscribe to RSS
They are just lost. There are no any exceptions, error codes or something else. Does anyone know what could be the problem? Help me please! Googling does not help. Maybe the problem is in permissions? Maybe I forgot about some settings of serial ports? Or do I use wrong devices but they work with my PC? I also try to use this adapters :.
But not for parity. To test this i connect 2 same devices between themselves via RS and connect them to Raspberry Pi. Then i use picocom to change device paramters and trancive data between them.
Because used other driver. I try this, but i recieve echo-signal when send some data over this device. And programm for polling my devices over RS recieve error. It connected to Raspberry Pi where runnning ser2net to access to serial port over Internet. This device based on FTDI chip and his driver support all modes of serial ports various parity, databits, stopbits. Now, on restart this driver loaded firtst to work with usb-rs The problem of connecting the Raspberry Pi to my PC via serial port has been solved by setting all port parameters more precisely in both sides.
The pySerial is working perfectly for all mentioned devices in case of using simple serial port. But I couldn't set up communication with sensors via RS standard where it is required.By David Herron ; Date: June 18, Arduino's are very popular for DIY or IoT projects involving a small computerized controller board, some GPIO pins to read inputs from the environment or to control devices, with optional communication with remote services.
Theoretically an Arduino, or for that matter larger computers like the Raspberry Pi, can replace the PLC devices commonly used in industrial control applications.
Why spend several hundred dollars on an expensive PLC device when the same goal can be achieved more flexibly and inexpensively with newfangled embedded computers like the Arduino? A key to this is for an Arduino or other embedded control computer to interface with MODBUS and other protocols used in industrial settings. The last is interesting considering the huge variety of sensors available for Arduino. Consider a simple energy monitoring project - One can interface a CT current transformer to measure the current in a circuit, and directly measure the voltage using an analog input, a Sketch could read that data from the sensor, and make it available via MODBUS.
The Arduino cannot natively connect with an RS network, but can do so with this shield. The shield is inexpensive and slots directly onto the Arduino. Once you get the RS shield, go ahead and slide it on top of the Arduino.
Once you have the parts assembled, it will look something like the picture at the top of the article. At the Github project you'll find additional examples and documentation.
It is very simple to wire the temperature sensor to the RS shield. Simply match the wires from the sensor to the clearly labeled connections on the shield. We'll be taking the program section by section, so keep appending to the same Sketch.
In this section we're setting up the LiquidCrystal and ModbusMaster libraries.
These global variables will hold information we'll display on the LCD. The setup function is run once, of course. We initialize the display parameters and the global variables.
The DisplayCurrentValues will be shown later, and it takes care of displaying values on the screen. Remember that loop is repeatedly executed, and the delay at the bottom means this will be executed once a second.
In the middle we readInputRegisters to retrieve the temperature value from the sensor. Remember that in this sensor, the value is stored at input register 1, in centigrade, but multiplied by We check the status because I've seen flaky results with this temperature sensor. In CheckForDataChange If they're not equal then the data has changed, and at the bottom of the function we call DisplayCurrentValues if it is different.
In other words, the function does what it bills itself to do -- it checks if any data has changed, and if so it calls DisplayCurrentValues.
Finally we get to see DisplayCurrentValues. In this function we display the temperature and the timestamp seconds since the Arduino was booted. If an error occurred, an error code is printed instead.
The RS shield gives us an extra step to perform whenever uploading a program. If all went well, the program will compile and then successfully upload. As soon as it does the Arduino display will begin showing the display.
It must be reset to UART in order to communicate with the temperature. There's a whole slew of sensor gadgets available for Arduino, as well as relay boards, and motor controllers, and on and on.
It only takes a minute to sign up. Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Asked 1 year, 3 months ago.
Subscribe to RSS
Active 1 year, 3 months ago. Viewed times. Zeref Zeref 11 3 3 bronze badges. Sounds like a hardware problem. Show the schematic, and an oscilloscope trace. Dec 20 '18 at Active Oldest Votes. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. The Overflow How many jobs can be done at home? Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap. Related 0. Hot Network Questions.
Other places seem to have various combinations of connecting DE to ground and RE to positive, and other such things. Additionally, the places that say RE and DE should be tied together and then connected to a microcontroller, also have conflicting information about how these should then be controlled through the software.
You don't need any pull-up or pull-down resistors if you're driving those pins with normal output pins on your micro. DE is the 'Driver Enable' pin and must be pulled high while you're transmitting data.
Depending on your micro and how you're using its interrupts you may need to be careful about when you pull it back low - check that all of the bits are completely finished first or you risk truncating the end of your message. You must pull it back low before you'll be able to receive anything.
RE is the 'Receiver Enable' pin and must be pulled low whenever you want to be able to receive data. You'll notice that the DE and RE pins have opposite polarity.
DE is active-high and RE is active-low. So you can tie them together and control them from one pin if you want to - high means you want to transmit DE active, RE inactiveand low means you want to receive RE active, DE inactive.
Another possibility is to tie RE to ground and only control DE. You would use this configuration is you want to be able to listen to yourself talk.
This would be useful in cases where there could be multiple masters talking on your RS bus and you need to check that what you think you're sending is not being corrupted by another transmission occurring at the same time. If you're only ever going to be either transmitting or receiving then you could tie both DE and RE high permanent transmit or both low permanent receive. No pull up or pull down resistors are required for the enables.
Depending on what you're wanting to do and what the chip allows for, you can tie them together and drive them together high is TX, low is RXor drive them both separately. The latter allows for a low power state on the transceiver. So in that case, I'd tie them together and drive them together.
This depends on what you're trying to accomplish. If you need to enable the driver, DE needs to be high.Released: Aug 11, View statistics for this project via Libraries.
MinimalModbus is an easy-to-use Python module for talking to instruments slaves from a computer master using the Modbus protocol, and is intended to be running on the master. The only dependence is the pySerial module also pure Python. There are convenience functions to handle floats, strings and long integers in different byte orders. It is open source, and has the Apache License, Version 2.
Maintainers JonasBerg. Features MinimalModbus is an easy-to-use Python module for talking to instruments slaves from a computer master using the Modbus protocol, and is intended to be running on the master. Tested with Python 2. Support for Python2 will be dropped in This package uses semantic versioning. Release 1. Support more byteorders endianness for floats and long integers.
It would great if someone would pick up support for these instruments in a separate project. Requires pyserial 3. Removed module level constants for default values, as they were confusingly named. Other fixes: Allow slave addresses also in the reserved range up to Reported by GitHub user gnbl. Serial port read and write buffers are cleared before each request to the instrument.
Pull request from GitHub user mrrs6. Check whether the serial port is open before trying to open it. Reported by Matthias Bolte.Please read the Help Documents before posting.Python Q & A: PySerial Introduction
Hello There, Guest! Login Register. Login Username: Password: Lost Password? Remember me. Thread Rating: 3 Vote s - 2. Thread Modes. Coada Unladen Swallow. At first, I was not sure that I will receive anything while listening to the port since I wasn't sure of the compatibility. Had to try it tough.
After I did the setup and made a little code in python using the pySerial class I was able to receive the same messages that are shown in the proprietary software of the device. On the proprietary software I can give commands to the device and this device can trigger, from example, a relay. While giving such a command and while monitoring the communication between the Raspberry and the device I "recorded" all the messages, in hex, that were transmitted on the S-bus protocol, including the code sent from the proprietary software to the device to trigger the relay.
My goal is to send the same command as hex code that triggers the relay from Raspberry and not from the proprietary software; and to work of course :D. This seems like Captain Obvious. Unfortunately, it didn't happen. As a mention, I managed to command the relay with commands from the Raspberry to the device on the RS port also present on the device.
I am trying to make the commands work through the S-Bus port since it will benefit more. Things to try? Serial Novice :D. Some things come to mind.
Check the protocol on your serial port, you are mainly interested in number of databits This only matters if the command that triggers the relay uses bit 7 numbered for any purpose. It is possible to set databits to 7 or 8, with or without parity.
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I'm trying to use a Beaglebone Black running Angstrom 3. I bought the board pre-assembled with pins and a terminal strip. A friend of mine tested it with an oscilloscope and declared that the RS board does work.
The board has five pins that connect to the BBB. But I can't get communication to work correctly using the RS board.
The RTS on the board works backwards from the way I expect it to. If I have it setup without the bonescript mentioned above, then it will be on normally and blink off while transmitting. If I use my bonescript hack then it will be off normally and blink on while transmitting which is what I want. However this only works when using echo from the command line. It will not blink while transmitting. As soon as I make the statement in python:.
It does not blink when sending information using ser. As a result the rs board is not enabled for transmission.
I am able to use ser. I want it to work automatically when the serial port is transmitting data and it does when using echo, but not in Python. RTS will be asserted except when the kernel input buffer is full. The kernel input buffer is about one page or 4KB, so your application has to get well behind with its reads before RTS actually changes.
So check that CTS is being asserted pulled to ground outside of your board. However I don't think this will give you the right control over RTS that you need.
Learn more. Asked 6 years, 2 months ago. Active 5 years, 8 months ago. Viewed 9k times. Any help would be greatly appreciated. Timothy Vann. Timothy Vann Timothy Vann 1, 13 13 silver badges 21 21 bronze badges. What is the actual RS adapter you're using? I'm using this adapter: ebay.