schm1tz1 / arduino-ms5xxx Goto Github PK
View Code? Open in Web Editor NEWArduino Library with examples for using digital pressure sensors MS5607 (and MS56xx, MS57xx, MS58xx) based on AN520 by manufacturer.
License: GNU General Public License v3.0
Arduino Library with examples for using digital pressure sensors MS5607 (and MS56xx, MS57xx, MS58xx) based on AN520 by manufacturer.
License: GNU General Public License v3.0
When testing the MS5607 with the MS5xxx library it compiles fine with an Arduino uno but when I compile it with a Seeduino Zero I
get errors:
error: expected primary-expression before 'unsigned' unsigned long D1=0;
error: expected primary-expression before 'unsigned' unsigned long D2=0;
error: lvalue required as left operand of assignment D2=read_adc(MS5xxx_CMD_ADC_D2+MS5xxx_CMD_ADC_4096);
error: lvalue required as left operand of assignment D1=read_adc(MS5xxx_CMD_ADC_D1+MS5xxx_CMD_ADC_4096);
Hello Roman,
I have a problem with Arduino-MS5xxx library (Using MS5607 Parallax) with Arduino 101, Arduino IDE 1.6.13 and 1.8.1.
I tested with Arduino 2009, Mega and Mega R3 and everything works very well.
I am a beginner and I can not find a solution.
I tried the example "29124-Altimeter-Module-KickStart" on https://www.parallax.com/product/29124 and it works but I need the very low pressure and temperature for a weather balloon.
I apologize for my English, and for how to report a problem that maybe is not the correct way.
Best regards
Flavio
In the file "shab/flight_software/MS5xxx.cpp", the Wire.requestFrom() is followed by some Wire.read() and then a Wire.endTransmission(). That Wire.endTransmission() may be removed.
Explanation: Common-mistakes#2
I used a program based off the example sketch to print the calibration data and current temperature from my MS5607 barometer. On the nRF52832 Feather from Adafruit, it produces the following:
Starting on MS5xxx
C0: 20
C1: 4294967039
C2: 4294967039
C3: 4294967039
C4: 4294967039
C5: 4294967039
C6: 4294967039
C7: 4294967039
-11258997720986.12 deg c
-11258997720986.12 deg c
-11258997720986.12 deg c
However, if we upload it to an ESP32 Feather on the same board with the same hardware, we get the following:
Starting on MS5xxx
C0: 20
C1: 37555
C2: 34296
C3: 24510
C4: 23248
C5: 34466
C6: 28969
C7: 53513
11.23 deg c
11.25 deg c
11.25 deg c
I further verified that my sensor was working correctly by writing my own code to print out PROM values:
Wire.beginTransmission(ADDRESS);
Wire.write(0xA2);
Wire.endTransmission();
Wire.requestFrom(ADDRESS, 2);
uint8_t higher_8 = Wire.read();
uint8_t lower_8 = Wire.read();
uint16_t value = (higher_8 << 8) | lower_8; // Read the first 8 bits; shift them left 8; OR with the next 8 bits
Serial.print("Higher 8: "); Serial.print(higher_8, BIN); Serial.print("Lower 8: "); Serial.print(lower_8, BIN); Serial.print("Full: "); Serial.println(value, DEC);
Which printed the correct value for A2
After digging into the library, I noticed calls to _Wire->endTransmission(true);
after reading bytes from serial; removing these calls caused the calibration readings and read temperature to be equivalent to with the ESP32. Why is this function call present after reading bytes from i2c?
The setup: I'm working with an arduino pro mini(using the arduino bootloader) and a MS5607 barometer.
The Problem: ReadCalc was returning the wrong result (which I only knew because I fixed Calc_CRC4)
The Solution: replace "char c" with " unsigned int c"
void MS5xxx::ReadProm() {
send_cmd(MS5xxx_CMD_RESET);
delay(3);
for(uint8_t i=0;i<8;i++)
{
C[i]=0x0000;
send_cmd(MS5xxx_CMD_PROM_RD+2*i);
_Wire->requestFrom(i2caddr, 2);
unsigned int c = _Wire->read();
C[i] = (c << 8);
c = _Wire->read();
C[i] += c;
_Wire->endTransmission(true);
}
The Second Problem: Calc_CRC4 was returning zero.
The Second Solution: I adapted the "crc4" function from document AN520 by measurement specialties
unsigned char MS5xxx::Calc_CRC4()
{
int cnt; // simple counter
unsigned int n_rem; // crc reminder
unsigned int crc_read; // original value of the crc
unsigned char n_bit;
n_rem = 0x00;
crc_read=C[7]; //save read CRC
C[7]=(0xFF00 & (C[7])); //CRC byte is replaced by 0
for (cnt = 0; cnt < 16; cnt++) // operation is performed on bytes
{// choose LSB or MSB
if (cnt%2==1) n_rem ^= (unsigned short) ((C[cnt>>1]) & 0x00FF);
else n_rem ^= (unsigned short) (C[cnt>>1]>>8);
for (n_bit = 8; n_bit > 0; n_bit--)
{
if (n_rem & (0x8000))
{
n_rem = (n_rem << 1) ^ 0x3000;
}
else
{
n_rem = (n_rem << 1);
}
}
}
n_rem= (0x000F & (n_rem >> 12)); // final 4-bit reminder is CRC code
C[7]=crc_read; // restore the crc_read to its original place
return (n_rem ^ 0x0);
unsigned char MS5xxx::CRCcodeTest(){
unsigned int nprom[] = {0x3132,0x3334,0x3536,0x3738,0x3940,0x4142,0x4344,0x4500}; //expected output is 0xB
for(uint8_t i=0;i<8;i++)
{
C[i] = nprom[i];
}
unsigned char crc = Calc_CRC4(); //expected output is 0xB
ReadProm();
return crc;
*note: after substituting in these new functions you will need to update the header appropriatly
I have newly installed Arduino IDE v1.8.13 and downloaded the MS5xxx lib, as I remember from arduinolibraries.info but the example program Simple Server does not run.
I always get "Error connecting..." means can not connect to the sensor.
Because I am not a specialist with this breakout board and not that code master, could you help me what I could do ?
Regards Gerald
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.