Results 1 to 5 of 5

Thread: Battery Temp sensor reading

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    Battery Temp sensor reading

    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.

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Battery Temp sensor reading

    Take a look at this article as I don't think the Microsoft.WindowsMobile.Status.BatteryState exposes it
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    Re: Battery Temp sensor reading

    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?

    Code:
    ' 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

    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

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Battery Temp sensor reading

    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?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    65

    Re: Battery Temp sensor reading

    My mistake thanks for spotting that I changed it to temp and it works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width