SparkFun BMP180: an example that runs
Yes. You can use the SparkFun BMP180 (SFE_BMP180) library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (BMP180 pressure sensor). The example below, "Temperature, pressure and sea-level pressure in SFE_BMP180’s steps", runs on the Arduino Uno R3.
Built in on Mokxi: #include <SFE_BMP180.h> and it builds, with nothing to install. Free, and no account needed.
What SparkFun BMP180 (SFE_BMP180) does
The BMP180 in its tutorial’s steps: startTemperature(), getTemperature(T), startPressure(3), getPressure(P, T), sealevel() and altitude(). That is what SparkFun BMP180, by SparkFun Electronics, covers. The sketch below uses it on the Arduino Uno: “Temperature, pressure and sea-level pressure in SFE_BMP180’s steps”.
Each start call returns the ms to wait (0 when the chip did not answer) and each get call 1 on success. sealevel(P, A) and altitude(P, P0) are the datasheet's barometric formula. The datasheet's integer compensation does the sums, so getPressure() uses the temperature it measures itself and the T passed in is not needed.
The calls follow release 1.1.2 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.
| Library Manager name | SparkFun BMP180 (SFE_BMP180) |
|---|---|
| Author | SparkFun Electronics |
| Include | #include <SFE_BMP180.h> |
| Boards | every board Mokxi compiles for but ATtiny85 |
| In the simulator | Simulated: it runs against the part the way it does on the bench. |
| Parts it drives | BMP180 pressure sensor |
Install it
It builds on every board Mokxi compiles for but ATtiny85.
In Mokxi it is built in: #include <SFE_BMP180.h> and the sketch compiles, with no download, no zip and no Library Manager.
On a real board, install "SparkFun BMP180 (SFE_BMP180)" by SparkFun Electronics from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add SparkFun BMP180 (SFE_BMP180) to lib_deps in PlatformIO. Mokxi follows the calls of release 1.1.2, so a sketch written here builds there too.
What to know in the simulator: getPressure() uses the temperature it measures itself; the T passed in is not needed.
- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi
The calls you will use
In the order a sketch meets them.
SFE_BMP180 pressure
Makes pressure, the SFE_BMP180 object the calls below are made on.
pressure.begin()
Starts it up. Call it once in setup().
pressure.getTemperature(T)
Returns the temperature as a whole number. Arguments: temperature.
pressure.getPressure(P, T)
Returns the pressure as a whole number. Arguments: pressure, temperature.
Example: Temperature, pressure and sea-level pressure in SFE_BMP180’s steps
On the Arduino Uno R3. It runs in the browser exactly as printed.
#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
#define ALTITUDE 1655.0 // meters, at SparkFun in Boulder
void setup() {
Serial.begin(9600);
if (pressure.begin())
Serial.println("BMP180 init success");
else {
Serial.println("BMP180 init fail\n\n");
while (1);
}
}
void loop() {
char status;
double T, P, p0;
status = pressure.startTemperature();
if (status != 0) {
delay(status);
status = pressure.getTemperature(T);
if (status != 0) {
Serial.print("temperature: ");
Serial.print(T, 1);
Serial.println(" deg C");
status = pressure.startPressure(3);
if (status != 0) {
delay(status);
status = pressure.getPressure(P, T);
if (status != 0) {
Serial.print("absolute pressure: ");
Serial.print(P, 1);
Serial.println(" mb");
p0 = pressure.sealevel(P, ALTITUDE);
Serial.print("relative (sea-level) pressure: ");
Serial.print(p0, 1);
Serial.println(" mb");
}
}
}
}
delay(5000);
}Wiring
- Arduino Uno R3 A4 to BMP180 pressure sensor SDA
- Arduino Uno R3 A5 to BMP180 pressure sensor SCL
- Arduino Uno R3 5V to BMP180 pressure sensor VCC
- Arduino Uno R3 GND to BMP180 pressure sensor GND
Keep going
Try SparkFun BMP180 (SFE_BMP180) without installing anything
Open the example, change the sketch, and keep your version in a free account.