Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Arduino code - LM75A thermometer + OLED + Arduino NANO
#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
You can’t perform that action at this time.