Example on how to access Sensors on XU+E

Post Reply
mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Example on how to access Sensors on XU+E

Unread post by mdrjr » Fri Aug 30, 2013 6:05 am

Attached is a very simple shell script to provide example on how to access the sensors on ODROID-XU+E

It will produce the same output as ANDROID.

Code: Select all

CPU0: 250 Mhz, 47C
CPU1: 250 Mhz, 44C
CPU2: 250 Mhz, 49C
CPU3: 250 Mhz, 47C
Governor: ondemand
Fan Speed: 0%
A15 Power: 0.908750V, 0.009864A, 0.008172W
A7 Power: 0.896250V, 0.013725A, 0.011648W
MEM Power: 1.196250V, 0.161707A, 0.192556W
GPU Power: 0.941250V, 0.004712A, 0.003764W @ 350 Mhz
Attachments

[The extension sh has been deactivated and can no longer be displayed.]


ericvh
Posts: 11
Joined: Sun Sep 15, 2013 9:47 am
languages_spoken: english
ODROIDs: ODROID-X2 and ODROID-XUE
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by ericvh » Mon Sep 16, 2013 8:21 am

I'm getting lots of zero values on my XU+E:./sensors_example.sh
CPU0: 250 Mhz, 42C
CPU1: 250 Mhz, 42C
CPU2: 250 Mhz, 46C
CPU3: 250 Mhz, 45C
Governor: ondemand
Fan Speed: 0%
A15 Power: 0.000000V, 0.000000A, 0.000000W
A7 Power: 0.000000V, 0.000000A, 0.000000W
MEM Power: 0.000000V, 0.000000A, 0.000000W
...
This is with:
Linux (none) 3.4.5 #1 SMP PREEMPT Fri Sep 13 14:38:12 BRT 2013 armv7l armv7l armv7l GNU/Linux

Wondering if I'm missing kernel config or something to enable the actual power measurement...

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Mon Sep 16, 2013 9:21 am

ericvh,

We did some changes on the kernel.. I'm updating the thread with another version of this scripts that works :)

jcebrian
Posts: 11
Joined: Fri Sep 20, 2013 9:34 pm
languages_spoken: english
ODROIDs: ODROID-XU+e
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jcebrian » Fri Sep 20, 2013 9:41 pm

Hi.

One quick question. Is there any way to get a continuous reading instead of a discrete reading from the sensors?.

Let me explain. As I see this, if you are running a 4-thread application and you use this script to get power readings, you will be reading the power of 3 cores running your application, but one of them will be reading the power of the script that is reading the power. Can you get some "energy" reading at an specific section of your code and another one later on so that you just substract them and get the actual energy that was burned? (similar to Intel RAPL MSRs).

Jm.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Sat Sep 21, 2013 10:46 am

I doubt that the transaction between threads is faster them the script.

jcebrian
Posts: 11
Joined: Fri Sep 20, 2013 9:34 pm
languages_spoken: english
ODROIDs: ODROID-XU+e
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jcebrian » Mon Sep 23, 2013 6:06 pm

But the script is running on one of the cores right?....when the OS gives control to the script it kicks out my application from the core, thus the power reading is not from my application, but from the script itself. Anyways, there is no energy info that can be retrieved from the PMIC?.

PD: Maybe the delay of the PMIC is enought to hide the context switch between the application and the script, not sure about this.

Jm.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Tue Sep 24, 2013 2:56 am

PMIC doesn't have any power usage data..

Unless you implement that in kernel level witch will happen the same.. since its a "kernel process" and it will concur with your application as well.

User avatar
Matt
Posts: 576
Joined: Tue Feb 26, 2013 4:57 pm
languages_spoken: English
ODROIDs: X2, U2, XU+E rev.2, Smart Power
Location: Charlottesville, VA, USA
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by Matt » Tue Sep 24, 2013 6:46 am

This doesn't give you the power used to run your app, it gives you the power being drawn by the two CPU clusters, the memory, and the GPU at the time you probed the kernel for those values. These readings give you the amount of power being used by those discrete units in the process of running your app, anything in the background, and the OS all together. The act of running this rather small script (which is nothing more than `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`, just with 11 different files) doesn't amount to anything more than standard Linux kernel background noise when it comes to processor power... since really all you're doing is asking the kernel something it already knows, anyway.
ODROID Boards: U2, X2, XU+E rev.2
Accessories: VU, Smart Power, 13" LCD Kit (for the X2)

