Created
September 5, 2019 23:00
-
-
Save MichalSkoula/c5082d1ca91a8cfcd47c3fa17733f708 to your computer and use it in GitHub Desktop.
Simple Arduino code - LM75A thermometer + OLED + Arduino NANO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <U8g2lib.h> | |
#include <LM75A.h> | |
// Create display instance | |
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0); | |
// Create I2C LM75A instance | |
LM75A lm75a_sensor(false, false, false); | |
// temperature variable | |
float temperature_in_degrees = 0; | |
void setup(void) | |
{ | |
u8g2.begin(); | |
} | |
void loop(void) | |
{ | |
// get temperature | |
temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees(); | |
delay(500); | |
// draw everything | |
u8g2.firstPage(); | |
do { | |
// print logo | |
u8g2.setFont(u8g2_font_t0_17b_tf ); | |
u8g2.setCursor(15, 18); | |
u8g2.print("bastlime.eu"); | |
// print temperature | |
u8g2.setFont(u8g2_font_inb30_mn); | |
u8g2.setCursor(0, 55); | |
if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE) { | |
u8g2.print("ERROR"); | |
} else { | |
u8g2.print(temperature_in_degrees); | |
} | |
} while (u8g2.nextPage()); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment