0

I want to send the voltage magnitude received on an analog pin of atmega328Pu to another arduino uno using Serial communication pins TX and RX and display the value on the receiver arduino's Serial monitor.

Transmitter Arduino Code:

void setup()
{

  Serial.begin(9600);

  pinMode(A0, INPUT);

}

void loop()

{

  int voltage=analogRead(A0);

  Serial.println(voltage); 


}

Receiver Arduino Code:

void setup()

{

  Serial.begin(9600);

}
int incomingByte = 0;

void loop()
{
if (Serial.available() > 0) {    
    incomingByte = Serial.read();   
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
}

}

Problem: Now the Problem I am facing is that Serial Monitor of Receiver arduino does not shows anything, it remains blank. Please analyse this system help me in finding out the best way to get around this problem? enter image description here

  • You need to connect GND (0V) between the to. Electricity flows in circles. – Dougie Oct 15 at 17:28
2
  1. Connect the grounds of the two Arduinos together. Their serial transmitters and receivers need the same voltage reference.

  2. pinMode(A0, INPUT); is not needed. pinMode() only affects the digital part of the pin driver. (But it probably isn't doing any harm, either).

  3. The transmitter Arduino will be sending 1, 2, 3, or 4 ASCII bytes - the digits 0-9, representing the D/A result, 0 - 1023. In decimal, those digits will look like 48, 49, ..., 57 (for a '0', '1', ... '9', respectively). So the receiving Arduino will be handling characters, not numbers. It needs to collect all of the characters, then repeat them onto it's terminal output.

  • Thanks for the Help. It works Now – gautam sagar Oct 16 at 4:41
3

The problem is that a serial connection usually connects two devices, in your case it's three (sensor arduino, receiving arduino and your pc).

To get around this you have to use an additional software serial on different pins on the receiving arduino (unfortunately the atmega328 has only one hardware serial interface). As long as you don't have to send anything from pc to the receiving arduino and from the receiving arduino to the sensing one you could try to simply disconnect the wire receiving-TX to sensing-RX and see if it works. In this latter case you could actually get rid of the receiving arduino at all.

Edit: another important point was mentioned in JRobert's answer: grounds of devices communicating with each other must always be connected!

  • Thank you very much for the help. – gautam sagar Oct 16 at 4:42
  • If your problem is solved please accept an answer so the question is closed – Sim Son Oct 16 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.