1

how to show the

CPU temperature, CPU usage (percentage) and the memory usage(percentage)

in Arduino Serial Monitor.

2
  • 1
    an Arduino does not have a CPU
    – jsotola
    Jan 1, 2019 at 9:15
  • 2
    @jsotola Yes it does.
    – Majenko
    Jan 1, 2019 at 10:49

1 Answer 1

6

CPU temperature

Some Arduino boards have a microcontroller with a temperature sensor inside. For example the Arduino Uno can measure the temperature inside the microcontroller.

As far as I know, no one uses it. It is not accurate and a microcontroller should not get hot in the first place. The microcontroller or processor on the Arduino board can run at 100% load and it does not get hot.
The internal temperature sensor is not accurate enough to measure the ambient temperature.
The internal temperature is therefore (almost) useless.

See this page on the Arduino Playground and this forum thread for the internal temperature sensor.

CPU usage

There is no CPU usage. There is no idle task. The microcontroller or processor usually runs all the time at full speed.

It is possible to determine how long the Arduino board stays in delays (via the yield function).
With a external RTC clock it is possible to determine how long the Arduino board stays in sleep mode (some battery powered Arduino projects use the sleep mode).
However, those are very specific things. Perhaps a project requires to measure them, but there is no common use for them.

A good sketch is not supposed to do nothing, it is supposed to check all the inputs and check millis-timers and act if needed. The Arduino loop() function is supposed to run as often as possible to make the Arduino run fast and smooth.

Memory usage

The memory usage is something to be aware of when writing a sketch. An Arduino board has much less memory than a typical computer.

It is possible to determine the unused memory between the stack and the heap.
The function at the bottom of this page can be used to determine the amount of free memory.

I have also seen code to measure the high water mark (memory that is never used at all), but none of them work for all Arduino boards and the code is not reliable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.