I would like to send strings to a weetech 25-pin serial port, simulating a barcode reading gun. i tried to use softwareSerial but it didn't work. how can I do? do i use rs232? I use a USB and then suitable?
If this is a classic RS232 serial port, you need a TTL to RS232 voltage level converter, like this one.
Of course, you also have to use the correct wiring, and send the correct data.
Are you simulating it using an Arduino(I hope so), or using a PC and terminal software, for example?
In order to simulate a thing, you first need to find out exactly what that thing does.
So you will need to find out what, exactly, this gun sends - including whether it uses RS232.
You will also have to find out if it depends on anything coming from the PC.
You could start by using a serial terminal to monitor what the the gun sends, and if anything is sent to it - be sure to use something that will show you all control codes, any binary data, etc ...
I bought this rs232 shield, it arrives tomorrow,
today I tried sending data directly from arduino to db25 or using a TTL usb shield from arduino and an adapter from usb db9 and then a cable that connects to db25.
I used the following sketch:
/*
https://tecnicamente.wordpress.com/2012/04/07/arduino-max232-e-comunicazione-seriale-parte-1/
*/
#include <SoftwareSerial.h>
SoftwareSerial SSerial(11, 12); //12 RX e 11 TX
void setup() {
Serial.begin(9600);
while(!Serial) {}
Serial.println("ok");
SSerial.begin(9600);
}
void loop() {
if (SSerial.available()){
Serial.write(SSerial.read());
}
if (Serial.available()){
SSerial.write(Serial.read());
}
}
Today without rs232 shield it was not sending anything, maybe I am making a mistake in writing the sketch.
Looking at the library manual now, I have not declared the pinMode output input, can this affect it?
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
This is the information of the device on which I have to connect with arduino to send strings to simulate the barcode reader.
So it tells you that it has three serial ports all on a single DB25 connector - therefore that is not a standard RS232 connector!
So the first thing you're going to have to do is to make up a custom cable to correctly connect your Arduino to the appropriate serial port within that connector.
It does say that it's "RS232-compatible" - so that means your will need an RS232 transceiver between your Arduino and the system.
If you're not familiar with these terms, then study this tutorial:
https://learn.sparkfun.com/tutorials/serial-communication/all
Your image also shows that RTS and CTS are present - so you'll need to find out if they are optional, or need some configuration, etc ...
The text refers to "Serial IN/OUT", but that does not appear in the table - which has only "Special input".
Is that a typo - who knows?!
It also doesn't describe how this "Serial IN/OUT (bidirectional)" is intended to work - so you have more digging to do on that.
And it tells you nothing at all about what it is expecting to receive on those ports - baud rates, parity, data format, etc, etc ...
Again, do you have a working barcode reader to analyse?
I have a barcode reader with db9 output, I tried to read the output of the reader by connecting on pin 2 and 3. It works, I was able to get output, it corresponds to a println()
Thank you for your valuable help and the links. The datasheet is not very detailed, which is why I am going by trial and error.
Knowing that from the gun came out output from pin 2 and 3 using an adapter from 25db to 9 db I sent on those pins the sting without using the rs232 shield. But I got no reaction from the device.
I also tried connecting the 25db directly to pin 2 and 3, but again no reaction from the device.
You mean DE9?
Anyhow, have you successfully got that reader to work with this "weetech" serial port?
I meant de9, sorry for the mistake.
yes, I managed to make that reader work with weetech, but my intention is to be able to simulate it with Arduino and send the strings myself
Right: so that's the first step! Now you have something to simulate.
SO you need to spend some time to understand what that reader is actually sending - and anything that the Weetech sends back - and make sure that your Arduino faithfully matches that.
Start by monitoring the communications between the reader and the Weetech - you can do this using a terminal emulator (or two):
https://www.avrfreaks.net/s/topic/a5C3l000000UYWbEAO/t146507?comment=P-1422786
Also pay attention to the wiring.
Thanks for the advice, I will start to try and read the outputs with the programmes mentioned in the link you sent me.
As soon as I have news I will share it here!
Thanks!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
