Cpu Temp Logger


In this tutorial, we will implement a simple temperature logger on the Raspberry Pi 3 and connect four DS18B20 temperature sensors to it. The temperature measurements will be stored in a database along with a time stamp. Real Temp is a CPU temperature monitoring software. It is specially designed for Intel single core, dual core, quad core and core i7 processors. It shows the temperature of the CPU in real time. It also shows the maximum and minimum temperature of the CPU.

In this tutorial, we will implement a simple temperature logger on the Raspberry Pi 3 and connect four DS18B20 temperature sensors to it.
The temperature measurements will be stored in a database along with a time stamp. We have selected InfluxDB as the database engine as this is a time-series database and integrates very easy to Grafana.
Grafana will retrieve and visualize the data stored in the database. Grafana is an open source solution for running data analytics, pulling up metrics that make sense of the massive amount of data, and to visualize our results in the form of graphs and gauges with the help of very cool customizable dashboards.
Everything is running on the Raspberry so before start writing code we have to do some preparing:

  • Setup the 1-wire bus on raspberry pi to be able to communicate with the DS18B20 sensor
  • Connect temperature sensors to the Raspberry GPIO
  • Install InfluxDb and Grafana
  • Add required python libraries
  1. Under load, you want your CPU to ideally stay under 80 degrees Celsius (176 degrees Fahrenheit), though some CPUs may run hotter when they're in laptops or small-form-factor (SFF) computers.
  2. Im brand new here with a bit of a problem. Im after a program that can monitor the temperature of CPU cores over a 60 second period, on a 9700K. RealTemp and RealTempGT offer this service perfectly for anything up to 6 cores but not above. Ideally, itll record the temperatures of th.

1. Setup the 1-wire bus on raspberry Pi 3.

The Raspberry Pi Rasbian operating system has a 1-wire bus driver that can use GPIO4 as data in/out if enabled. It provides low-speed data, signaling, and power over a single conductor. Low cost 1-wire devices such as the DS18B20 temperature sensor commonly connects to this port. The default Raspbian image disables the interface by default so before you can use it we must make a configuration change.
Open the command line CLi terminal and execute the following bash command that will start the raspberry config utility:

This will start the raspi-config utility. Select 5 “Interfacing Options” :
Highlight the “1-wire” option and activate <Select > :
On the next screen Select and activate <Yes >.
When prompted to reboot highlight and activate <Yes > .
The Raspberry Pi will reboot and the interface will be enabled ready for use.

2. Connect the DS18B20 sensors to the raspberry IO.

The circuit drawing below shows how to connect four DS18B20 sensors to the Raspberry GPIO. It is important to connect the DS18B20 Vcc pin to +3.3V as the raspberry GPIO port is runned on 3.3V. A pullup resistor of 4.7kOhm have been connected between +3.3V and GPIO4. When the 1-wire peripheral is enabled in the raspberry, GPIO4 is configured as data in/out pin, which connects to DS18B20 data (DQ) pin.
Use low capacitance cable if you plan to place sensors far away, 10 -100m. Ethernet cable is cheap and works well. Connect GND and DQ to one of the pair, and 3.3V on another wire pair.
Place your sensors along the cable (linear network topology), starting from the master and extending to the farthest slave device. This will make the communication more robust and with less errors. Other slaves connects to the 1-wire bus cable with insignificant branches (<3m) or stubs.

3. Verify the 1-wire DS18B20 communication.

Now is the time to test if the raspberry is able to communicate with the sensors.
Open the command line interface Terminal, and at the command prompt enter:

modprobe w1-gpio registers the new sensors connected to GPIO4 so that the Raspberry Pi knows that there is a 1-Wire device connected to the GPIO connector.
modprobe is a Linux program used to add a loadable kernel module (LKM) to the Linux kernel or to remove a LKM from the kernel. It is commonly used to load drivers for automatically detected hardware.

Then run the command:

modprobe w1-therm tells the Raspberry Pi to add the ability to measure temperature on the 1-Wire system.

To allow the w1_gpio and w1_therm modules to load automatically at boot we can edit the /etc/modules file and include both modules there where they will be started when the Pi boots up. Edit the /etc/modules file using the nano editor:

Add the following to the file and then save and exit.

Change directories to the /sys/bus/w1/devices directory by entering:

