I have a Photon that needs to be connected to two serial sensors. As the Photon only has one serial port (actually two but the other is used by the LED), I have used in the past the SoftSerial library which worked well.
However, I have a serial sensor that is giving wrong results with the SoftSerial library.
What could the reason be? (Sensor is using 115200 baud but can use a lower speed).
Is there an easy way to add more UARTs to the Photon?
Thanks in advance for any help.
ParticleSoftSerial is only good for speeds up to 28800 (maybe 38400/57600 for short messages).
Thank you @ScruffR. I will reduce to 38400.
Is there an easy way to increase number of UARTs on a Photon?
Depends what you deem easy.
You could use something like a I2C or SPI UART expander/bridge.
Thanks again @ScruffR.
Can you refer me to a link?
I rather thought of something along the line of this retired product
or a board based on the MAX3107/3109 (or similar) SPI/I2C to UART bridges
or a dedicated UART expander like this
On the other hand, what have you got connected to
And what is that sensor you want to run at that high rate on
I prefer the SC16IS740. The MAX3107 is virtually useless for async serial without flow control. While it has a 128-byte FIFO, you can’t read from the FIFO while serial data is being received! You have to use flow control or happen to know that no data is being received, or the data can be silently corrupted with a repeated byte.
The RHR is the bottom of the receive FIFO and is the register used for reading data out of the receive FIFO. It contains the oldest (first received) character in the receive FIFO. RHR is the first data bit of the serial-data word received by the receiver at the RX pin. Note that the data read out of RHR can be in error. This occurs when the UART receiver is receiving a character at the same time as a value is being read out of RHR and the FIFO level counter is being updated. In the event of this error condition, the result is that a character is read out twice from the RHR. To avoid this, the receiver should not be receiving data while the RHR is being read out. This can be achieved via flow control, or prior knowledge of the amount of data that is expected to be received.
Thank you @ScruffR.
I am running a distance measurement sensor with a high frequency.
The port expander is a different sort of thing, it splits a single serial port into multiple ports, allowing you to select which one you read and write to, one at a time.
As far as I know, no one has ported a driver for a SC16IS7x0 to Particle. I have the hardware and have been meaning to write one from scratch, optimized for Particle, but I haven’t done so yet. Thus it’s only theoretically possible to use one at this time.
In my case, while I do need 2 serial ports, I only need to use one at any given time.
In this case, will that port expander work? It uses the Altsoft serial library …
I am planning to evolve to the new Mesh devices, and thus replace the Electron for the Boron, however, since the Boron has only one UART, I would definetly need to implement the additional UARTs.
So I’d like to ask you, did you get to write the library for the expander? If not, what hardware would you recommend for this? I like TI’s TL16C752C since it has two UARTs
The UARTs are meant to interface with the Adafruit Thermal Printers and a Modbus RTU chip.
My SC16IS740 library works on the mesh devices. You can attach 4 to the I2C bus or as many as you want to SPI (limited by available GPIO for the CS lines).