Free digital input pin on ALL Androids

rayellam

Member
Licensed User
Longtime User
Hi All,
Thought id share this solution i found. If you need one digital input from the outside world whilst running on battery then use this method from the phone lib

B4X:
Dim PhoneEvents1 As PhoneEvents

Sub thePhoneEvents_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
    'Get the battery level on change event
    digitalInputState = Plugged
End Sub

Response time is < 3 seconds which is good enough for my application.

Cheers
Ray
 

rayellam

Member
Licensed User
Longtime User
Hi All,
Thought id share this solution i found. If you need one digital input from the outside world whilst running on battery then use this method from the phone lib

B4X:
Dim PhoneEvents1 As PhoneEvents

Sub thePhoneEvents_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
    'Get the battery level on change event
    digitalInputState = Plugged
End Sub

Response time is < 3 seconds which is good enough for my application.

Cheers
Ray

If the D/I voltage is 5V then the phone will charge the battery and around 350mA is drawn from the D/I. If you lower the D/I voltage to 3.3V then the phone will still detect the change (works down to ~2.2V) BUT the voltage is to low for the phone internal charger to kick in so the current drawn from the D/I is negligible. This was tested on a Huawei Y210D
 
Top