jcebrian
Posts: 11
Joined: Fri Sep 20, 2013 9:34 pm
languages_spoken: english
ODROIDs: ODROID-XU+e
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jcebrian » Tue Sep 24, 2013 8:02 pm

I realize that the power is for the 4 INA 231 power monitors (http://www.ti.com/product/ina231). But, as you say, power is discrete. They will provide the power of whatever is running at that specific moment in time, that is, you "cat /sys...". It cannot account for background noise from the kernel since the A15 cores, as far as I know, are not SMT, so you only have 1 thread feeding instructions to the pipeline. The only way to get that you suggest is to have an ENERGY (POWERxTIME) counter, you read at the beginning, you read at the end, and the difference is your app energy + background.

The question remains the same, is the delay between the INA 231 monitors and the kernel readings long enough so that the readings are from something more than the "cat command" or are we just reading the power for the retrieval script on whatever core is running it?.

janrinze
Posts: 76
Joined: Thu Sep 19, 2013 4:31 am
languages_spoken: english
ODROIDs: ODROID-XU-E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by janrinze » Tue Sep 24, 2013 10:18 pm

using a low pass filter on the measuring device should enable it to read more accurately the general power consumption.
Usually the shunt is measured directly thus providing a snapshot of the power at that precise time. With a RC circuit it should be possible to get a more even measurement.

janrinze
Posts: 76
Joined: Thu Sep 19, 2013 4:31 am
languages_spoken: english
ODROIDs: ODROID-XU-E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by janrinze » Wed Sep 25, 2013 11:06 pm

when the XU is running at 1.8 GHz the script starts failing. Perhaps we need some of the I2C related bugfixes?

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Thu Sep 26, 2013 12:48 am

Logs?

ericvh
Posts: 11
Joined: Sun Sep 15, 2013 9:47 am
languages_spoken: english
ODROIDs: ODROID-X2 and ODROID-XUE
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by ericvh » Thu Sep 26, 2013 11:43 pm

I've yet to even push it past 1.6, even with cpufreq-set it doesn't seem to ever want to go above that...

micrel.odroid
Posts: 15
Joined: Thu Oct 10, 2013 2:33 am
languages_spoken: english italian
ODROIDs: ODROID-XU+E ODROID-XU3
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by micrel.odroid » Fri Oct 25, 2013 1:35 am

Hi all,
is it possible to extend the script with the information relative to each core load?

Thank you

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Fri Oct 25, 2013 4:21 am

micrel.odroid wrote:Hi all,
is it possible to extend the script with the information relative to each core load?

Thank you
Yep... you can take a look on /proc/stat to do the math.

armendzh
Posts: 23
Joined: Mon Sep 16, 2013 11:05 am
languages_spoken: English, Russian, Spanish
ODROIDs: ODROID-U2, ODROID-XU+E, ODROID-XU3
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by armendzh » Wed Oct 30, 2013 9:06 am

How frequency can I read data from sensors? Is this something that is controlled by kernel?

Right now, if I am reading just data for A15, I have about 100 samples per second. If I am reading data for A15, A7, GPU and MEM, I am getting about 32 samples per second. If I am reading everything from Linux script (frequency, power, current.. etc), I am getting about 10 samples per second.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Wed Oct 30, 2013 12:22 pm

not actually sure..
since theres one sensor for each block..

unless the i2c is limiting...

you can try pooling directly from the kernel..
on drivers/hardkernel you'll find the drivers ;)

User avatar
Matt
Posts: 576
Joined: Tue Feb 26, 2013 4:57 pm
languages_spoken: English
ODROIDs: X2, U2, XU+E rev.2, Smart Power
Location: Charlottesville, VA, USA
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by Matt » Thu Oct 31, 2013 2:21 pm

I saw in another thread that all four INA231 (power) sensors are on the same I2C bus, so you might get different sample rates if you are sampling a different number of the sensors. The temperature sensors probably depend on some other bus, but I could be wrong. The CPU frequency readings shouldn't affect the sample rate at all, since they are just being read from memory.

I'd be interested in seeing what sample rate you get from different numbers of temperature sensors to see if they bottleneck the same way the power sensors do. Maybe they bottleneck in sample rate worse than the power sensors do, or maybe they contribute to the issue when added to the power sensors as you suspect.
ODROID Boards: U2, X2, XU+E rev.2
Accessories: VU, Smart Power, 13" LCD Kit (for the X2)

jcebrian
Posts: 11
Joined: Fri Sep 20, 2013 9:34 pm
languages_spoken: english
ODROIDs: ODROID-XU+e
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jcebrian » Thu Oct 31, 2013 6:20 pm

File /sys/bus/i2c/drivers/INA231/4-00XX/update_period contains the update interval for the sensor. By default is 263808 useconds. This seems to be controlled by arch/arm/mach-exynos/board-odroidxu-power.c in the Kernel source
in structures sensor_arm, sensor_mem, sensor_kfc, sensor_g3d. Instead of increasing the sampling rate that may cause some overhead on your execution, you can try to increase the update period of the sensor to something that matches your sampling rate. Since the sensors internally accumulate and average the energy over time to give you a power reading, this should give you a better power reading that just reading the average power of the last 0.2 seconds many times.

dragao-azul
Posts: 14
Joined: Sun Nov 03, 2013 10:25 am
languages_spoken: english
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by dragao-azul » Mon Nov 04, 2013 9:01 pm

Hello,

While taking a look at the script I noticed this:

Code: Select all

# Node Configuration for CPU Frequency
CPU0_FREQ=$((`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq`/1000))" Mhz"
CPU1_FREQ=$((`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq`/1000))" Mhz"
CPU2_FREQ=$((`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq`/1000))" Mhz"
CPU3_FREQ=$((`cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq`/1000))" Mhz"
Aren't we always reading the same cpu for 1,2 and 3? I do get different values, but can't that be related to frequency changes between readings?

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Mon Nov 04, 2013 9:14 pm

you are right! i've updated the script.. thanks for the heads up.

caogao
Posts: 14
Joined: Tue Oct 22, 2013 2:00 am
languages_spoken: english
ODROIDs: ODROID XU4, XU3, XU+E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by caogao » Sat Nov 09, 2013 10:23 am

For the power number, is it the total of all four cores or just for every single core?
Thanks.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Sat Nov 09, 2013 11:14 am

Total of 4 cores.

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Wed Nov 13, 2013 3:29 pm

Thanks for the script, useful in creating the graphic version :D
http://elhokar.zapto.org/temperature/
I only record the temperature, fan speed and power consumption, but it would be so easy to add the other readings as well...

I am calculating the RPM as/sys/bus/platform/devices/odroidxu-fan/pwm_duty * 6000 / 255 -> am I right to assume that the max speed of the fan (255) is 6000RPM ?

Thanks.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Wed Nov 13, 2013 3:44 pm

Ehhhh.. I don't know the fan max speed on U2...
odroid will probably answer this one :)

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Wed Nov 13, 2013 4:51 pm

