element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum serial communication between arduino
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 10 replies
  • Subscribers 393 subscribers
  • Views 1338 views
  • Users 0 members are here
Related

serial communication between arduino

menuth
menuth over 6 years ago

i have two arduinos connected serially meaga and uno i have a numbers 0 to 255 in the uno i should be able to read the numbers 0 to 255 from the uno to the mega and print it on the serial monitor. but i am not getting it correct. Can anyone please help me out.

thanks in advance

  • Sign in to reply
  • Cancel

Top Replies

  • fmilburn
    fmilburn over 6 years ago in reply to menuth +4
    There still is not enough information to give a definitive reply and your problem could be the way it is wired, the code, or both. The posted code is incomplete and confusing - so post complete code for…
  • genebren
    genebren over 6 years ago +2
    Greetings, Communicating between arduinos is a well established process. There should be plenty of examples out there of how to do this. In asking a question like this, the more information that you provide…
  • menuth
    menuth over 6 years ago in reply to genebren +2
    i have two arduino boards hooked up serially (uno is the sender and mega is the receiver) the mega is connected to pc i need to print the data received from the sender on the serial monitor, can anyone…
Parents
  • genebren
    genebren over 6 years ago

    Greetings,

     

    Communicating between arduinos is a well established process.  There should be plenty of examples out there of how to do this.

     

    In asking a question like this, the more information that you provide, describing the approach you are taking and the results that you are getting, the more likely it is that people are going to be able to help you.  Providing you code, and examples of the data you are getting will help people better understand the problem.  Also it helps if you can explain your skills and level of understanding of coding/computing to people can frame their response better.

     

    Best of luck with your project!

    Gene

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • menuth
    menuth over 6 years ago in reply to genebren

    i have two arduino boards hooked up serially (uno is the sender and mega is the receiver) the mega is connected to pc i need to print the data received from the sender on the serial monitor, can anyone please help me out? this the function which i'm using for it.

     

    void transmit()

    {

     

      char data[300];

      Wire.beginTransmission(0x08);

      Wire.write(0x0D);

      Wire.endTransmission();

     

     

      Wire.requestFrom(0x08, 1);  //requesting slave to send data

      x = Wire.read();

      if (x == 0x1D)

      {

        Serial.print("slave response is: ");

        Serial.println(x, HEX);

        Serial1.begin(115200);

        {

        Serial1.readBytes(data, 255);

        Serial.print(data);

       }

      }} 

     

    the result which i get is some garbage values.

    please help me out

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • genebren
    genebren over 6 years ago in reply to menuth

    Ok, thanks for the additional information.  First off, I am not an ardunio expert (in fact I have never used one myself), but I have a lot of knowledge in writing communication software.

     

    First, the the good news is that you see some data.  That usually implies that things are connected correctly.  From here I would suspect things like baudrate and signaling voltages, etc.  Are the PC and arduino talking on the same baudrate? (I notice that there are two serial streams being used here, Serial and Serial1, which is talking to the PC?)  Is the ardunio communication in true RS232 levels?

     

    These would be my first guesses as to why you are getting garbage data back.

     

    Good luck!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • menuth
    menuth over 6 years ago in reply to genebren

    serial is talking to pc and serial1 is the link between 2 arduinos. the baud rates are same. i think some logical error in programming.

    thank you

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • genebren
    genebren over 6 years ago in reply to menuth

    That is a pretty big jump to believe that it is about programming, as there is very little programming shown (you could simplify the programming by just outputting a simple string, over and over from the arduino to the PC).  Garbage data is a good indication that the two ends of the serial link are not talking the same language (i.e. baudrate, start/stop bits, or signaling voltage).  If you have access to an oscilloscope you could verify baudrate and voltage levels fairly easily.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • balearicdynamics
    balearicdynamics over 6 years ago in reply to menuth

    Hello Rabada,

     

    based on the code it seems you are using the SPI serial connection, or I am wrong? If so, you can follow a more reliable and better approach, IMHO.

     

    Enrico

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • fmilburn
    fmilburn over 6 years ago in reply to menuth

    There still is not enough information to give a definitive reply and your problem could be the way it is wired, the code, or both.  The posted code is incomplete and confusing - so post complete code for both the sender and the receiver.  Also indicate which pins are connected between the two Arduinos.  Are you trying to use I2C (Wire Library) or Serial (Serial1) to communicate between the Arduinos?  It appears the two are being mixed.  I suggest trying working code from the many available examples first.

     

    For example if trying to use I2C to communicate between the two then Arduino has this example:  https://www.arduino.cc/en/Tutorial/MasterReader .  Be sure to connect to the correct pins on the Mega for SDA and SCL.

     

    If trying to use Serial communication between two Arduinos then doing an internet search turns up this:  http://robotic-controls.com/learn/arduino/arduino-arduino-serial-communication .  Note that RX and TX are "crossed" when using Serial - i.e. RX connects to TX and TX connects to RX.  Serial1 works on the Mega but not the Uno.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Cancel
  • menuth
    menuth over 6 years ago in reply to balearicdynamics

    i'm using both i2c and serial communication.the serial communication is to transmit data between the arduinos wit a baudrate 115200.

    thank you

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • menuth
    menuth over 6 years ago in reply to balearicdynamics

    i'm using both i2c and serial communication.the serial communication is to transmit data between the arduinos wit a baudrate 115200.

    thank you

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube