{"id":8102,"date":"2019-08-15T23:06:59","date_gmt":"2019-08-15T22:06:59","guid":{"rendered":"https:\/\/stevepedwards.today\/quad\/Electronics\/?p=8102"},"modified":"2019-08-15T23:06:59","modified_gmt":"2019-08-15T22:06:59","slug":"combining-code-from-bmp180-and-thermistor-lcd-output","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/ElectronicsStuff\/combining-code-from-bmp180-and-thermistor-lcd-output\/","title":{"rendered":"Combining Code from BMP180 and Thermistor LCD Output"},"content":{"rendered":"<p><a href=\"https:\/\/youtu.be\/V73NPS6-OYI\">https:\/\/youtu.be\/V73NPS6-OYI<\/a><br \/>\n<a href=\"https:\/\/stevepedwards.today\/wmrx00.sourceforge.net\/\">https:\/\/stevepedwards.today\/wmrx00.sourceforge.net\/<\/a><br \/>\n<a href=\"https:\/\/youtu.be\/DXGtw0zpOqY\">https:\/\/youtu.be\/DXGtw0zpOqY<\/a><br \/>\nAfter a lot of trial and error for the order that the 2 code pieces display their resp. data to LCD and serial monitor, I got both sensors to print to the LCD while keeping the BMP180 serial display:<br \/>\nCODE:<\/p>\n<pre class=\"lang:default decode:true\">#include &lt;LiquidCrystal.h&gt;\n#include &lt;Wire.h&gt;\n#include &lt;Adafruit_BMP085.h&gt;\nAdafruit_BMP085 bmp;\nint ThermistorPin = 0;\nint Vo;\nfloat R1 = 9900;\nfloat logR2, R2, T;\nfloat c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;\nLiquidCrystal lcd(12, 11, 5, 4, 3, 2);\nvoid setup() {\nSerial.begin(9600);\nbmp.begin();\n}\nvoid loop() {\nVo = analogRead(ThermistorPin);\nR2 = R1 * (1023.0 \/ (float)Vo - 1.0);\nlogR2 = log(R2);\nT = (1.0 \/ (c1 + c2*logR2 + c3*logR2*logR2*logR2));\nT = T - 273.15;\nT = (T * 9.0)\/ 5.0 + 32.0;\n\/\/conv C\nT = (T - 32) \/ 1.8;\nlcd.print(\"Temp = \");\nlcd.print(T);\nlcd.print(\" C\");\ndelay(2000);\nlcd.clear();\nSerial.print(\"TempBMP(C)= \");\nSerial.print(bmp.readTemperature());\nlcd.print(\"TempBMP(C)= \");\nlcd.print(bmp.readTemperature());\ndelay(2000);\nlcd.clear();\nSerial.print(\" Pressure (Pa)= \");\nSerial.print(bmp.readPressure());\nlcd.print(\"Pres(Pa)=\");\nlcd.print(bmp.readPressure());\ndelay(2000);\nlcd.clear();\nSerial.print(\" Altitude (m)= \");\nSerial.print(bmp.readAltitude());\nlcd.print(\"Alt(m)= \");\nlcd.print(bmp.readAltitude());\nSerial.println();\ndelay(2000);\nlcd.clear();\ndelay(2000);\nlcd.clear();\n}<\/pre>\n<p>&nbsp;<br \/>\nThis had to be space compressed and abbreviated etc. to fit on the LCD, but can be seen that the print line has to be followed immediately by the respective sensor read line to get the next data value e.g .(bmp.readTemperature(), from the unit to follow the LCD text:<br \/>\nSerial.print(\"TempBMP(C)= \");<br \/>\nSerial.print(bmp.readTemperature());<br \/>\nlcd.print(\"TempBMP(C)= \");<br \/>\nlcd.print(bmp.readTemperature());<br \/>\ndelay(2000);<br \/>\nlcd.clear();<br \/>\nIn the SFE180 example code, altitude is set as the constant:<br \/>\nSFE_BMP180 pressure;<br \/>\n#define ALTITUDE 1540 \/\/ Altitude of SparkFun's HQ in Boulder, CO. in meters so maybe this an be added...<\/p>\n<hr \/>\n<p>In this code, you can add your current pressure, but still gives wrong Alt...?:<br \/>\nThis is an example for the BMP085 Barometric Pressure &amp; Temp Sensor<br \/>\nDesigned specifically to work with the Adafruit BMP085 Breakout<br \/>\n----&gt; https:\/\/www.adafruit.com\/products\/391<br \/>\nThese displays use I2C to communicate, 2 pins are required to<br \/>\ninterface<br \/>\nAdafruit invests time and resources providing this open source code,<br \/>\nplease support Adafruit and open-source hardware by purchasing<br \/>\nproducts from Adafruit!<br \/>\nWritten by Limor Fried\/Ladyada for Adafruit Industries.<br \/>\nBSD license, all text above must be included in any redistribution<\/p>\n<pre class=\"lang:default decode:true\">\/*******************************************************************************************************\/\n#include &lt;Wire.h&gt;\n#include &lt;Adafruit_BMP085.h&gt;\n\/\/ Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)\n\/\/ Connect GND to Ground\n\/\/ Connect SCL to i2c clock - on '168\/'328 Arduino Uno\/Duemilanove\/etc thats Analog 5\n\/\/ Connect SDA to i2c data - on '168\/'328 Arduino Uno\/Duemilanove\/etc thats Analog 4\n\/\/ EOC is not used, it signifies an end of conversion\n\/\/ XCLR is a reset pin, also not used here\nAdafruit_BMP085 bmp;\nvoid setup() {\nSerial.begin(9600);\nif (!bmp.begin()) {\nSerial.println(\"Could not find a valid BMP085 sensor, check wiring!\");\nwhile (1) {}\n}\n}\nvoid loop() {\nSerial.print(\"Temperature = \");\nSerial.print(bmp.readTemperature());\nSerial.println(\" *C\");\nSerial.print(\"Pressure = \");\nSerial.print(bmp.readPressure());\nSerial.println(\" Pa\");\n\/\/ Calculate altitude assuming 'standard' barometric\n\/\/ pressure of 1013.25 millibar = 101325 Pascal\nSerial.print(\"Altitude = \");\nSerial.print(bmp.readAltitude());\nSerial.println(\" meters\");\nSerial.print(\"Pressure at sealevel (calculated) = \");\nSerial.print(bmp.readSealevelPressure());\nSerial.println(\" Pa\");\n\/\/ you can get a more precise measurement of altitude\n\/\/ if you know the current sea level pressure which will\n\/\/ vary with weather and such. If it is 1015 millibars\n\/\/ that is equal to 101500 Pascals.\nSerial.print(\"Real altitude = \");\nSerial.print(bmp.readAltitude(101800));\nSerial.println(\" meters\");\nSerial.println();\ndelay(5000);\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/youtu.be\/V73NPS6-OYI https:\/\/stevepedwards.today\/wmrx00.sourceforge.net\/ https:\/\/youtu.be\/DXGtw0zpOqY After a lot of trial and error for the order that the 2 code pieces display their resp. data to LCD and serial monitor, I got both sensors to print to the LCD while keeping the BMP180 serial display: CODE: #include &lt;LiquidCrystal.h&gt; #include &lt;Wire.h&gt; #include &lt;Adafruit_BMP085.h&gt; Adafruit_BMP085 bmp; int ThermistorPin = 0; <a href=\"https:\/\/stevepedwards.today\/ElectronicsStuff\/combining-code-from-bmp180-and-thermistor-lcd-output\/\" class=\"more-link\">...<span class=\"screen-reader-text\">  Combining Code from BMP180 and Thermistor LCD Output<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,2],"tags":[],"class_list":["post-8102","post","type-post","status-publish","format-standard","hentry","category-tech-studies","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts\/8102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/comments?post=8102"}],"version-history":[{"count":0,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/posts\/8102\/revisions"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/media?parent=8102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/categories?post=8102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-json\/wp\/v2\/tags?post=8102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}