For U2 it's on the website: 4000
I am looking for XU :)

User avatar
odroid
Site Admin
Posts: 29750
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by odroid » Wed Nov 13, 2013 5:54 pm

I don't know the maximum RPM of XU's fan.
I will contact the manufacturer.

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Wed Nov 13, 2013 7:40 pm

Thank you :D

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Thu Nov 14, 2013 1:10 pm

Is there a way of getting the total power consumption or an approximate, w/o the power accessory?
Currently, on the XU+E, you have CPU consumption, GPU and memory from the sensors. I think the big unknown would then be USB ports, maybe fan... what else would have a big impact?

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Thu Nov 14, 2013 1:13 pm

MFC/Gscaler/.... list goes on... only with the smartpower to get the total value

User avatar
odroid
Site Admin
Posts: 29750
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by odroid » Fri Nov 15, 2013 2:52 pm

Here is a brief specification of the fan.

Dimension: 38x10mm
Bearing Type: Sleeve bearing
Rated Voltage: DC 5V
Operating Voltage: DC 3-7V
Start-up Voltage: <3V
Real current: 0.19A-0.2A
Real power:1W
Rated speed 4500rpm/min
Install hole: 55mm
Connecter: 2.0 2pin plug
Lead wires :Red(+), Black(-) L= 70±5mm, 2wires

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Fri Nov 15, 2013 3:21 pm

Thank you

ilham
Posts: 23
Joined: Mon Oct 28, 2013 6:35 pm
languages_spoken: English, Turkish
ODROIDs: XU
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by ilham » Sun Mar 23, 2014 6:08 am

I get this error on each update:

Code: Select all

