The RTC-ds3231 extra feature.
The real time clock ds3231 comes with an extra feature. It's an internal temperature sensor ranging from -45 °C to +85 °C. Mounting the ds3231 module with a piece of cable outside your pi box will give you the ability to read room or outside temperature while operating the pi. It's temperature value can be read by the following 'code'.
Make this an executable shell script.
#!/bin/bash
echo $(cat /sys/bus/i2c/devices/1-0068/hwmon/hwmon2/temp1_input|awk '{print $0/1000 " °C"}')
echo $(cat /sys/bus/i2c/devices/1-0068/hwmon/hwmon2/temp1_input|awk '{print (($0/1000 * 1.8) + 32) " °F"}')
echo $(cat /sys/bus/i2c/devices/1-0068/rtc/rtc0/date)
echo $(cat /sys/bus/i2c/devices/1-0068/rtc/rtc0/time) "UTC"
The console output will look like this.
# /root/ds3231-TempSensor
24.25 °C
75.65 °F
2022-03-18
15:35:00 UTC
# /root/ds3231-TempSensor
24.5 °C
76.1 °F
2022-03-18
15:37:50 UTC
#