Energy Monitoring
-
- Posts: 2
- Joined: Fri Sep 05, 2014 9:51 am
- languages_spoken: english
- ODROIDs: XU+E, XU3
- Has thanked: 0
- Been thanked: 1 time
- Contact:
Energy Monitoring
There's a default application to monitor energy for XU3, and its sources are on https://github.com/hardkernel/EnergyMonitor. I needed to log monitoring data like XU+E script.
I wrote a simple c++ program using the given source. It shows data every 5 second in default.
Compile:
g++ main.cpp getnode.cpp -o sensors -std=c++11
Execute:
sudo sensors or sudo sensors 2
In /etc/rc.local
/usr/local/bin/sensors >> /var/log/sensors.log 2>&1
I hope this could be useful to someone.
I wrote a simple c++ program using the given source. It shows data every 5 second in default.
Compile:
g++ main.cpp getnode.cpp -o sensors -std=c++11
Execute:
sudo sensors or sudo sensors 2
In /etc/rc.local
/usr/local/bin/sensors >> /var/log/sensors.log 2>&1
I hope this could be useful to someone.
- Attachments
-
getnode.cpp
- (6.07 KiB) Downloaded 270 times
-
getnode.h
- (1.76 KiB) Downloaded 233 times
-
main.cpp
- (1.78 KiB) Downloaded 238 times
- These users thanked the author chan for the post:
- raditya160053 (Mon Jun 10, 2019 8:14 am)
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
-
- Posts: 8
- Joined: Mon Nov 03, 2014 8:54 pm
- languages_spoken: english
- ODROIDs: XUE
XU3 - Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
Hi
I believe there is a minor bug in git version of EnergyMonitor. When you read the CPU frequency on you only read the first 3 characters from the file and then make assumptions about the rest. This means that if the clock frequency is less than 1GHz displayed frequency is wrong. For example if I set frequency of CPU7 to 200MHz (by setting scaling_max_freq = 200,000) the Energy monitor still displays 2000MHz, it was a bit worrying when I set it to 900MHz and it said 9000MHz!
As an aside is there a reason that EnergyMonitor uses cpuinfo_cur_freq for current frequency (default only readable) rather than scaling_cur_freq? This means by default standard system users can't see the operating frequency of the CPUs is scaling_cur_freq invalid at some point e.g. if some feature is enabled?
Cheers
John
I believe there is a minor bug in git version of EnergyMonitor. When you read the CPU frequency on you only read the first 3 characters from the file and then make assumptions about the rest. This means that if the clock frequency is less than 1GHz displayed frequency is wrong. For example if I set frequency of CPU7 to 200MHz (by setting scaling_max_freq = 200,000) the Energy monitor still displays 2000MHz, it was a bit worrying when I set it to 900MHz and it said 9000MHz!
As an aside is there a reason that EnergyMonitor uses cpuinfo_cur_freq for current frequency (default only readable) rather than scaling_cur_freq? This means by default standard system users can't see the operating frequency of the CPUs is scaling_cur_freq invalid at some point e.g. if some feature is enabled?
Cheers
John
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
I don't like the 9000Mhz either 9Ghz.. 
We will fix the wrong 3 digits issue soon.
But I don't understand the difference between cpuinfo_cur_freq and scaling_cur_freq clearly.
Please help me to make sense.

