JAVA, Raspberry Pi, PI4J, I2C, module MS5607 reading of C1 to C6 and D1 D2 always 0
pcote
Posts: 5
Hello,
I am really stuck. I have been trying to read C1 to C6 calibration parameters and D1 and D2 conversion parameters and I always get 0 values. All of them. A 30$ module is costing thousands of dollars of salary. I have been trying for two weeks now and tried all possible combinations.
// Parallax Device I2C MS5607 chip commands
public static final byte MS5607_CMD_RESET = 0x1E;
public static final byte MS5607_ADC_READ = 0x00;
public static final byte MS5607_CONVERT_D1_OSR_256 = 0x40;
public static final byte MS5607_CONVERT_D1_OSR_512 = 0x42;
public static final byte MS5607_CONVERT_D1_OSR_1024 = 0x44;
public static final byte MS5607_CONVERT_D1_OSR_2048 = 0x46;
public static final byte MS5607_CONVERT_D1_OSR_4096 = 0x48;
public static final byte MS5607_CONVERT_D2_OSR_256 = 0x50;
public static final byte MS5607_CONVERT_D2_OSR_512 = 0x52;
public static final byte MS5607_CONVERT_D2_OSR_1024 = 0x54;
public static final byte MS5607_CONVERT_D2_OSR_2048 = 0x56;
public static final byte MS5607_CONVERT_D2_OSR_4096 = 0x58;
// Signed
public static final byte MS5607_CMD_PROM_READ = (byte) 0xA0;
public static final byte MS5607_CMD_PROM_READ_C1 = (byte) 0xA2;
public static final byte MS5607_CMD_PROM_READ_C2 = (byte) 0xA4;
public static final byte MS5607_CMD_PROM_READ_C3 = (byte) 0xA6;
public static final byte MS5607_CMD_PROM_READ_C4 = (byte) 0xA8;
public static final byte MS5607_CMD_PROM_READ_C5 = (byte) 0xAA;
public static final byte MS5607_CMD_PROM_READ_C6 = (byte) 0xAC;
C1 to C6
byte[] c1, c2, c3, c4, c5, c6;
c1 = new byte[2];
c2 = new byte[2];
c3 = new byte[2];
c4 = new byte[2];
c5 = new byte[2];
c6 = new byte[2];
System.out.println("MS5607 calibration data reading");
try {
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C1, c1, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C2, c2, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C3, c3, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C4, c4, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C5, c5, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C6, c6, 0, 2);
} catch (IOException e) {
System.err.println(RED + systemDateFormat.format(new Date()) + " " + "--> <ERROR> Unable to read MS5607 calibration value(s)" + RESET);
System.err.println(RED + "--> <ERROR> " + e.getMessage() + RESET);
isMs5607CheckedOk = false;
}
D1 and D2
byte[] d1, d2;
d1 = new byte[3];
d2 = new byte[3];
long i = 0;
try {
ms5607Device.write(MS5607_CONVERT_D1_OSR_4096);
sleep(30);
ms5607Device.read(MS5607_ADC_READ, d1, 0, 3);
ms5607Device.write(MS5607_CONVERT_D2_OSR_4096);
sleep(30);
ms5607Device.read(MS5607_ADC_READ, d2, 0, 3);
} catch (IOException e) {
System.err.println(RED + systemDateFormat.format(new Date()) + " " + "--> <ERROR> Unable to initiate MS5607 pressure conversion" + RESET);
System.err.println(RED + "--> <ERROR> " + e.getMessage() + RESET);
}
Help deeply needed here
I am really stuck. I have been trying to read C1 to C6 calibration parameters and D1 and D2 conversion parameters and I always get 0 values. All of them. A 30$ module is costing thousands of dollars of salary. I have been trying for two weeks now and tried all possible combinations.
// Parallax Device I2C MS5607 chip commands
public static final byte MS5607_CMD_RESET = 0x1E;
public static final byte MS5607_ADC_READ = 0x00;
public static final byte MS5607_CONVERT_D1_OSR_256 = 0x40;
public static final byte MS5607_CONVERT_D1_OSR_512 = 0x42;
public static final byte MS5607_CONVERT_D1_OSR_1024 = 0x44;
public static final byte MS5607_CONVERT_D1_OSR_2048 = 0x46;
public static final byte MS5607_CONVERT_D1_OSR_4096 = 0x48;
public static final byte MS5607_CONVERT_D2_OSR_256 = 0x50;
public static final byte MS5607_CONVERT_D2_OSR_512 = 0x52;
public static final byte MS5607_CONVERT_D2_OSR_1024 = 0x54;
public static final byte MS5607_CONVERT_D2_OSR_2048 = 0x56;
public static final byte MS5607_CONVERT_D2_OSR_4096 = 0x58;
// Signed
public static final byte MS5607_CMD_PROM_READ = (byte) 0xA0;
public static final byte MS5607_CMD_PROM_READ_C1 = (byte) 0xA2;
public static final byte MS5607_CMD_PROM_READ_C2 = (byte) 0xA4;
public static final byte MS5607_CMD_PROM_READ_C3 = (byte) 0xA6;
public static final byte MS5607_CMD_PROM_READ_C4 = (byte) 0xA8;
public static final byte MS5607_CMD_PROM_READ_C5 = (byte) 0xAA;
public static final byte MS5607_CMD_PROM_READ_C6 = (byte) 0xAC;
C1 to C6
byte[] c1, c2, c3, c4, c5, c6;
c1 = new byte[2];
c2 = new byte[2];
c3 = new byte[2];
c4 = new byte[2];
c5 = new byte[2];
c6 = new byte[2];
System.out.println("MS5607 calibration data reading");
try {
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C1, c1, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C2, c2, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C3, c3, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C4, c4, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C5, c5, 0, 2);
ms5607Device.write(MS5607_CMD_PROM_READ);
ms5607Device.read(MS5607_CMD_PROM_READ_C6, c6, 0, 2);
} catch (IOException e) {
System.err.println(RED + systemDateFormat.format(new Date()) + " " + "--> <ERROR> Unable to read MS5607 calibration value(s)" + RESET);
System.err.println(RED + "--> <ERROR> " + e.getMessage() + RESET);
isMs5607CheckedOk = false;
}
D1 and D2
byte[] d1, d2;
d1 = new byte[3];
d2 = new byte[3];
long i = 0;
try {
ms5607Device.write(MS5607_CONVERT_D1_OSR_4096);
sleep(30);
ms5607Device.read(MS5607_ADC_READ, d1, 0, 3);
ms5607Device.write(MS5607_CONVERT_D2_OSR_4096);
sleep(30);
ms5607Device.read(MS5607_ADC_READ, d2, 0, 3);
} catch (IOException e) {
System.err.println(RED + systemDateFormat.format(new Date()) + " " + "--> <ERROR> Unable to initiate MS5607 pressure conversion" + RESET);
System.err.println(RED + "--> <ERROR> " + e.getMessage() + RESET);
}
Help deeply needed here
Comments
Mike
I will look at your code to see what I am doing wrong. But if you know anyone who's good with JAVA that would be a great help.
My code is used on Stratospheric Balloons and all the modules I use are interfaced in a bigger JAVA software. So my first choice would be to integrate this module in the already existing software.
TX
Patrice
Mike
******************************************************
MS5607 calibration data reading
C Values raw
C0 = 0 75
C1 = 19 0
C2 = 0 0
C3 = 0 0
C4 = 0 0
C5 = 0 0
C6 = 51 0
C Values combined
ms5607C0 = 75
ms5607C1 = 4864
ms5607C2 = 0
ms5607C3 = 0
ms5607C4 = 0
ms5607C5 = 0
ms5607C6 = 13056
D Values
D1 = 0 0 0
D2 = 0 0 0
i Value = 0
Pressure D1 = 0
Temperature D2 = 0
***************************************
ms5607 Temperature = 20.0
ms5607 Pressure = 0.0