[UNO] SoftwareSerial ask for data write --> read

Good morning:

I'm trying to develop an interface between Arduino UNO and a Development Kit from a manufacturer. The kit communicates via UART, and when receiving some commands, it sends data back. The kit comes tin a "plugable" UART --> USB to manage it from the PC, where I've checked the module works and responds to several commands.

Now the issue: I've created a SoftwareSerial in order to communicate Arduino with the kit at the same time that I get those data to mi laptop via Serial. When I send the characters to the module, it does not sends me anything in return:


SoftwareSerial portOne(7, 6);
void setup() {

  • Serial.begin(9600);*
  • portOne.begin(9600);*
    }
    void loop() {
  • portOne.listen();*
  • portOne.print(".B"); // Config mode, this should return a prompt...*
  • while(portOne.available() > 0)*
  • Serial.println(portOne.read());*
  • delay(1000);*
    }


Is this the adecuate way of making the comm.?

Thanks a lot.
Regards.

SoftwareSerial cannot talk and listen at the same time. If the device you send a message to responds immediately you may miss the reply.

You may need to use an Arduino with an extra hardware serial port such as a Mega, Leonardo or Micro.

...R

Thanks for your reply!

I'll try to do the same with the Serial.read() and store the data in an SD card, just to verify the comunication with my kit works.
In this case, I should plug it in 0 , 1 pins, right?

Regards!

pablohr88:
In this case, I should plug it in 0 , 1 pins, right?

You need to explain more clearly what you are thinking of doing before I can answer that.

…R

I’ve tried to use the pins 0 and 1 from the board, as those are the ones used for the Serial port, right?
Now, when I open the serial monitor, I can see my sent bytes sent but not the returned ones…

I’ve detected, that the kit sometimes sends me the the string I want by using Serial.end(), I don’t understand why…

My code is this:

#include <Arduino.h>
#include <SD.h>
String input;
void setup() {

  • SD.begin(4);*
  • Serial.begin(9600);*
    }
    void loop() {
    Serial.write(.\0);
  • while(!Serial.available()); //Program stucks here until I write. The kit is not detecting anything.*
  • input = Serial.read();*
  • File myFile = SD.open(“kit.txt”, FILE_WRITE);*
  • Serial.println(input);*
  • myFile.println(String(input));*
  • myFile.close();*
  • delay(2000);*
    }

You really need an Arduino with 2 (or more) hardware serial ports (a Mega, Leonardo or Micro) to debug your project.

When you know how it works you may find a way to implement it on an Uno.

...R