cat: /sys/bus/i2c/drivers/INA231/4-0045/sensor_V: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0045/sensor_A: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0045/sensor_W: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0040/sensor_V: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0040/sensor_A: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0040/sensor_W: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0041/sensor_V: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0041/sensor_A: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0041/sensor_W: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0044/sensor_V: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0044/sensor_A: No such file or directory
cat: /sys/bus/i2c/drivers/INA231/4-0044/sensor_W: No such file or directory
CPU0: 250 Mhz, 47C
CPU1: 250 Mhz, 31C
CPU2: 800 Mhz, 50C
CPU3: 800 Mhz, 48C
Governor: interactive
Fan Speed: 0%
A15 Power: V, A, W
A7 Power: V, A, W
MEM Power: V, A, W
GPU Power: V, A, W @ 350 Mhz

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Sun Mar 23, 2014 6:36 am

Do you have a XU+E ?
What's the color of the sticker on top of the ethernet connector?

ilham
Posts: 23
Joined: Mon Oct 28, 2013 6:35 pm
languages_spoken: English, Turkish
ODROIDs: XU
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by ilham » Thu Mar 27, 2014 12:53 am

No, it's straight XU. Maybe noteworthy, i've done nothing about i2c so far.

I did a kernel update today following the instructions here: http://forum.odroid.com/viewtopic.php?f=61&t=1516
Now it's 3.4.75 and OS is Xubuntu 13.10 http://forum.odroid.com/viewtopic.php?f=61&t=1983

Still getting the same output (not sure if it's a error)

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Thu Mar 27, 2014 2:05 am

Those sensors are ONLY available on XU+E.

adonp
Posts: 5
Joined: Mon Mar 24, 2014 6:05 pm
languages_spoken: english
ODROIDs: ODROID XU+E REV0.3-20130717
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by adonp » Thu Mar 27, 2014 11:45 pm

Hi,

I would like to access the power sensors through a user-space program (in C). Is it possible to access them through a mmap function? or i2c-dev interface?
Last edited by adonp on Fri Mar 28, 2014 5:35 am, edited 1 time in total.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Fri Mar 28, 2014 2:19 am

adonp wrote:Hi,

I would like to access the power sensors through a use-space program (in C). Is it possible to access them through a mmap function? or i2c-dev interface?
Yes, but I don't have any example for you.

User avatar
memeka
Posts: 4172
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by memeka » Fri Mar 28, 2014 7:44 am

you can always read the contents of the sysfs files (in C)
though i guess this will be slower than mmap. for mmap i'm not sure the address is published anywhere... maybe you need to look in the kernel sources?

jsubirat
Posts: 39
Joined: Mon Oct 28, 2013 8:57 pm
languages_spoken: english, catalan, spanish
ODROIDs: ODROID-XU+E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jsubirat » Fri Mar 28, 2014 7:56 pm

@mdrjr, could you please tell me what kernel option should I enable when compiling a custom kernel, in order to have this sensor available? I'm compiling kernel 3.13.0+. I searched in the kernel configuration, and the most similar option I found is CONFIG_SENSORS_INA2XX=y (as the device is named INA231 under /sys/bus/i2c/drivers), but it was not the one. Could you tell me which options to enable to get it working? Many thanks.

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Fri Mar 28, 2014 8:03 pm

jsubirat wrote:@mdrjr, could you please tell me what kernel option should I enable when compiling a custom kernel, in order to have this sensor available? I'm compiling kernel 3.13.0+. I searched in the kernel configuration, and the most similar option I found is CONFIG_SENSORS_INA2XX=y (as the device is named INA231 under /sys/bus/i2c/drivers), but it was not the one. Could you tell me which options to enable to get it working? Many thanks.
Doesn't work yet on 3.13

adonp
Posts: 5
Joined: Mon Mar 24, 2014 6:05 pm
languages_spoken: english
ODROIDs: ODROID XU+E REV0.3-20130717
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by adonp » Fri Apr 04, 2014 6:33 pm

memeka wrote:you can always read the contents of the sysfs files (in C)
though i guess this will be slower than mmap. for mmap i'm not sure the address is published anywhere... maybe you need to look in the kernel sources?
Hi memeka. thanks for your response. I've tried using mmap and i2c-dev interface. I just want to read/write the configuration register of ina231 in order to use more averaging samples. I looked to the source code and saw that the averaging sampes are set to 16. However they can set up to 1024 according to ina231 datasheet. In particular, the configuration ina231 register value set by the kernel, is 0x46FF. This is my only reference in order to check if I am accessing corectly through userspace the device. Below are my attempts:
mmap: I used mmap to map the device files (such as ../ina231/sensor_W) with no result. Also I mmaped the physical adresses of 12c60000 (s3c2440-i2c.0), 12c70000(s3c2440-i2c.1),12c80000( s3c2440-i2c.2),12ca0000(exynos5-hs-i2c.0) but I couldn't found any "0x46FF" value. Maybe I am doing it with the wrong way as it is like looking i2c bus's transactions instead of device's register values.
ioctl: I made an ioctl using 0x40,0x41,0x41,0x45 as device numbers and /dev/i2c-4 as file descriptor, and "I2C_SLAVE" as i2c's slave adress and fails.
I use prebuilt kernel 3.4.75 ubuntu

jsubirat
Posts: 39
Joined: Mon Oct 28, 2013 8:57 pm
languages_spoken: english, catalan, spanish
ODROIDs: ODROID-XU+E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by jsubirat » Thu Apr 24, 2014 2:15 am

Hi guys. First of all, many thanks to mdrjr for having added the ina2xx support in the 3.13.7+ kernel. I adapted the script provided at the beginning of the post to read the power sensor values using this kernel version in a XU+E. I also used http://lxr.free-electrons.com/source/dr ... n/ina2xx.c as a reference. I attach the script in case it's useful for anyone. Please, let me know if there's anything incorrect. My understanding is that the units are uA for current, uV for voltage and uW for power, right?
Attachments

[The extension sh has been deactivated and can no longer be displayed.]


mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by mdrjr » Thu Apr 24, 2014 3:23 am

Great :)

