Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to allow code to run on SparkFun OpenLog Artemis #22

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ MS5837();

/** Must be called before attempting to operate the sensor.
* Returns true if the sensor was initialized successfully.
* wirePort is optional and defaults to Wire.
* You can select a different port by calling (e.g.) init(Wire1)
*/
bool init();
bool init(TwoWire &wirePort);

/** Calls init.
* Returns true if the sensor was initialized successfully.
*/
bool begin(TwoWire &wirePort);

/** Set model of MS5837 sensor. Valid options are MS5837::MS5837_30BA (default)
* and MS5837::MS5837_02BA.
*/
void setModel(uint8_t model);

/** Provide the density of the working fluid in kg/m^3. Default is for
/** Provide the density of the working fluid in kg/m^3. Default is for
* seawater. Should be 997 for freshwater.
*/
void setFluidDensity(float density);

/** The read from I2C takes up for 40 ms, so use sparingly is possible.
/** The read from I2C takes up for 40 ms, so use sparingly if possible.
*/
void read();

Expand Down
41 changes: 22 additions & 19 deletions examples/MS5837_Example/MS5837_Example.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* Blue Robotics MS5837 Library Example
-----------------------------------------------------

Title: Blue Robotics MS5837 Library Example

Description: This example demonstrates the MS5837 Library with a connected
sensor. The example reads the sensor and prints the resulting values
to the serial terminal.

The code is designed for the Arduino Uno board and can be compiled and
The code is designed for the Arduino Uno board and can be compiled and
uploaded via the Arduino 1.0+ software.

-------------------------------
Expand Down Expand Up @@ -40,11 +40,11 @@ THE SOFTWARE.
MS5837 sensor;

void setup() {

Serial.begin(9600);

Serial.println("Starting");

Wire.begin();

// Initialize pressure sensor
Expand All @@ -57,30 +57,33 @@ void setup() {
Serial.println("\n\n\n");
delay(5000);
}

sensor.setModel(MS5837::MS5837_30BA);

// .init sets the sensor model for us but we can override it if required.
// Uncomment the next line to force the sensor model to the MS5837_30BA.
//sensor.setModel(MS5837::MS5837_30BA);

sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater)
}

void loop() {
// Update pressure and temperature readings
sensor.read();

Serial.print("Pressure: ");
Serial.print(sensor.pressure());
Serial.print("Pressure: ");
Serial.print(sensor.pressure());
Serial.println(" mbar");
Serial.print("Temperature: ");
Serial.print(sensor.temperature());

Serial.print("Temperature: ");
Serial.print(sensor.temperature());
Serial.println(" deg C");
Serial.print("Depth: ");
Serial.print(sensor.depth());

Serial.print("Depth: ");
Serial.print(sensor.depth());
Serial.println(" m");
Serial.print("Altitude: ");
Serial.print(sensor.altitude());

Serial.print("Altitude: ");
Serial.print(sensor.altitude());
Serial.println(" m above mean sea level");

delay(1000);
}
}
31 changes: 31 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#######################################
# Syntax Coloring Map
#######################################

#######################################
# Datatypes (KEYWORD1)
#######################################

MS5837 KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
#######################################

begin KEYWORD2
init KEYWORD2
setModel KEYWORD2
getModel KEYWORD2
setFluidDensity KEYWORD2
read KEYWORD2
pressure KEYWORD2
temperature KEYWORD2
depth KEYWORD2
altitude KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

MS5837_30BA LITERAL1
MS5837_02BA LITERAL1
Loading