We will fix the wrong 3 digits issue soon.
But I don't understand the difference between cpuinfo_cur_freq and scaling_cur_freq clearly.
Please help me to make sense.
-
- Posts: 8
- Joined: Mon Nov 03, 2014 8:54 pm
- languages_spoken: english
- ODROIDs: XUE
XU3 - Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
By default (as shipped)
/sys/devices/system/cpu/cpu<0-7>/cpufreq cpuinfo_cur_freq/cpuinfo_cur_freq has permissions 400 so only root can read
/sys/devices/system/cpu/cpu<0-7>/cpufreq cpuinfo_cur_freq/scaling_cur_freq has permissions 444 so anyone can read it
Energy monitor uses cpuinfo_cur_freq so if you are not root you can not see values for frequency. As far as I know the values should always be the same so it would make more sense to use the one which defaults to use world read but I'm not sure. Not a big deal just a thought gives a better user experience out of the box.
Thanks
John
/sys/devices/system/cpu/cpu<0-7>/cpufreq cpuinfo_cur_freq/cpuinfo_cur_freq has permissions 400 so only root can read
/sys/devices/system/cpu/cpu<0-7>/cpufreq cpuinfo_cur_freq/scaling_cur_freq has permissions 444 so anyone can read it
Energy monitor uses cpuinfo_cur_freq so if you are not root you can not see values for frequency. As far as I know the values should always be the same so it would make more sense to use the one which defaults to use world read but I'm not sure. Not a big deal just a thought gives a better user experience out of the box.
Thanks
John
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
The 3 digits assinging is related to only GPU. So it seems not to be an issue.odroid wrote:I don't like the 9000Mhz either 9Ghz..
We will fix the wrong 3 digits issue soon.
But I don't understand the difference between cpuinfo_cur_freq and scaling_cur_freq clearly.
Please help me to make sense.
-
- Posts: 8
- Joined: Mon Nov 03, 2014 8:54 pm
- languages_spoken: english
- ODROIDs: XUE
XU3 - Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
Sorry about that I was running the one I got on system install and reading the code in git as I use Qt5 and did't want to install Qt4 and wasn't reading carefully enough. mdjr actually fixed it on his August14 commit
by reading 8 characters instead of 5 from the file. I installed Qt4-dev built and all is fine

