Energy Monitoring

Post Reply
chan
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

Unread post by chan » Fri Sep 05, 2014 10:30 am

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.
Attachments
getnode.cpp
(6.07 KiB) Downloaded 228 times
getnode.h
(1.76 KiB) Downloaded 193 times
main.cpp
(1.78 KiB) Downloaded 203 times
These users thanked the author chan for the post:
raditya160053 (Mon Jun 10, 2019 8:14 am)

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Fri Sep 05, 2014 12:25 pm

Thank for the great energy logger! ;)

jmawer
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

Unread post by jmawer » Thu Jan 08, 2015 1:24 am

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

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Thu Jan 08, 2015 1:40 am

I don't like the 9000Mhz either 9Ghz.. :o
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.

jmawer
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

Unread post by jmawer » Thu Jan 08, 2015 2:33 am

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

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Thu Jan 08, 2015 10:51 am

Okay... make sense.

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Thu Jan 08, 2015 1:45 pm

odroid wrote:I don't like the 9000Mhz either 9Ghz.. :o
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.
The 3 digits assinging is related to only GPU. So it seems not to be an issue.

jmawer
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

Unread post by jmawer » Thu Jan 08, 2015 7:33 pm

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

seungju.son
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

Unread post by seungju.son » Mon Feb 23, 2015 8:52 pm

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.

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Mon Feb 23, 2015 9:46 pm

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.

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Tue Feb 24, 2015 10:33 am

This!

Code: Select all

modprobe ina231-sensor

seungju.son
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

Unread post by seungju.son » Tue Feb 24, 2015 2:15 pm

Thanks, but it doesn't work.

The message is like
modprobe: FATAL: Module ina231-sensor not found.

I tried
modprobe ina231-sensors
modprobe i2c-isa
as well, but still not working.

seungju.son
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

Unread post by seungju.son » Tue Feb 24, 2015 2:57 pm

There are some directories which seems like i2c and INA231 drivers are installed.

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.

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Tue Feb 24, 2015 6:38 pm

Which OS image do you use?
Let me know the file name.

seungju.son
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

Unread post by seungju.son » Tue Feb 24, 2015 7:00 pm

I use Linux 3.10.63+

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Tue Feb 24, 2015 7:45 pm

Did you installed this image?
ubuntu-14.04.1lts-lubuntu-odroid-xu3-20150212.img

seungju.son
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

Unread post by seungju.son » Tue Feb 24, 2015 8:57 pm

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.

erik
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

Unread post by erik » Fri Feb 27, 2015 10:12 pm

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?

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Sat Feb 28, 2015 11:32 pm

@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.

seungju.son
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

Unread post by seungju.son » Mon Mar 02, 2015 2:26 pm

I tried your instructions, but it didn't work.


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?

seungju.son
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

Unread post by seungju.son » Mon Mar 02, 2015 2:30 pm

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.

User avatar
rooted
Posts: 6618
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 111 times
Been thanked: 25 times
Contact:

Re: Energy Monitoring

Unread post by rooted » Mon Mar 02, 2015 3:20 pm

The module must be compiled into the kernel.

seungju.son
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

Unread post by seungju.son » Mon Mar 02, 2015 3:29 pm

Now I know what was wrong.
(I was stupid... all my faults)

I had been doing

Code: Select all

sudo sensors
instead of

Code: Select all

sudo ./sensors
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).

erik
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

Unread post by erik » Mon Mar 02, 2015 4:10 pm

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!

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Mon Mar 02, 2015 4:15 pm

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

erik
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

Unread post by erik » Mon Mar 02, 2015 7:21 pm

OK. I see. Now, I updated it using ODROID-Utility. Before, I only updated the packages suggest by Ubuntu. Thanks!

seungju.son
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

Unread post by seungju.son » Fri Mar 13, 2015 7:54 pm

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.

saigomathi
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

Unread post by saigomathi » Sun Apr 07, 2019 5:31 am

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?

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Mon Apr 08, 2019 8:21 am

XU4 has no energy sensor on the board.

raditya160053
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

Unread post by raditya160053 » Tue May 21, 2019 2:35 am

I'm getting the following error message on running "sudo ./sensor"

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
Does anybody know why this might be happening? I'm using a xu3 board with ubuntu 18.04.

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Tue May 21, 2019 8:50 am

Check your dmesg output if your board was detected as XU3 or XU4?

raditya160053
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

Unread post by raditya160053 » Tue May 21, 2019 11:54 pm

odroid wrote:
Tue May 21, 2019 8:50 am
Check your dmesg output if your board was detected as XU3 or XU4?

dmesg output:
OF: fdt: Machine model: Hardkernel Odroid XU3

User avatar
odroid
Site Admin
Posts: 32146
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 297 times
Contact:

Re: Energy Monitoring

Unread post by odroid » Wed May 22, 2019 10:33 am

What is your current kernel version and Ubuntu version?
Could you run "sudo modprobe ina231-sensor"?

raditya160053
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

Unread post by raditya160053 » Thu May 23, 2019 8:59 am

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.

raditya160053
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

Unread post by raditya160053 » Thu Jun 13, 2019 3:01 am

odroid wrote:
Tue May 21, 2019 8:50 am
Check your dmesg output if your board was detected as XU3 or XU4?
I installed kernel 4.14 on an eMMC and tried it on XU3 and it's getting recognized as XU4

dmesg output:
[ 0.000000] OF: fdt: Machine model: Hardkernel Odroid XU4
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.

Thanks
Last edited by raditya160053 on Thu Jun 13, 2019 6:34 am, edited 1 time in total.

User avatar
mad_ady
Posts: 6545
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 168 times
Been thanked: 128 times
Contact:

Re: Energy Monitoring

Unread post by mad_ady » Thu Jun 13, 2019 3:55 am

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)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest