Introduction
In this article, I will explain about connecting the BMP085 in Arduino and Python. In Arduino, it will be used to see the temperature measurement in the Serial monitor. But in Python, it will display in the run module.
Parts Of Lists
HardWareParts
- Arduino Uno
- BMP085
- Hook up wires
- Bread Board.
Software Required
- Arduino IDE
- Python 2.7.11
Connection From ArduinoUno To BMPO85 Sensor
Sensor |
Board |
Gnd |
Gnd |
Vin |
5v |
SDA |
A3 |
SCL |
A4 |
Progarmming
- #include "Wire.h" // imports the wire library for talking over I2C
- #include "Adafruit_BMP085.h" // import the Pressure Sensor Library
- Adafruit_BMP085 mySensor;
-
- float tempC;
- float tempF;
- float pressure;
-
- void setup(){
- Serial.begin(9600);
- mySensor.begin();
- }
-
- void loop() {
- tempC = mySensor.readTemperature();
- tempF = tempC*1.8 + 32.;
- pressure=mySensor.readPressure();
-
- Serial.print("The Temp is: ");
- Serial.print(tempF);
- Serial.println(" degrees F");
- Serial.print("The Pressure is: ");
- Serial.print(pressure);
- Serial.println(" Pa.");
- Serial.println("");
- delay(250);
- }
Program Of Python
- import serial
- import numpy
- import matplotlib.pyplot as plt
- from drawnow import *
-
- tempF= []
- pressure=[]
- arduinoData = serial.Serial('com11', 115200)
- plt.ion()
- cnt=0
-
- def makeFig():
- plt.ylim(80,90)
- plt.title('My Live Streaming Sensor Data')
- plt.grid(True)
- plt.ylabel('Temp F')
- plt.plot(tempF, 'ro-', label='Degrees F')
- plt.legend(loc='upper left')
- plt2=plt.twinx()
- plt.ylim(93450,93525)
- plt2.plot(pressure, 'b^-', label='Pressure (Pa)')
- plt2.set_ylabel('Pressrue (Pa)')
- plt2.ticklabel_format(useOffset=False)
- plt2.legend(loc='upper right')
-
-
- while True:
- while (arduinoData.inWaiting()==0):
- pass
- arduinoString = arduinoData.readline()
- dataArray = arduinoString.split(',')
- temp = float( dataArray[0])
- P = float( dataArray[1])
- tempF.append(temp)
- pressure.append(P)
- drawnow(makeFig)
- plt.pause(.000001)
- cnt=cnt+1
- if(cnt>50):
- tempF.pop(0)
- pressure.pop(0)
Explanation
In this article I will explain about how the BMP085 can be used to see the temperature level. In Arduino it will be displayed in the serial monitor but in Python I have used the matlab plot.
The matplot software is used to display the higher and lower levels of the temperature. Click the software below and download the software.
http:/pip.pypa.io/en/learning/installing.
In Python write the code and click the
run module or f5 to see the output.
In Python the data and the code will be read from Arduino because we have given the Arduino port in Python.The matlab plot can plot the temperature in the current level.
Output
Figure 1 : Output