PDA

Click to See Complete Forum and Search --> : Battery Temp sensor reading


DarkDemon
Jul 6th, 2008, 11:17 AM
Hi guys I'm trying to obtain the temperature reading from the battery in my dell axim 51v.

I can currently see the temperature by using the program wr resinfo and clicking the advanced tab.

Is there any programming call I can make to store the temperature inside a variable? other programs can capture this data and I'll like to have it for logging purposes.

petevick
Jul 7th, 2008, 02:22 AM
Take a look at this (http://msdn.microsoft.com/en-us/library/aa457088.aspx)article as I don't think the Microsoft.WindowsMobile.Status.BatteryState exposes it

DarkDemon
Jul 7th, 2008, 04:51 AM
Thanks for that I tried there code all I get is a zero in the text box, it deploys to the pda fine but just shows 0%

I'm getting warnings though on the following functions.

* type of member (all of the below) is not CLS-compliant

Any ideas?

' SYSTEM_POWER_STATUS_EX2

Public BatteryLifeTime As System.UInt32
Public BatteryFullLifeTime As System.UInt32

Public BackupBatteryLifeTime As System.UInt32
Public BackupBatteryFullLifeTime As System.UInt32
Public BatteryVoltage As System.UInt32
Public BatteryCurrent As System.UInt32
Public BatteryAverageCurrent As System.UInt32
Public BatteryAverageInterval As System.UInt32
Public BatterymAHourConsumed As System.UInt32
Public BatteryTemperature As System.UInt32
Public BackupBatteryVoltage As System.UInt32

'SYSTEM_POWER_STATUS_EX
Public BatteryLifeTime As System.UInt32
Public BatteryFullLifeTime As System.UInt32


Public BackupBatteryLifeTime As System.UInt32
Public BackupBatteryFullLifeTime As System.UInt32



Heres the code


Imports System.Runtime.InteropServices

Public Class Form1

' VB
Public Class SYSTEM_POWER_STATUS_EX2
Public ACLineStatus As Byte
Public BatteryFlag As Byte
Public BatteryLifePercent As Byte
Public Reserved1 As Byte
Public BatteryLifeTime As System.UInt32
Public BatteryFullLifeTime As System.UInt32
Public Reserved2 As Byte
Public BackupBatteryFlag As Byte
Public BackupBatteryLifePercent As Byte
Public Reserved3 As Byte
Public BackupBatteryLifeTime As System.UInt32
Public BackupBatteryFullLifeTime As System.UInt32
Public BatteryVoltage As System.UInt32
Public BatteryCurrent As System.UInt32
Public BatteryAverageCurrent As System.UInt32
Public BatteryAverageInterval As System.UInt32
Public BatterymAHourConsumed As System.UInt32
Public BatteryTemperature As System.UInt32
Public BackupBatteryVoltage As System.UInt32
Public BatteryChemistry As Byte
End Class 'SYSTEM_POWER_STATUS_EX2

Public Class SYSTEM_POWER_STATUS_EX
Public ACLineStatus As Byte
Public BatteryFlag As Byte
Public BatteryLifePercent As Byte
Public Reserved1 As Byte
Public BatteryLifeTime As System.UInt32
Public BatteryFullLifeTime As System.UInt32
Public Reserved2 As Byte
Public BackupBatteryFlag As Byte
Public BackupBatteryLifePercent As Byte
Public Reserved3 As Byte
Public BackupBatteryLifeTime As System.UInt32
Public BackupBatteryFullLifeTime As System.UInt32
End Class 'SYSTEM_POWER_STATUS_EX


'VB
<DllImport("coredll")> _
Private Shared Function GetSystemPowerStatusEx( _
ByVal lpSystemPowerStatus As SYSTEM_POWER_STATUS_EX, _
ByVal fUpdate As Boolean) As System.UInt32
End Function


<DllImport("coredll")> _
Private Shared Function GetSystemPowerStatusEx2(ByVal _
lpSystemPowerStatus As SYSTEM_POWER_STATUS_EX2, _
ByVal dwLen As System.UInt32, ByVal fUpdate As Boolean) _
As System.UInt32
End Function



Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If (e.KeyCode = System.Windows.Forms.Keys.Up) Then
'Rocker Up
'Up
End If
If (e.KeyCode = System.Windows.Forms.Keys.Down) Then
'Rocker Down
'Down
End If
If (e.KeyCode = System.Windows.Forms.Keys.Left) Then
'Left
End If
If (e.KeyCode = System.Windows.Forms.Keys.Right) Then
'Right
End If
If (e.KeyCode = System.Windows.Forms.Keys.Enter) Then
'Enter
End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim status As New SYSTEM_POWER_STATUS_EX
Dim status2 As New SYSTEM_POWER_STATUS_EX2

If Convert.ToInt32(GetSystemPowerStatusEx(status, False)) = 1 Then
TextBox1.Text = String.Format("{0}%", status.BatteryLifePercent)
End If

If Convert.ToInt32(GetSystemPowerStatusEx2(status2, _
Convert.ToUInt32(Marshal.SizeOf(status2)), False)) = _
Marshal.SizeOf(status2) Then

TextBox1.Text = String.Format("{0}%",status2.BackupBatteryLifePercent)
End If




End Sub


End Class

petevick
Jul 8th, 2008, 01:15 AM
This is trying to show the 'charged' percentage which you can do using Microsoft.WindowsMobile.Status.BatteryState or Microsoft.WindowsMobile.Status.BatteryLevel

I thought you wanted the temp - what does that value show?

DarkDemon
Jul 8th, 2008, 04:48 AM
My mistake thanks for spotting that I changed it to temp and it works great.