-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
At first, thank you for sharing your logging code.
I downloaded and compiled the source but it did't work.
The message said
"No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are."
Then I tried the command 'sensors-detect', but no sensors were detected.
I also tried installing lm-sensors.
What should I do for next?
I am using ODROID XU3, by the way.
I downloaded and compiled the source but it did't work.
The message said
"No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are."
Then I tried the command 'sensors-detect', but no sensors were detected.
I also tried installing lm-sensors.
What should I do for next?
I am using ODROID XU3, by the way.
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
You need to do "modprobe" a driver module of INA231 energy sensor.
I will let you know the module name tomorrow because it's already 10:00 PM in Korea.
I will let you know the module name tomorrow because it's already 10:00 PM in Korea.
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
Thanks, but it doesn't work.
The message is like
I tried
The message is like
modprobe: FATAL: Module ina231-sensor not found.
I tried
as well, but still not working.modprobe ina231-sensors
modprobe i2c-isa
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
There are some directories which seems like i2c and INA231 drivers are installed.
but with lsmod command
nothing.
Code: Select all
odroid@odroid:/sys/bus/i2c/drivers/INA231/3-0041/driver$ ls -al
total 0
drwxr-xr-x 2 root root 0 Feb 24 15:53 .
drwxr-xr-x 10 root root 0 Feb 24 15:53 ..
lrwxrwxrwx 1 root root 0 Feb 24 16:20 3-0041 -> ../../../../devices/12c60000.i2c/i2c-3/3-0041
lrwxrwxrwx 1 root root 0 Feb 24 16:20 3-0044 -> ../../../../devices/12c60000.i2c/i2c-3/3-0044
lrwxrwxrwx 1 root root 0 Feb 24 16:20 3-0045 -> ../../../../devices/12c60000.i2c/i2c-3/3-0045
--w------- 1 root root 4096 Feb 24 16:20 bind
--w------- 1 root root 4096 Feb 24 16:20 uevent
--w------- 1 root root 4096 Feb 24 16:20 unbind
but with lsmod command
Code: Select all
odroid@odroid:/sys/bus/i2c/drivers/INA231/3-0041/driver$ lsmod
Module Size Used by
8192cu 531585 0
hid_apple 5674 0
rfcomm 33046 0
bnep 10854 2
bluetooth 228012 10 bnep,rfcomm
rfkill 12820 3 bluetooth
fuse 74749 2
nls_cp437 5128 1
vfat 9563 1
fat 54008 1 vfat
nothing.
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
Did you installed this image?
ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img
ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I don't remember which file exactly I use but the Kernel is earlier than 20150212 version.
I installed the OS on an eMMC card and boot with it.
I installed the OS on an eMMC card and boot with it.
-
- Posts: 12
- Joined: Thu Jan 29, 2015 1:12 am
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I also have trouble running it. I get the following error: /dev/sensor_armOpen FailOpenINA231
It used to work. Maybe it has something to do that I yesterday installed suggested updates?
It used to work. Maybe it has something to do that I yesterday installed suggested updates?
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
@erik
Do you use this image?
ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img
If you use it, you should find the "ina231-sensor" in the result of "lsmod".
Anyway, follow this instruction and let me know the result.
1. add the ina231-sensor in the blacklist (/etc/modprobe.d/blacklist )
2. after rebooting, check the ina231-sensor from the "lsmod" command.
3. modprobe ina231-sensor and run the monitor program.
Do you use this image?
ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img
If you use it, you should find the "ina231-sensor" in the result of "lsmod".
Anyway, follow this instruction and let me know the result.
1. add the ina231-sensor in the blacklist (/etc/modprobe.d/blacklist )
2. after rebooting, check the ina231-sensor from the "lsmod" command.
3. modprobe ina231-sensor and run the monitor program.
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I tried your instructions, but it didn't work.
when I do "lsmod", the result is as follows.
Do you think the previous version of kernel causes the problem?
when I do "lsmod", the result is as follows.
Code: Select all
odroid@odroid:~$ lsmod
Module Size Used by
8192cu 531585 0
rfcomm 33046 0
bnep 10854 2
bluetooth 228012 10 bnep,rfcomm
rfkill 12820 3 bluetooth
fuse 74749 2
nls_cp437 5128 1
vfat 9563 1
fat 54008 1 vfat
Do you think the previous version of kernel causes the problem?
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
omg
There is no 'ina231-sensor' in the result of 'lsmod', but the sensor logging binary works!!!
I don't understand how it was fixed.
There is no 'ina231-sensor' in the result of 'lsmod', but the sensor logging binary works!!!
I don't understand how it was fixed.
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
Now I know what was wrong.
(I was stupid... all my faults)
I had been doing
instead of
There is generally used command 'sensors' , and the binary name is same with the command.
but I still have question.
when logging, A7_W and MEM_W data seems like converted.
Those logging data is different with monitoring data(display version).
(I was stupid... all my faults)
I had been doing
Code: Select all
sudo sensors
Code: Select all
sudo ./sensors
but I still have question.
when logging, A7_W and MEM_W data seems like converted.
Those logging data is different with monitoring data(display version).
-
- Posts: 12
- Joined: Thu Jan 29, 2015 1:12 am
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I use the the preinstalled Ubuntu and then I have been installing the suggested updates regularly. Now I have: Ubuntu 14.04.2 LTS (GNU/Linux 3.10.54+ armv7l)
I don't know why I got the error. After restarting the device I no longer get the error. However, lsmod shows the following
Module Size Used by
rfcomm 32722 0
bnep 10882 2
joydev 9066 0
bluetooth 226463 10 bnep,rfcomm
rfkill 12917 2 bluetooth
fuse 75320 2
nls_cp437 5132 1
vfat 9526 1
fat 54089 1 vfat
Thanks for your help!
I don't know why I got the error. After restarting the device I no longer get the error. However, lsmod shows the following
Module Size Used by
rfcomm 32722 0
bnep 10882 2
joydev 9066 0
bluetooth 226463 10 bnep,rfcomm
rfkill 12917 2 bluetooth
fuse 75320 2
nls_cp437 5132 1
vfat 9526 1
fat 54089 1 vfat
Thanks for your help!
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
The latest kernel should be 3.10.69 if you ran Kernel update via ODROID-Utility.
Code: Select all
#uname –a
Linux odroid 3.10.69 #1 SMP PREEMPT Thu Feb 12 15:22:14 BRST 2015 armv7l armv7l armv7l GNU/Linux
-
- Posts: 12
- Joined: Thu Jan 29, 2015 1:12 am
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
OK. I see. Now, I updated it using ODROID-Utility. Before, I only updated the packages suggest by Ubuntu. Thanks!
-
- Posts: 9
- Joined: Mon Feb 23, 2015 8:45 pm
- languages_spoken: english
- ODROIDs: XU3
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I have another question about power sensor frequency.
I am using the logging code and modified time interval by using usleep instead of sleep.
It seems like the power sensor value is updated 4 time in a second(4Hz), and the unit is Watt.
Is the logged value representing power in 250ms? or 1sec?
I wonder if I get mean value of 4 logged value for real power value in one second.
I am using the logging code and modified time interval by using usleep instead of sleep.
It seems like the power sensor value is updated 4 time in a second(4Hz), and the unit is Watt.
Is the logged value representing power in 250ms? or 1sec?
I wonder if I get mean value of 4 logged value for real power value in one second.
-
- Posts: 1
- Joined: Sun Apr 07, 2019 4:29 am
- languages_spoken: english
- ODROIDs: odroid XU4 computing board
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: Energy Monitoring
Hi odroid i am using odroid xu4 SCB. is it possible to allocate workloads to per-core basis and also is it possible to measure energy after each task execution?
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
-
- Posts: 10
- Joined: Wed May 15, 2019 7:02 am
- languages_spoken: english
- ODROIDs: Odroid XU4, SmartPower2
- Has thanked: 3 times
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I'm getting the following error message on running "sudo ./sensor"
Does anybody know why this might be happening? I'm using a xu3 board with ubuntu 18.04.
Code: Select all
Time|CPU0_Freq(MHz)|CPU1_Freq|CPU2_Freq|CPU3_Freq|CPU4_Freq|CPU5_Freq|CPU6_Freq|CPU7_Freq|GPU_Freq|CPU0_Temp(C)|CPU1_Temp|CPU2_Temp|CPU3_Temp|GPU_Temp|A7_W|A15W|MEM_W|GPU_W|Watt_Sum
This loops forever until press <Ctrl-C>!
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
[1] 1939 abort sudo ./sensors
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
-
- Posts: 10
- Joined: Wed May 15, 2019 7:02 am
- languages_spoken: english
- ODROIDs: Odroid XU4, SmartPower2
- Has thanked: 3 times
- Been thanked: 0
- Contact:
- odroid
- Site Admin
- Posts: 36509
- Joined: Fri Feb 22, 2013 11:14 pm
- languages_spoken: English, Korean
- ODROIDs: ODROID
- Has thanked: 1465 times
- Been thanked: 996 times
- Contact:
Re: Energy Monitoring
What is your current kernel version and Ubuntu version?
Could you run "sudo modprobe ina231-sensor"?
Could you run "sudo modprobe ina231-sensor"?
-
- Posts: 10
- Joined: Wed May 15, 2019 7:02 am
- languages_spoken: english
- ODROIDs: Odroid XU4, SmartPower2
- Has thanked: 3 times
- Been thanked: 0
- Contact:
Re: Energy Monitoring
uname -a:
Linux odroid 4.14.85-152 #1 SMP PREEMPT Mon Dec 3 03:00:02 -02 2018 armv7l armv7l armv7l GNU/Linux
Ubuntu 18.04
I did run the modprobe command, threw no errors and no output.
This is on a micro-sd card, When I use the emmc that comes with the board the above code works just fine.
Linux odroid 4.14.85-152 #1 SMP PREEMPT Mon Dec 3 03:00:02 -02 2018 armv7l armv7l armv7l GNU/Linux
Ubuntu 18.04
I did run the modprobe command, threw no errors and no output.
This is on a micro-sd card, When I use the emmc that comes with the board the above code works just fine.
-
- Posts: 10
- Joined: Wed May 15, 2019 7:02 am
- languages_spoken: english
- ODROIDs: Odroid XU4, SmartPower2
- Has thanked: 3 times
- Been thanked: 0
- Contact:
Re: Energy Monitoring
I installed kernel 4.14 on an eMMC and tried it on XU3 and it's getting recognized as XU4
dmesg output:
Is there a way to fix this? I'm trying to use the sensors on XU3, but if it gets recognized as XU4, I can't do that.[ 0.000000] OF: fdt: Machine model: Hardkernel Odroid XU4
Thanks
Last edited by raditya160053 on Thu Jun 13, 2019 6:34 am, edited 1 time in total.
-
- Posts: 9108
- Joined: Wed Jul 15, 2015 5:00 pm
- languages_spoken: english
- ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
- Location: Bucharest, Romania
- Has thanked: 598 times
- Been thanked: 585 times
- Contact:
Re: Energy Monitoring
You can change boot.ini and force loading of the xu3 dtb, instead of relying on autodetection.
- These users thanked the author mad_ady for the post:
- raditya160053 (Thu Jun 13, 2019 8:03 am)
Who is online
Users browsing this forum: No registered users and 3 guests