Now enter ls to list the devices:

This should list out the contents of the /sys/bus/w1/devices which should include a number of directories starting 28-. The number of directories should match the number of connected sensors. The portion of the name following the 28- is the unique serial number of each of the sensors.


We then cd into one of those directories:

( Change xxxxxxxxxxxx to match the serial number of one of the directories )
We are then going to view the ‘w1_slave’ file with the cat command using:

The cat program takes the specified file (or files) and by default outputs the results to the screen (there are a lot of different options for cat, more can be found here).

The output should look something like the following:

At the end of the first line we see a YES for a successful CRC check (CRC stands for Cyclic Redundancy Check, a good sign that things are going well). If we get a response like NO or FALSE or ERROR, it will be an indication that there is some kind of problem that needs addressing. Check the circuit connections and start troubleshooting.
At the end of the second line we can now find the current temperature. The t=22312 is an indication that the temperature is 22.312 degrees Celsius (we need to divide the reported value by 1000).


To convert from degrees Celsius to degrees Fahrenheit, multiply by 1.8, then add 32.

cd into each of the 28-xxxx directories in turn and run the cat w1_slave command to check that each is operating correctly. It may be useful at this stage to label the individual sensors with their unique serial numbers to make it easy to identify them correctly later.

4. Install the Influx database on the Raspberry Pi

a. Installing the Influx database is pretty simple. Please follow the instructions in this article.

b. Do not forget to start the Influxdb service on the Raspberry Pi by running this bash command in the terminal:

c. With InfluxDB installed, you are ready to start doing some great things. We will use the influx command line interface (CLI), which is included in all InfluxDB packages and is a lightweight and simple way to interact with the database. The CLI communicates with InfluxDB directly by making requests to the InfluxDB HTTP API over port 8086 by default.
The influx command should be available via the command line. Executing…

…in the Raspberry terminal will start the CLI and automatically connect to the local InfluxDB instance (assuming you have already started the server with service influxdb start or by running influxd directly). The output should look like this:

The command line is now ready to take input in the form of the Influx Query Language (a.k.a InfluxQL) statements. A fresh install of InfluxDB has no databases (apart from the system _internal), so creating one is our first task. You can create a database with the CREATE DATABASE InfluxQL statement, where is the name of the database you wish to create. Names of databases can contain any unicode character as long as the string is double-quoted. Names can also be left unquoted if they contain only ASCII letters, digits, or underscores and do not begin with a digit. Throughout this guide, we will use the database name temp_logger_db:

Now that the temp_logger_db database is created, we’ll use the SHOW DATABASES statement to display all existing databases:

The output will be something like this:

We have created a database and it is ready to be used in our temperature logger application. Exit the Influx shell by typing the command:

5. Install the Grafana server on the Raspberry Pi

a. Installing the Grafana realtime graph dashboard is pretty simple. Please follow the instructions in this article.
b. Please remember to start the Grafana server:

This will start the grafana-server process as the grafana user, which was created during the package installation. The default HTTP port is 3000 and default user and psw is “admin”.

To configure the Grafana server to start at boot time:

6. Install the required python libraries

We are using python3 in this datalogger example which have a slightly different syntax than the “retired” python2.
Like many Python libraries, the easiest way to get up and running is to install the library using pip.
We’re going to run pip using the -m argument to the Python command, in order to be sure which Python is the install target.

You should see some output indicating success.
You could display all your python3 stuff/libraries by running:

or run

when in the python shell.

7. Temperature logger python code

Save the script as ‘templogger.py’ and run using

To run the script in the background and indefinitely as a ssh user use:

Let us understand key points of the code listing above:

We import the InfluxDBClient class at the start of the program code.
We define two constants, one for the InfluxDB Host, which is the Public IP of your Compute Engine instance. Remember to replace it in the code.
The next statement is important. We initialize the InfluxDBClient with the hostname, port (8086 for the API) and provide it with the database name.
Now that we have the client object, we can then either query or insert database records.
The “write_points” method takes a list of measurement points and writes it to the Influx database. Each measurement point, specifies the measure,
one or more tags (test1 and runNo), and the four field values. Also notice that we are passing in the timestamp so that we record the timestamp from the board that it was recorded on. We use the `datetime` package in python to help us get the Unix timestamp that we will send to InfluxDB.
The result of the `write_points` method is of boolean type. It returns “true” if successful.

