Skip to content

Commit 9107ffe

Browse files
committed
Add Project
1 parent 1dda0e2 commit 9107ffe

File tree

7 files changed

+138
-1
lines changed

7 files changed

+138
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <Wire.h>
2+
#include "SFE_BMP180.h"
3+
4+
SFE_BMP180 sfe_bmp180;
5+
6+
#define ALTITUDE 1655.0
7+
8+
void setup()
9+
{
10+
Serial.begin(9600);
11+
Serial.println("BMP180 - Pressure Measurement");
12+
13+
if (sfe_bmp180.begin()) {
14+
Serial.println("Connected to the BMP180 sensor.");
15+
} else {
16+
Serial.println("Failed to connect to the BM180 sensor.");
17+
while(1);
18+
}
19+
}
20+
21+
void loop()
22+
{
23+
char status;
24+
double T, P, p_0, value;
25+
Serial.println();
26+
27+
status = sfe_bmp180.startTemperature();
28+
if (status != 0) {
29+
delay(status);
30+
31+
status = sfe_bmp180.getTemperature(T);
32+
if (status != 0) {
33+
Serial.print("Temperature : ");
34+
Serial.print(T, 2);
35+
Serial.print(" (Celcius) C, ");
36+
Serial.print((9.0 / 5.0) * T + 32.0, 2);
37+
Serial.println(" (Fahrenheit) F");
38+
39+
status = sfe_bmp180.startPressure(3);
40+
if (status != 0) {
41+
delay(status);
42+
43+
status = sfe_bmp180.getPressure(P, T);
44+
if (status != 0) {
45+
Serial.print("Absolute pressure : ");
46+
Serial.print(P, 2);
47+
Serial.print(" millibar, ");
48+
Serial.print(P * 0.0295333727, 2);
49+
Serial.println(" civainc");
50+
51+
value = (1013.2 - P) * 9.5;
52+
Serial.print("Calculated altitude : ");
53+
Serial.print(value, 0);
54+
Serial.print(" meter, ");
55+
Serial.print(value * 3.28084, 0);
56+
Serial.println(" feet");
57+
} else {
58+
Serial.println("Error occurred in pressure measurement.\n");
59+
}
60+
} else {
61+
Serial.println("Pressure measurement is faulty.\n");
62+
}
63+
} else {
64+
Serial.println("Error occurred in temperature measurement.\n");
65+
}
66+
} else {
67+
Serial.println("Temperature measurement is faulty.\n");
68+
}
69+
70+
delay(5000);
71+
}

BMP180BreakoutArduinoLibrary.zip

15.6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#define TRIG_PIN 8
2+
#define ECHO_PIN 9
3+
4+
void setup()
5+
{
6+
Serial.begin(9600);
7+
pinMode(TRIG_PIN, OUTPUT);
8+
pinMode(ECHO_PIN, INPUT);
9+
}
10+
11+
void loop()
12+
{
13+
digitalWrite(TRIG_PIN, LOW);
14+
delayMicroseconds(2);
15+
digitalWrite(TRIG_PIN, HIGH);
16+
delayMicroseconds(10);
17+
digitalWrite(TRIG_PIN, LOW);
18+
19+
long microsecond = pulseIn(ECHO_PIN, HIGH);
20+
long distance = microsecond / 58.3;
21+
Serial.print(distance);
22+
Serial.println(" cm");
23+
delay(1500);
24+
}

Keypad-Example/Keypad-Example.ino

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "Keypad.h"
2+
3+
const byte rows = 3;
4+
const byte cols = 4;
5+
char keys[rows][cols] = {
6+
{ '0', '8', '5', '2' },
7+
{ '#', '9', '6', '3' },
8+
{ '*', '7', '4', '1' }
9+
};
10+
byte row_pins[rows] = { 7, 8, 6 };
11+
byte col_pins[cols] = { 5, 4, 3, 2 };
12+
13+
Keypad keypad = Keypad(makeKeymap(keys), row_pins, col_pins, rows, cols);
14+
15+
void setup()
16+
{
17+
Serial.begin(9600);
18+
}
19+
20+
void loop()
21+
{
22+
char key = keypad.getKey();
23+
if (key != NO_KEY)
24+
Serial.println(key);
25+
}

Keypad.zip

18.1 KB
Binary file not shown.

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
# Arduino-Sensor-Examples
1+
# Arduino-Sensor-Examples
2+
Contains sensor module examples with Arduino. These examples include:
3+
4+
- BMP180-PressureMeasurement: This example demonstrates how to measure pressure, altitude, and temperature using the BMP180 sensor module with Arduino. The Arduino communicates with the BMP180 sensor module via I2C. The connection is made using the Arduino A4 and A5 pins.
5+
6+
- HCSR04-DistanceMeasurement: This example shows how to measure distance using the HC-SR04 distance sensor module with Arduino. The Arduino connects the HCSR04 distance sensor to the trig pin (D8) and the echo pin (D9).
7+
8+
- Keypad-Example: This example allows the use of a keypad module with Arduino.
9+
10+
Arduino Used: Arduino Uno, Arduino Mega
11+
12+
Arduino IDE Version: 2.2.0
13+
14+
BMP180BreakoutArduinoLibrary Arduino Library: This library enables the use of the BMP180 sensor module. Include this library in your Arduino IDE.
15+
16+
Keypad Arduino Library: This library enables the use of the Keypad module. Include this library in your Arduino IDE.
17+
18+
Arduino-Keypad Connection Diagram: The connection of the keypad to the Arduino is shown in the (keypad-schematic.png) image.

keypad-schematic.png

152 KB
Loading

0 commit comments

Comments
 (0)