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
Connection From ArduinoUno To BMPO85 Sensor
Sensor Board
Gnd Gnd
Vin 5v
SDA A3
SCL A4
Progarmming
Program Of Arduino
  1. #include "Wire.h" // imports the wire library for talking over I2C
  2. #include "Adafruit_BMP085.h" // import the Pressure Sensor Library
  3. Adafruit_BMP085 mySensor; // create sensor object called mySensor
  4. float tempC; // Variable for holding temp in C
  5. float tempF; // Variable for holding temp in F
  6. float pressure; //Variable for holding pressure reading
  7. void setup(){
  8. Serial.begin(9600); //turn on serial monitor
  9. mySensor.begin(); //initialize mySensor
  10. }
  11. void loop() {
  12. tempC = mySensor.readTemperature(); // Read Temperature
  13. tempF = tempC*1.8 + 32.; // Convert degrees C to F
  14. pressure=mySensor.readPressure(); //Read Pressure
  15. Serial.print("The Temp is: "); //Print Your results
  16. Serial.print(tempF);
  17. Serial.println(" degrees F");
  18. Serial.print("The Pressure is: ");
  19. Serial.print(pressure);
  20. Serial.println(" Pa.");
  21. Serial.println("");
  22. delay(250); //Pause between readings.
  23. }
Program Of Python
  1. import serial # import Serial Library
  2. import numpy # Import numpy
  3. import matplotlib.pyplot as plt #import matplotlib library
  4. from drawnow import *
  5. tempF= []
  6. pressure=[]
  7. arduinoData = serial.Serial('com11', 115200) #Creating our serial object named arduinoData
  8. plt.ion() #Tell matplotlib you want interactive mode to plot live data
  9. cnt=0
  10. def makeFig(): #Create a function that makes our desired plot
  11. plt.ylim(80,90) #Set y min and max values
  12. plt.title('My Live Streaming Sensor Data') #Plot the title
  13. plt.grid(True) #Turn the grid on
  14. plt.ylabel('Temp F') #Set ylabels
  15. plt.plot(tempF, 'ro-', label='Degrees F') #plot the temperature
  16. plt.legend(loc='upper left') #plot the legend
  17. plt2=plt.twinx() #Create a second y axis
  18. plt.ylim(93450,93525) #Set limits of second y axis- adjust to readings you are getting
  19. plt2.plot(pressure, 'b^-', label='Pressure (Pa)') #plot pressure data
  20. plt2.set_ylabel('Pressrue (Pa)') #label second y axis
  21. plt2.ticklabel_format(useOffset=False) #Force matplotlib to NOT autoscale y axis
  22. plt2.legend(loc='upper right') #plot the legend
  23. while True: # While loop that loops forever
  24. while (arduinoData.inWaiting()==0): #Wait here until there is data
  25. pass #do nothing
  26. arduinoString = arduinoData.readline() #read the line of text from the serial port
  27. dataArray = arduinoString.split(',') #Split it into an array called dataArray
  28. temp = float( dataArray[0]) #Convert first element to floating number and put in temp
  29. P = float( dataArray[1]) #Convert second element to floating number and put in P
  30. tempF.append(temp) #Build our tempF array by appending temp readings
  31. pressure.append(P) #Building our pressure array by appending P readings
  32. drawnow(makeFig) #Call drawnow to update our live graph
  33. plt.pause(.000001) #Pause Briefly. Important to keep drawnow from crashing
  34. cnt=cnt+1
  35. if(cnt>50): #If you have 50 or more points, delete the first one from the array
  36. tempF.pop(0) #This allows us to just see the last 50 data points
  37. 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