8. Configure the Grafana dashboard

While the templogger.py is running it is time to get the data from the influx database to show up as nice graphs in Grafana.

Unlike InfluxDB, Grafana doesn’t enable it’s service, so do this to enable at boot and start the service now:

Navigating your web browser to port 3000, you should be presented with the Grafana web GUI.
http://localhost:3000 or your raspberry IP: http://xx.xx.xx.xx:3000
Log in using psw: admin user:admin
Add datasource:
Under the data source selection window you have the option to select among a lot of different data source types. Select InfluxDb. The following data source configuration window should open:
Edit the input boxes as above example
Note! using http://localhost:8086 will not work. You should use your full raspberry ip address number e.g. “”.

The next task is to set up the grafana dashboard for our temperature logger.
From the grafana menu select + Create and then select dashboard.

This is how we have set up a basic dashboard that gives you a gauge and a graph for each of the 4 temperature readings that we are taking.

So by now hopefully you’ve got the project fully up and running, have accessed the dashboard and have been taking readings and filling up your database. Here are a few more things to take a look at before you move on to the next project.

What next?

The dashboard and reporting software, Grafana, has a lot of configuration options and settings for you to play with.
You can customize each panel on Grafana after you have logged in by hovering over the title and going to edit. I recommend having a play with the options – the changes to your dashboard are not saved automatically so if you make a mistake you can reload the page and everything will revert to how it was. If you make some changes you want to keep, hit save at the top of the dashboard and all of your settings will be saved to your device.
Thanks for reading!

Real Temp is a temperature monitoring program designed for all Intel single Core, Dual Core, Quad Core and Core i7 processors.
Each core on these processors has a digital thermal sensor (DTS) that reports temperature data relative to TJMax which is the safe maximum operating core temperature for the CPU. As your CPU heats up, your Distance to TJMax will decrease. If it reaches zero, your processor will start to thermal throttle or slow down so maximizing your distance away from TJMax will help your computer run at full speed and more reliably too.

Main Features

  • Reads temperature information from all Intel Core based processors. Pentium 4 processors are not supported.
  • Ability to individually calibrate Real Temp for each core of your CPU.
  • Program is based on temperature data gathered using a Fluke 62 IR Thermometer.
  • Test Sensors feature will check your DTS sensors for any sign of problems.
  • Keeps track of Minimum and Maximum temperatures with full logging features.
  • Reporting and logging of the Intel PROCHOT# thermal throttle activity bit.
  • Quick, very accurate and repeatable benchmark.
  • Displays MHz, TJMax, CPUID, APIC ID and Calibration settings.
  • High temperature alarm and shutdown feature based on CPU or NVIDIA GPU temperature.
  • No installation or registry modifications required.
  • Support for Windows 2000 / XP / Vista / Windows 7 / Windows 8 / Windows 10 (32 & 64 bit)





See the Installation & Calibration Page.

Cpu Temp History


The latest version is available in the downloads section.

Changes in Version 3.70

  • Support for Sandy Bridge CPUs.
  • VID based power consumption estimates for the newer CPUs.
  • Improved log file formatting.
  • Added a single system tray icon that reports the maximum core temperature.
  • RealTemp GT updated for the 6 core Sandy Bridge E CPUs.
  • i7 Turbo GT 1.30 multiplier monitoring tool.

Changes in Version 3.60

Cpu Temp Monitor Download

  • Added Core i Turbo multiplier and Turbo TDP/TDC overclocking for Extreme / K series CPUs.
  • Added ATI GPU and improved NVIDIA GPU monitoring with CrossFire and SLI support.
  • Added a system tray / notification area font selector.
  • New Fahrenheit and 3 digit system tray option.
  • Fixed Core 2 Extreme multiplier reporting.
  • Fixed Core 2 mobile CPU C0% based load reporting.
  • Changed how Core 2 Super Low Frequency Mode (SLFM) is reported.
  • Improved sensor test consistency.
  • Bug with Reset button on ATI systems fixed.
  • RealTemp GT for the 6 core Gulftown CPUs was also updated.
  • Separate i7 Turbo GT multiplier monitoring tool for 6 core Gulftown CPUs added.

