Serial comms, Micro > Micro Pro

Hi there.

I'm getting a bit confused with what I'm reading in other posts about comms between these little things.

I have a Micro Pro which I need to send data to a Micro. I have a common ground and Micro RX connected to Mp TX0, baud is correct everywhere but I have no data getting to the Micro.

I'm using code from the arduino help files on both. On the Pro I'm opening the port and sending data. On the Micro I'm opening the port, checking available, reading data.

Where I'm confused is what ports to use, there are posts saying I should use Serial, Serial1, or use software posts. I have to use RX on the Micro as there are no other pins available.

So, serial data from a Micro Pro, to a Micro. Which pins should I use and what serial ports? Are there any other considerations?

I'm not posting diagrams or code with this post as I'm asking for best practices for this specific scenario, not a critique of my drawing skills!

Many thanks.

@munty-scruntfundle, your topic has been moved to a more suitable location.

On the 32U4 based boards like the Micro and the Pro Micro, the UART (TX and RX) is Serial1 and the USB is Serial.

You forgot to post the code, using code tags, the symbol </>. How do You think we will find the fault? Helpers seldomly have access to crystal balls.

Well, I'm not posting any help, as I don't want to make assumptions you have done everything correctly.

2 Likes

:+1:

Did anyone read the bit where I asked for BEST PRACTICES?????

There is no frigging code, there is no frigging diagram.

This forum is without doubt the most unfriendly and unhelpful I've ever come across in my life. And if you ask I'll be happy to tell you where to stick your frigging thumb! Idiot.

How do you expect the young people of this world who don't find this kind of thing natural to get on with help like this?

How about... if you don't want to help, don't post? Instead of feeding your egos and narcissism with posts that only serve to put people off.

Does anyone want to answer a question about BEST PRACTICES, ports, pins, serial or serial1, etc?

Arduino to Arduino via Serial has code examples to send between Arduinos

Here is a simple Serial1 Echo test to run on each board
Open two copies of the IDE and connect one board to each and program this sketch and check you can type in one monitor and see the data in the other.

// Serial1 to Serial1 echo test
// #define SOFTWARE_SERIAL if using SoftwareSerial

// if using SoftwareSerial on Uno/Mega
#ifdef SOFTWARE_SERIAL
#include <SoftwareSerial.h>
#define SERIAL_RX 10
#define SERIAL_TX 9
SoftwareSerial softSerial(SERIAL_RX, SERIAL_TX);
#define comSerial softSerial

#else
// else for hardware Serial1
#define comSerial Serial1
#endif

void setup() {
  Serial.begin(115200);  // fast for debug
  for (int i = 10; i > 0; i--) {
    Serial.print(i); Serial.print(' ');
    delay(500);
  }
  Serial.println();
  comSerial.begin(4800);

}

void loop() {
  if (Serial.available()) {
    comSerial.write(Serial.read());
  }
  if (comSerial.available()) {
    Serial.write(comSerial.read());
  }
}

In all case, SoftwareSerial will be the worst choice and should only be used if you have no other option.
For the rest, there must be an understanding how stuff works and which functionalities are available in a microcontroller and how you can make use of them in a project.

Further I told you that you have to use Serial1.

On a 32U4 based board, there is one UART and it is connected to the RX and TX pins on the board; it's not used for communication with the PC.
On a 328P based board, there is one UART (connected to the RX and TX pins on the board) and it is also used for communication with the PC through the TTL-to-USB chip.

Make sure that frame format (e.g. 8N1, 7E2 etc) match at both ends.
Don't assume any flow control, unless you provide it.
Beware of auto reset.

Thanks to you helpful people, your info has set me off in the right direction and I have a working prototype running in front of me right now.

Now, on a slight different tac, is there any reason I can't connect more than one slave to the receiving Micro on the same rx pin? I know FOR SURE the two slaves couldn't send data at the same time, there's no two comms and if there's no handshaking I can't see why they'd get fedup with each other, unless slave 1 will get upset receiving data on it's tx pin. Has anyone tried this? I have another Micro Pro here which I can test with, but I'd sooner not break it.

Maybe I should apologise for my previous post. It just infuriates me when people post replies just to be antagonistic. Looking around in other forums it's clear this one has a less than desirable reputation for actually helping people. I ran departments at a highly technical IT company for over 10 years in charge of many things including the customer support, if anyone behaved the way people have in this thread on our forums they'd have been out the door in five minutes. And here endeth the rant!

So to those who have helped, many many thanks.

So you try to connect the TX of two or more ProMicros to the RX of the Micro? If that is the case, those ProMicros will fight. If there is no communication, the output is HIGH. If one starts sending data, it will make toggle the TX line between HIGH and LOW. The LOW will fight with the HIGH of the other one and it will more than likely eventually damage the micocontrollers.

What you can do is put a resistor between RX TX of each ProMicro and the TX RX of the Micro. Not sure of the value, 1K will probably do.

Note:
If both ProMicros will send at the same time, the above will not prevent data corruption. But it's my understanding that you can guarantee that.

Other approaches to connecting multiple Tx pins to a single Rx pin could be:

  1. Use a small diode like 1n4148 to connect each Tx pin to the Rx pin, and a pull-up resistor to the Rx pin. The cathodes of the diodes would be connected together. This may limit the fastest baud rate you can use, compared to connecting one TX to one Rx.
  2. Use 74hcXX chips to make an OR-gate between the Rx pins and the Tx pin. The most obvious choice would probably be 74hc32, but with ingenuity many others would work just as well, such as 74hc00, 74hc02, 74hc10...

As for the friendliness of the forum, remember this is a community forum, no-one is paid to work here, so unlike call centre employees, forum members here are not required to suffer fools gladly. I'm not saying you are a fool. I'm saying hang around here for a while and see how many fools turn up on a daily basis, I'm sure it will remind you of your time in customer support roles. If the forum's reputation keeps some of those fools away, great. I suspect it won't, though, because they are fools. For me, the forum's reputation is based on the quality of help and advice given to those that are more deserving of it.

indeed - and it often starts by reading and posting according to the advices that are outlined here: How to get the best out of this forum

In this case the question is #1 was not very precise in terms of which pins or which code OP was really using and

Does anyone want to answer a question about BEST PRACTICES, ports, pins, serial or serial1, etc?

is just too generic of a request...

Answer #1 was spot on and the attitude towards members then got the ball rolling quickly into sarcasm territory.

Here you told us you did have wiring, and were using code. I appologise for asking you to supply the code and wiring you told us you were using. I was confused by the words you used, and the order you put them in!