×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    29

    JavaME: how to connect an external sensor?

    Hello!

    I have an external sensor (personal, mobile). For example, a thermometer. I'd like to connect it to an ordinary mobile phone (no OS, just JavaME) and write JavaME application which reads data from that sensor and displays them on the screen.

    My understanding was that I could connect sensor to phone using the audio jack (headphone jack), because every phone has that jack. But I didn't find any info how to read data through that jack.

    So, my questions are:

    1) Is it possible to connect an external sensor to phone's headphone jack and read data from it in JavaME application? How? Code example?

    2) What are the other ways to connect an external sensor to JavaME phone? Bluetooth? Sms?

    Thanks for your help!

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: JavaME: how to connect an external sensor?

    Hi zakharo,

    The general concept is that your Java ME applications will need to understand or "see" the sensor. This kind of client-server communication model normally consists of custom-written programs for both the server and the client.
    In other words a Java ME client program should run on the remote terminal while a Java ME server should run on the mobile phone.

    You can see example codes for communication between two Java ME terminals over Bluetooth here (server and client respectively):

    http://www.developer.nokia.com/Commu...ice_in_Java_ME
    http://www.developer.nokia.com/Commu...ces_in_Java_ME

    SMS is also another communication option, provided that the sensor has this capability. A Java ME Midlet can send and receive an SMS. Examle codes for sending and receiving an sms can be found here:

    http://www.developer.nokia.com/Commu...ronous_version
    http://www.developer.nokia.com/Commu...ing_a_text_SMS

    Alternatively if the sensor is internet enabled, and can run a web service, you can try to connect to it from a midlet running on your phone by using the an HTTP request:

    http://www.developer.nokia.com/Commu...est_in_Java_ME
    http://www.developer.nokia.com/Commu...est_in_Java_ME

    Data connection over the headphone jack is not possible as it can not be used for bidirectional data transmission.
    Last edited by skalogir; 2011-10-11 at 11:46.

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,545

    Re: JavaME: how to connect an external sensor?

    Bluetooth and JSR-82 APIs from J2ME. Examples in the wiki: http://www.developer.nokia.com/Commu...ivity_Articles

    There's no chance for you read anything from J2ME using the headphone jack.

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: JavaME: how to connect an external sensor?

    Certain products do use audio jack (headphone jack) for connecting mobile device, these devices convert the data which they want to send to the device in Audio format using some codec and the incoming audio stream is recorded on the device and then decoded using the same codec which was used to encode it - before used on the program.

    For example - squareup.com card reader.

    Other way around is easy to use Bluetooth pairing, but your option will depend on the capabilities provided by the device which you want to connect to.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    29

    Re: JavaME: how to connect an external sensor?

    Thanks for reply!

    Your example, I mean squareup.com card reader, looks good. This is exactly what I need. But... I found the following info on the specified site:
    "What devices does Square work with?
    Square is supported on most iOS and Android devices."
    So, that product doesn't work for a simple phone with JavaME : (

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    29

    Re: JavaME: how to connect an external sensor?

    Quote Originally Posted by petrib View Post
    There's no chance for you read anything from J2ME using the headphone jack.
    Do you have any proof links? I need them to explain my decisions.

  7. #7
    Registered User
    Join Date
    Oct 2011
    Posts
    29

    Re: JavaME: how to connect an external sensor?

    Hi,

    Thanks for your reply!

    First of all, I did not catch your idea about JavaME client and server on different terminals. My understanding was that I needed only JavaME client on a mobile phone which read data from external device through some kind of an input stream.

    Re:
    > Data connection over the headphone jack is not possible as it can not be used for bidirectional data transmission.
    >
    1. Actually I need the unidirectional data link: external sensor -> phone.
    2. Do you have any proof links?

    Thanks for your help!

  8. #8
    Regular Contributor
    Join Date
    Mar 2011
    Location
    Pune,Maharashtra,India
    Posts
    92

    Re: JavaME: how to connect an external sensor?

    Quote Originally Posted by azakharo View Post
    Hi,

    Thanks for your reply!

    First of all, I did not catch your idea about JavaME client and server on different terminals. My understanding was that I needed only JavaME client on a mobile phone which read data from external device through some kind of an input stream.

    Re:
    > Data connection over the headphone jack is not possible as it can not be used for bidirectional data transmission.
    >
    1. Actually I need the unidirectional data link: external sensor -> phone.
    2. Do you have any proof links?

    Thanks for your help!
    You can use bluetooth for communication with external devices or sensors,but in sensor case you again need to programme the device containing the sensor so that it can send sensed data to bluetooth antenna i.e you need interface between sensor and bluetooth antenna.
    and you can use mobile J2ME app to retrieve data from bluetooth antenna buffer.

  9. #9
    Registered User
    Join Date
    Aug 2012
    Posts
    3

    Re: JavaME: how to connect an external sensor?

    Hi petrib,
    I want to record audio from some device which is attached in headphone jack.
    I have two question related to that
    1. how to detect that device is plugin in headphone jack?
    2. how to capture audio from that device?.

    I am working on nokia s40 6th addition phones
    please reply as soon as possible.Thanks in advance

Similar Threads

  1. How to connect External HD / Pen drive?
    By pedro_osb in forum General Development Questions
    Replies: 3
    Last Post: 2010-04-07, 13:49
  2. Can we connect sensor motes to phones
    By cuteprince in forum General Development Questions
    Replies: 0
    Last Post: 2007-12-07, 22:03
  3. Using Python and Bluetooth to connect with a Nonin Medical Sensor
    By icinnamon in forum Bluetooth Technology
    Replies: 0
    Last Post: 2007-07-11, 00:33
  4. connect to WAP Page on external event
    By wraboch in forum Symbian
    Replies: 0
    Last Post: 2003-12-02, 17:00
  5. Not able to connect to external server using RAS
    By reshmasp in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2003-09-12, 12:28

Posting Permissions

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