pedro.velho
Posts: 1
Joined: Thu Jun 26, 2014 12:39 am
languages_spoken: english
ODROIDs: ODROID-XU+E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by pedro.velho » Thu Jun 26, 2014 2:37 am

The script is gone! I was reading it last night on my girlsfriend's computer and today trying to fetch I get a file not found. Could you please put it back on-line?

Cheers,
Pedro

User avatar
odroid
Site Admin
Posts: 29750
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by odroid » Thu Jun 26, 2014 11:10 am

pedro.velho wrote:The script is gone! I was reading it last night on my girlsfriend's computer and today trying to fetch I get a file not found. Could you please put it back on-line?
All the attached files in this forum is not working at this moment.
We are managing the forum DB storage now. It may take 24 hours.

User avatar
odroid
Site Admin
Posts: 29750
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by odroid » Thu Jun 26, 2014 2:27 pm

You can access the attached files now.

grsingla
Posts: 60
Joined: Sat Dec 28, 2013 3:53 am
languages_spoken: english
ODROIDs: odroid XU+E
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by grsingla » Thu Feb 19, 2015 8:50 am

jcebrian wrote: File /sys/bus/i2c/drivers/INA231/4-00XX/update_period contains the update interval for the sensor. By default is 263808 useconds. This seems to be controlled by arch/arm/mach-exynos/board-odroidxu-power.c in the Kernel source
in structures sensor_arm, sensor_mem, sensor_kfc, sensor_g3d. Instead of increasing the sampling rate that may cause some overhead on your execution, you can try to increase the update period of the sensor to something that matches your sampling rate. Since the sensors internally accumulate and average the energy over time to give you a power reading, this should give you a better power reading that just reading the average power of the last 0.2 seconds many times.
I am trying to change the update rate on OdroidXU3, but it seems in this kernel, the path for board-odroidxu3-power.c has changed. Can you please tell where can we change the update rate for sensors in OdroidXU3.

vpras
Posts: 3
Joined: Mon Mar 28, 2016 10:44 am
languages_spoken: english
ODROIDs: Odroid-XU4, Weather board
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by vpras » Mon Mar 28, 2016 10:51 am

Sorry to re-open this old post.

I am trying to connect a gas sensor : http://www.sainsmart.com/sainsmart-mq13 ... ry-pi.html
to an Odroid-XU4. Has anyone connected such a sensor to the XU4?

I plan on recording the readings and log them for further usage.

Thanks in advance :)
Pras

User avatar
odroid
Site Admin
Posts: 29750
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Example on how to access Sensors on XU+E

Unread post by odroid » Mon Mar 28, 2016 2:12 pm

@vpras,

Open a new thread on the XU4 sub-forum.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 20 guests