Changes in Version 3.40

  • Core i7/i5/Xeon socket 1156 support including accurate turbo mode reporting.
  • new information window for Nvidia GPUs with improved SLI support.
  • correct reporting of Super Low Frequency Mode (SLFM) for Core 2 mobile CPUs.
  • correct reporting of Intel Dynamic Acceleration (IDA) for Core 2 mobile CPUs.
  • added VID reporting to the main GUI for Core 2 based CPUs.
  • added a Fahrenheit=1 INI file option.
  • added the option to view a Task Manager based or a C0% based load meter.
  • added the ability to toggle C1E state and view the SpeedStep (EIST) state.
  • improved dual and multi-monitor support including Anchor mode.
  • includes RealTemp GT, a 6 core version of RealTemp for Gulftown CPUs.
  • includes i7 Turbo, a high precision multiplier monitoring tool for all Core CPUs.
  • and includes LoadTester, a variable load, single core testing program.
  • Skull=1 or Skull=2 INI option for reading each CPU on a Dual Quad system.
  • thanks rge, burebista and somebody on TPU for all of your ideas and help.

Changes in Version 3.00

  • Core i7 temperature and frequency support including Turbo mode.
  • NVIDIA temperature reporting with highest GPU temperature displayed in SLI mode.
  • Ability to run a file or shutdown based on user defined alarm temperature.
  • Updated interface with modern XP / Vista style and border in Mini Mode.
  • Start Minimized Vista issues finally fixed.
  • New RivaTuner plug-in support.
  • Extra information on the main screen and the retirement of the toggle button.
  • Switch to UNICODE for better international support.
  • Adjustable GUI colors and bold System Tray font option.
  • TJMax updated based on new Intel documentation and further testing.
  • Calibration formula simplified.
  • All new CPU Cool Down Test for a more thorough look at your sensors.
  • Clock Modulation & Minimize on Close options.
  • New CPU Load meter, log file headings and Distance to TJMax in the System Tray.
  • 101 other improvements including initial Windows 7 Beta support.

Changes in Version 2.70

  • Redesigned user interface (GUI) with larger temperature fonts.
  • Added a movable Mini-Mode that is turned on and off with a double left mouse click on the GUI.
  • Added an Anchor position so the GUI will move to a fixed screen position after a double right mouse click.
  • Anchor position can be customized by holding down the Shift key while double right clicking.
  • The correct physical core order of Quad core processors is now reported based on APIC ID.
  • Added reporting of Minimum and Maximum VID as well as current VID.
  • A new user selectable high temperature alarm with two alarms for Quad core processors.
  • More accurate MHz calculation as well as FSB and CPU multiplier reporting.
  • New program Up Time feature.
  • Bug fix for log file output when using a Single or Dual core processor.
  • Fixed and improved the Default button in the Settings window.
  • Button labels and functionality changed in Settings window to follow the Windows style guide.
  • Improved multi-threading and memory usage for better long term stability.
  • Start Minimized option improved for better Vista support. See the documentation for more info.
  • Option to save the Log file in .CSV format for easy Excel support.
  • Gamer Mode temporarily retired.

Changes in Version 2.60

  • Added a new Settings screen where all adjustments can be made in real time including TjMax.
  • Temperatures of any core are now displayed in the System Tray area. Thanks W1zzard!
  • 4 font options for the System Tray.
  • Choice of Current, Minimum, Maximum or Average termperature displayed in the System Tray.
  • Test Sensors feature improved to increase repeatability.
  • CPU real time MHz calculation was re-worked for better SetFSB / ClockGen support.
  • Calibration options now include one digit after the decimal point for finer adjustments.
  • Experimental Gamer Mode introduced which allows core temperatures to be seen in some games.

Changes in Version 2.5

  • Added minimize to System Tray support.
  • Correctly reports CPU MHz for the new 45nm processors.
  • Displays CPU voltage identification (VID).
  • Start minimized option and now opens and closes in the same location.

Changes in Version 2.41

  • adjustable Idle calibration for each core and expanded range from -3 to 3.
  • adjustable TjMax for each core.
  • log interval options expanded from 1 to 60 seconds.
  • a change of timers used for the benchmark feature to better support overclocking from within Windows.
  • Reset button added to the gui to reset minimum and maximum temperatures.
  • better support of the Enter and Tab keys.