I need to know if its possible to set up an ISR, using the RX from a SoftwareSerial port, using a parallel connection to a input pin, and detect on that pin when the data was received.
If that works ,I don't need to be listening to that SoftwareSerial port with for example LoRa1.listen(), everytime theres data on the virtual port I can detect it with the interrupt and then check the buffer for the incoming bytes.
The question might be, is the ISR fast enough to read the values on the emulated serial port before they enter the buffer...I know it sounds confusing ....let me try to explain myself....
Suppose at time 1 data is received on the RX pin of a SoftwareSerial input pin, as we aren't listening to that port, that data will be lost, so using the HW interrupt technique I can set up a ISR that says something like....{ LoRa1.listen() ------> now read the buffer---->OtherPort_continue_listening_as_you_were.listen() }
Yes, you are confused. Async data is 10 bits long. All 10 bits are received BEFORE the 8 bit byte is placed into the buffer that YOUR code can read. An interrupt will occur with a SINGLE bit, either a 0 or a 1 depending on how you program it.
Software serial uses a timer to cause an interrupt for each of the 10 bits so it can decide if the bit is a zero or a one.
IF you try what you suggest, you will get an interrupt on the first bit, and there will be no data actually in the buffer until 9 bits later.
I guess there is no stopping you from trying your plan. So, go for it!
That gives me an idea, what if I send the data twice? I mean, I can discard the first 10 bits and read the other byte?
Like send something just to trigger the ISR and then after the port is listening read the expected byte?
I'm not sure if I understand which problem you're trying to solve? SoftwareSerial will happily receive in the background and you can use the available() method to check if there is data received.
I'm emulating two SoftwareSerial ports. While I'm using one of them I need to check the other one to see if there's data in on intervals, for example, 5 minutes.
The process that uses one of the emulated ports takes like 1 minute and loops, after 5 minutes another node will send the value of a voltage.
Using two SoftwareSerial instances is a recipe for disaster most of the time, esp if you don’t control when the data can asynchronously come in as you can only listen to one port. If the two happens to send data at the same time, you are toast and will loose data.
If you require multiple UART use a board that provides enough hardware based ones
I agree with you. It's just that the board that I've right now is a Nano, and was wondering how far could I get, just trying to figure out some ingenious way to work out a solution.
I need to get just the value of a float, a numeric value for a voltage.
Maybe If i can get just the remaining bits....
Could it happen that you have two communications happening at the same time?
if you only need 2 UART, may be you could use Serial for one of those ? it makes uploading code more painful (need to remove the connection to pin 0 and 1) and you can't use Serial to debug, but at least you get 2 UARTs that can work together (within the limits of SoftwareSerial)
Wait , you gave me an idea....What if I ask with LoRa to the other device for the data, and wait until it answers with a response....maybe that could work. I don't like too much the fact that the program will be stuck waiting, but in this case maybe it can work.
A Nano Every also has four hardware serial ports, use MCUdude's MegaCoreX to have access to all four ports, the Arduino boards package only has two accessible.