Can't get meaningful data from S9DOF Razor IMU using Arduino Mega 2560 R3 plus

I am using Arduino Mega 2560 to get data from a razor IMU sensor. I tried to implement the following code (, but not getting any meaningful data as he is getting. I am a beginner but I think this should work. I checked my sensor and it is working fine but I don’t know what is going wrong. I did make a change in the code; I deleted the ‘Byte’ from the serial.println command line as ‘Byte’ is no longer accepted in this new version. Could that be a reason? If not can anybody tell me what is missing here?

The code is as follows:
Read 9DOF Razor IMU data via Seeeduino Mega board (Arduino Mega clone).

  1. Connect the jumper wires between the two boards
    according to the following table:
9DOF Razor IMU Seeeduino Mega
TX0… RX1…(pin 18)…
RX1… TX1…(pin 19)…
3.3V… 3V3…
--------------- --------------------
  1. Connect the USB Cable between the PC and the Seeeduino Mega board.
  2. Select the “Board” item from the “Tools” top menu and check the radio
    button Arduino Mega (ATmega1280).
  3. Upload this Sketch to the Seeeduino Mega board
  4. Open Serial Monitor and set the Baud rate to 57600.
  5. Send the character ‘0’ to view the 9DOF Razor IMU Menu.

9DOF IMU Test Firmware v15

[1]Accelerometer: ADXL345
[2]Magnetometer: HMC5843
[3]Gyroscope: LPR530 and LY530
[5]Self Test


void setup() {
Serial1.begin(38400); // Baud rate fixed…
Serial1.print(4); // Begin with Raw data

void loop() {
if(Serial.available() > 0) {
int incomingByte =;
0 - 48
1 - 49
2 - 50
3 - 51
4 - 52
5 - 53
if(incomingByte >= 48 && incomingByte <= 53)

if(Serial1.available() > 0)

I also tried another simple code ( from here and that also did not work.

Any help will be much appreciated.