/*
Custom chip playground (LM75A)
Thanks @Tim2000 from the Wokwi community for the fixes and improvements.
See for more info: https://link.wokwi.com/custom-chips-alpha/
*/
#include <LM75A.h>
#include <LiquidCrystal_I2C.h>
// Create I2C LM75A instance
LM75A lm75a_sensor(false, // A0 LM75A pin state (connected to ground = false)
false, // A1 LM75A pin state (connected to ground = false)
false); // A2 LM75A pin state (connected to ground = false)
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
float temperature = 0;
uint8_t DegreeBitmap[] = { 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0 };
void setup() {
Serial.begin(9600);
// Initialize the lcd
lcd.init();
// Storage the custom degree symbol as character #1
lcd.createChar(1, DegreeBitmap);
// Print a message to the LCD
lcd.backlight();
lcd.setCursor(5, 0);
lcd.print("LM75A");
lcd.setCursor(2, 1);
lcd.print("Address 0x48");
delay(1000);
lcd.clear();
}
void loop() {
// 11-bit ADC that offers a temperature resolution of 0.125 °C
temperature = lm75a_sensor.getTemperatureInDegrees();
if (temperature != INVALID_LM75A_TEMPERATURE) {
lcd.setCursor(2, 0);
lcd.print("Temperature:");
lcd.setCursor(4, 1);
lcd.print(temperature);
lcd.print("\001C "); // Print char 1 (which is the degree) followed by C
delay(1000);
}
}