5

I wonder if it is possible to send a value from one arduino to another.

Basically, I have one arduino measuring let's say weight, but I want to display that value using an lcd in another arduino. Is it possible to send the value to a pin using analogwrite or digital write in the arduino doing the measurement and use analogread/digitalread at the other arduino making the display?

I do not know if this is possible but what is attractive is that one can have several arduino making weight measurements, all showing up in the display of just one central one...

4

You could have the LCD Arduino be an I2C master and all the weighing Arduinos be slaves. There's an example of master/slave communication and wiring here: https://www.arduino.cc/en/Tutorial/MasterReader.

I2C supports up to 128 devices and the wiring is very simple.

  • Exactly what I too was looking for thanks! – BrandonS Feb 23 '17 at 18:34
2

Yes it is possible,The answer provides one of the basic methods to do so

Connections

   Arduino1          Arduino2
     TX--------------->RX
     RX--------------->TX   

Arduino1 Sketch:

void setup(){
 Serial.begin(9600);
 delay(2000);
}

void loop() {
 ////read sensor data to a variable 
 Serial.println(sensorDataVariable);
 delay(2000); //Not to flood serial port
}

Arduino2 Sketch :

int byteRead;
void setup(){
 Serial.begin(9600);
 delay(2000);
}

void loop() {
  /* check if data has been sent from the computer: */
  while (Serial.available()) {
    /* read the most recent byte */
    byteRead = Serial.read(); //now byteRead will have latest sensor 
                              // data sent from Arduino1
  }
  //Write code to display the values to LCD
}

hope this helps

  • Will this option be limited to only two arduinos? I would like several arduinos transmitting weigh values to a central arduino. – Camilo Sep 21 '15 at 8:16
  • you can but use Arduino 2 sketch on all other receivers,,broad cast form one arduino and receive from many,,,you should do more research – Lokanath Sep 21 '15 at 8:36
  • How can we achieve this if we would like to do vice versa ? Arduino 2 is sending data to Arduino 1. – Sabhay Sardana Feb 16 at 8:38
1

To tie multiple Arduinos together you need to come up with some kind of networking topology and some form of networking protocol.

Requirements are:

  1. The Arduinos must not (electrically) interfere with each other
  2. There must be some way to know which Arduino is sending what and where to

The two points could be addressed by having a separate connection for each Arduino but that ends up complicated, and there are only limited resources on an Arduino for creating such connections (you really need to use the hardware UART ports and the Uno has only 1. The Mega has 4).

A better solution is to use a bus system (also known as a multi-drop network). There are a number of existing and well supported methods for doing this. In the automotive system the CAN Bus is used. In industry the RS-485 system is heavily used.

Personally I prefer RS-485 since it is well established. There are a number of standard protocols that run on RS-485, such as MODBUS, but for the Arduino world I wrote my own light weight protocol specially which is far simpler to get going with. You can find out more here: https://github.com/MajenkoLibraries/ICSC

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.