How to connect Load Cell to Arduino UNO (or MEGA??)

Hi,
I'm trying to interface a DL-100 load cell with an arduino UNO. I'm very new to coding and am unfamiliar with Serial and Serial 2 in the example code they provided on the website.
Here is the tutorial and the example code they gave.

It won't compile and I think it's because I have an UNO and not a MEGA. If anyone can help me and tell me how to get this to work on an UNO that would be much appreciated.
If this is not possible without a MEGA, I have the funds to purchase one so let me know if that's my best option.
Thanks so much!

/*

This program continuously reads weights from a Loadstar Sensors'
DI-100 digital load cell interface connected to a load cell.
The DI-100 is powered by the Arduino and the Tx/Rx pins are connected to
TX2 and RX2 of the Arduino Mega 2560 board.

 */

int isPolling=0; //are we continuosly reading weights?
void setup()
{

// start serial port at 9600 bps for communicating with the Arduino via Serial/USB to PC:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
  Serial.print("Connected to PC\n");

// start serial port 2 at 9600 bps for communicating with iLoad Series Serial Sensor or DI-100 Serial Interface:
  Serial2.begin(9600);
  while (!Serial2) {
    ; // wait for serial port to connect.
  }
  Serial.print("Connected to Sensor\n");
  Serial2.write("TARE\r"); //zero the sensor
  delay(5000);//wait for 5 seconds before polling
  isPolling=1; //start polling
  Serial2.write("W\r"); //send one command to read the weight, after the weight is
        //read in the event loop, another command to read the weight is sent
}

void loop()
{

}

void serialEvent2() {
  char c=char(Serial2.read());
  Serial.print(c);
  if (isPolling==1 && c=='\n') {
    //we just finished reading a weight
    //read the weight again.
    Serial2.write("W\r");
  }
}

As it's using a baudrate of 9600 baud you may try to use SoftwareSerial for the connection to the load cell. If the load cell isn't overly picky about the timing this should work.

If this is for a commercial project use the Mega or some other device that has a crystal clock driving the UART baud clock. The UNO has that but it is used for the serial monitor and is not available for general use without jumping a lot of hurdles.

There is a fuse bit that can be changed to bring the 16 MHz system clock out on PB0 (check the datasheet, might be a different pin).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.