Android Question Camera LED used as low speed data transfer

minitech

Member
Licensed User
Longtime User
Hi, Has anyone used the camera led as a low speed data transfer medium. I have looked through info and cannot find how to modulate the led
 
That's an awesome idea. But no, sorry I haven't tried it. You would probably use a version of morse code, this will be a very slow way to transfer data though and could cause you issues with epileptic users! Might be better to try using high pitch audio transmission.
 
Upvote 0
The process would be used to transfer data to a piece of equipment so the phone would be pointed away from the user, although I take on board that reflection could still cause some users a problem. For the application a warning would probably suffice. Yes a series of simple codes is the idea. Binary coded not morse which is of course coded letters. But worth considering
 
Upvote 0
How bright would the light need to be? You may have a chance using a flashing white (or whatever color is most easily received) panel on a black or contrasting background.
 
Upvote 0
Here you go try this.

Requires permission:

Code: Copy
AddPermission("android.permission.CAMERA")

To be added to the manifest.

Turn on with:

Code: Copy
    Cam.InitializeStatic("android.hardware.Camera")
    Cam = Cam.RunMethod("open",Null)
    Dim Par As JavaObject = Cam.RunMethod("getParameters",Null)
    Par.RunMethod("setFlashMode",Array As Object("torch"))
    Cam.RunMethod("setParameters",Array As Object(Par))

and Off with

Code: Copy
Cam.RunMethod("release",Null)

Works on my Sony experia.

Test project attached.
 

Attachments

Last edited:
Upvote 0
Thanks for reply Steve. I will try that on my Samsung later. Just got tied up with some other issue. Will let you know.
 
Upvote 0
Try changing the flash mode from "torch" to "on", apparently it may work for up to 5 seconds. But that should be enough for your purposes.

If that doesn't work you can try adding one or both of these to your Manifest:

Code: Copy
AddPermission("android.permission.FLASHLIGHT")
AddManifestText("android.permission-group.HARDWARE_CONTROLS")
 
Upvote 0
Been a while but update from tests are that although some control of the led is possible, it seems that it is not stable enough in the system to provide consistently equal width pulses needed for decoding. Using timer seems to have some problems which are probably system related in that timer seems not to have priority when kicked off so timings not stable. Someone else is doing tests which this post is based on so waiting for some more details. It may turn out to be unusable for transmit of binary data field.
 
Upvote 0
I was able to get this sample to work on a Note 2 running Android 4.1.2
When I try to run it on a Note 3 with Android 4.4.2 it fails to turn the light on.

If I run the example in the CameraEx class / library - the light function works as expected.

Any thoughts as to why it would fail in A 4.4.2?

G
 
Last edited:
Upvote 0
Can only assume that they have changed permissions, or the hardware has a mask ! As for original idea of transmitting data I think that the chances of achieving stable pulse width's to decode is a pipe dream on Android, unless somebody knows differently. So for the time being I am abandoning this idea for communications.
 
Upvote 0
I see,

I'm using the code above to turn a light on - not for pulse width modulated communication.
I'm hoping the author might have a simple solution to the problem I'm seeing.
I tried the recommended changes (above) - no joy.

G
 
Upvote 0
I found a reference in an Android Forum that says.

"Try turning "Smart Stabilization" off...For some idiotic reason Samsung decided to bundle the "Night Mode" into the stabilization option, so more often than not, the phone will try to take pictures with longer exposure rather than firing up the flash."

Will try this later today and see if it solves the problem.

G
 
Upvote 0
Is there a way to dump the cam.parameters - so I can see the correct name of the smart_stabilization parameter and maybe turn it off just ahead of activating the light?

G
 
Upvote 0
Back
Top