Double ATmega328p-pu Data transfer and "sorted data"

Hi,

I came here with an interesting question but 1st i wanna explain what i actually try to do to be easier to understand my question (as the name of the topic).

I wanna use 2x ATmega328p-pu, one to connect some sensors and get constant data and gonna be as the main "basic" chip and the 2nd to receive the data from the 1st Atmega and control other components like leds, servos, dc motors..etc (dose not really mater what I'm gonna control).

And here is my Question : Is there a possible way to transmit the data from the 1st Atmega to the 2nd Atmega to sort them as separated data (like A: , B:, C: data, like in serial monitor from each sensor) and work with that data to control leds, servos..etc ?

ps (To transmit data from one chip to other just with the pins from the chip not extra "modules").

Just use serial communication and the same techniques you would use to send data to and receive data from the Serial Monitor.

If it is possible to do everything with a single -328 it will make life much simpler.

...R

Just use? where is the guild to just follow and use what you say? :smiley:

It’s not possible to use with a single 328, 10+ sensors.

It's not possible to use with a single 328, 10+ sensors.

You can put 100's of sensors on a single Uno and have as many outputs!

Mark

And here is my Question : Is there a possible way to transmit the data from the 1st Atmega to the 2nd Atmega to sort them as separated data (like A: , B:, C: data, like in serial monitor from each sensor) and work with that data to control leds, servos..etc ?

Yes, you just need to define the protocol that will be followed by each. Perhaps each message will have 8 bytes: first character is AA as a sync message next character is the senders ID, from 0 to 255 -- two or three bits might indicate the kind of sensor in use, with the remaining 6 or 5 being the senders ID the next 6 are the data being sent. Sender fills with 0's if less than 6 bytes are needed.

There are all kinds of possibilities.

Yes, you just need to define the protocol that will be followed by each.
Perhaps each message will have 8 bytes:
first character is AA as a sync message
next character is the senders ID, from 0 to 255
– two or three bits might indicate the kind of sensor in use, with the remaining 6 or 5 being the senders ID
the next 6 are the data being sent. Sender fills with 0’s if less than 6 bytes are needed.

That sounds like the most logical way to manage the I/O.

Sounds nice all that but can someone saw me how to do that, how to connect the pin's between the ATmega's, what kind of code (example) i need to receive the same data as in the 1st atmega.

I'm gonna give you a logical/text example about what I need. 1st Atmega with the sensors and i put nicely to print my data in the serial monitor.

A: 100 B: 150 C: 900 //Repeat (loop)

Now i need to take just the data from the "A" -> 100 transmit it to the other Atmega make an integer or real (variable) for example "Ai" and "println("AI",Ai); to print the data. 2nd Atmega.

Ai: 100 Bi: 150 Ci: 900

Now I understand everything what you told me but i never done something like that before and i just keep learning, my problem here is that i don't know how to connect the atmegas in the right way to transmit the data and not damage them and about the code I don't know what kind of code to use.

I will be glad to just give me an example how to connect them in the right way and an mini example of code after that i can learn from that mini example and make something bigger.

Thanks

Domino60: Sounds nice all that but can someone saw me how to do that, how to connect the pin's between the ATmega's, what kind of code (example) i need to receive the same data as in the 1st atmega.

Just connect Rx to Tx. Tx to Rx and GND to GND.

Then use the code in serial input basics and the usual Serial.println() to send the data.

That's what I meant in Reply #1

But maybe you have something else in mind that I have overlooked?

...R

Would you lkke fries with that order ?

Just connect Rx to Tx. Tx to Rx and GND to GND.

Would you lkke fries with that order ?

You mean about the pin connection?

Well I'm afraid a bit to connect the atmega's between them I don't wanna risk to burn several components my bugget and time is small and risk to burn the components will be a big failure and mistake from my side.

Thinking about having only a unit (basic box sensors) just for the sensors and working in the same time with another Topic that i started about the " nRF24" I'm thinking to transmit the data thru a nRF24 but with that setup i lose a lot of pins "nRF24" need 6 pins to transmit data and all of them are digital.

In my case or * I risk to make a wire setup between 2x ATmegas328 or * Transmit data thru "nRF24" and lose a lot of digital pins or * "Thinking" to use the nRF24 and buy a bigger ATmega chip (with more pins)

or I don't know.

I don't wanna risk to burn several components my bugget and time is small and risk to burn the components will be a big failure and mistake from my side

There is no risk of doing something when you wire two Atmegas together that you could not do with one on its own. There are two principal things to watch out for

stay within the permitted voltage limits of 0 to 5v do not allow more than 40mA (absolute max) to be taken from or fed into any I/O pin.

After that, "you can't make an omelette without breaking eggs".

You mean about the pin connection?

I meant the Rx and Tx pins. I don't know which of us @raschemmel was referring to.

...R

Would you lkke fries with that order ?

was in reference to this request:

but can someone saw me how to do that, how to connect the pin's between the ATmega's, what kind of code (example) i need to receive the same data as in the 1st atmega.

If I were to reword it I would change it to:

"What is the best method to AND two SERIAL data signals from two arduinos ? (Your statement that you want the SAME data implies the AND function)

what kind of code (example) i need to receive the same data as in the 1st atmega.

This implies you have NO code , are starting from scratch and are asking us to design the circuit and write the code. Am I right so far ?

Well I'm not asking to design anything. I know that you need to connect the RX, TX pins to receive data from one to another ATmega but give me a basic example about how to connect the in the right order and a simple example code (Hello world) or something like that.

Something totally basic (example), not asking something huge. After that I'll know what I'm doing and keep going with my projects.

Sure, no problem" ARDUINO TO ARDUINO SERIAL COMMUNICATION

ARDUINO TO ARDUINO SERIAL

ARDUINO SERIAL

SOFTWARE SERIAL