Hi,
I have to send/receive data to/from a device through serial connection (using Serial1 of an Arduino Mega). The device listens the command once it goes to ground. I've tested that the device works properly using an USB-serial cable (prolific), see attached image. For testing the communication, I'm using the software terminal. Where I send the command $03$02$01$05$F8$03$03 on the part of Macros. I receive the right data.
However, when I want to do the same through Arduino, I don't receive anything. For that, I connect:
- GND (device) to GND (Arduino)
- TX (device) to RX1 (Arduino)
- RX (device) to TX1 (Arduino) - I use a resistor of 4.7K ohm to adapt the voltage
- PGM (device) to digital Pin 7 (Arduino)
The PGM should go to ground in order to listen the command. See cable connected to the device.
Hence, I configure the pin 7 as OUTPUT and I put it as LOW before sending the command. The command I send through arduino is:
const int A_TEST = 7; // TX from the Micro RF
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
digitalWrite(A_TEST, LOW);
delay (300);
uint8_t message[] = {0x03, 0x02, 0x01, 0x05, 0xF8, 0x03, 0x03};
Serial1.write(message, sizeof(message));
byte dat;
if(Serial1.available() > 0)
{
dat=Serial1.read();
Serial.print("Received data of size: ");Serial.print(sizeof(dat));Serial.print(" With value (HEX): ");Serial.println(dat, HEX);
}
}
I don't receive anything. My questions:
- Inserting the pin7 to LOW is like connecting it to ground? I check the current with the multimeter and it is almost 0.
- The same command in terminal is the same as the one I'm sending on Arduino? The dollar symbol has some meaning with Arduino?
I'm stuck with this for several days now. Please give some hint on how to solve this.
Thanks
