Dear forum,
I ask you because I have a lot of problem with the serial trasmission on a Arduino board UNO.
I created a very simple sketch
void setup() {
// put your setup code here, to run once:
Serial.begin(9600, SERIAL_8N1);
valore=0;
}
void loop() {
// put your main code here, to run repeatedly:
String tmp = "!R1#" + String(valore) + "\r";
Serial.print(tmp);
if (Serial.available() > 0)
{
digitalWrite(led2,LOW);
received = Serial.readString();
Serial.print(received);
}
delay (1000);
valore++;
}
If I tried to execute this sketch using Arduino connects with my laptop there isn't problems. On the serial monitor I see all my strings.
When I disconnect the usb cable, I connect the battery (9V). I connect the serial cable to Rx/Tx pin (0 and 1) and the GND. When I try to mesaure volts on the Tx I don't see anything, and the led Tx doens't blink.
LLombardi:
I connect the serial cable to Rx/Tx pin (0 and 1) and the GND.
You have not told us what you connect them to. Post a diagram showing all the connections.
Also, you really need an oscilloscope to see the serial data signals.
And a small PP3 style 9v battery is not really suitable as it cannot provide much current. It may work an Arduino for a short time when the battery is very new.
When I try to mesaure volts on the Tx I don't see anything,
That is a silly statement. The voltmeter doesn't just disappear on you, nor does the screen play hide and seek. So, if you are looking in the right direction, you see something.
and the led Tx doens't blink.
The TX LED is controlled by the USB to Serial converter that you bypassed. Of course it isn't going to blink.
I connect the serial cable to Rx/Tx pin (0 and 1) and the GND
You connect one end to those pins. You wave the other one around in the air?
The battery is new. I get out it from the packge today, and I'm sure that is full
I use a oscilloscope, but I see a fixed line on 5V and sometime fall to 0, as the oscilloscope read something
I connect my tx-rx and gnd pins with a cable, that on the other side is welded to a serial port. On this serial plug I have my tx is connectd to the pin n°2, my rx is connectd to the pin n°3 and the arduino gnd is connectd to the pin n°5. I also short-circuits the pins 4-6 and pins 7-8 on the serial port
This serial port is connected with a serial usb-adapter, because the final device has only usb port, but open only a serial communication.
I connect my tx-rx and gnd pins with a cable, that on the other side is welded to a serial port.
A true serial port? With RS232 level logic, rather than TTL level logic that you get with a USB to serial cable, and that the Arduino sends and receives?
I connect my tx-rx and gnd pins with a cable, that on the other side is welded to a serial port.
[/quote]
You need to check if the serial port you want to connect to uses TTL or RS232 voltage levels. RS232 voltage levels can damage an Arduino and you need something like a MAX232 to convert between the Arduino's TTL voltages and the RS232 voltages.
ok, in the case of the usb adapter it has the usb voltage of 5 V but it is not compatible with TTL serial of the microcontroller. https://www.sparkfun.com/tutorials/215