element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs MIT App Inventor and Arduino Part 2 - send data from Arduino to Android and display
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: neilk
  • Date Created: 18 Jul 2014 4:06 PM Date Created
  • Views 12170 views
  • Likes 4 likes
  • Comments 53 comments
  • android
  • bluetooth
  • hc06
  • mit
  • arduino_tutorials
  • arduino tutorials
  • appinventor
  • arduino_tutorial
  • arduino tutorial
  • arduino
Related
Recommended

MIT App Inventor and Arduino Part 2 - send data from Arduino to Android and display

neilk
neilk
18 Jul 2014

MIT App Inventor and Arduino Part 2 - send data from Arduino to Android and display


I found numerous links via Google for this example; unfortunately a lot of them were the same tutorial posted in different places by the same person. None of them included the Arduino sketch! However, the sketch tuned out to be entirely trivial

 

I won't bother giving any of the links, because the the whole thing is unbelievably simple!

 

Here is the Design screen for the App:

 

                                                              image

The screen is very similar to the previous app, except the On and Off buttons are replaced by 2 Labels: Label2 has the default text of "Data from Arduino" and Label3 is given the default text of "0", in Red with a larger font.


As in the previous App, there is a  Bluetooth Client and we also need to add a  Clock component to act as a timer.  These are both non-visible on the display and are shown below the bottom of the Android device screen.

 

In the Blocks screen we retain the 2 Blocks relating to selecting and connecting to Bluetooth and the Block responsible for disconnecting  from Bluetooth. We  dispense with the Button Blocks.


We then add the following new Block to receive and display the data:

image

In the Design screen, I left the default timer interval on the Clock at 1000mS because we want to have time to actually read the Android display.

 

The Arduino Sketch turned out to be very simple:

 

/*   Demonstration sketch to send data to an Android App via Bluetooth - essentially simple; this is just serial output of integer data.

     The Bluetooth module is connected across the Arduino Rx and Tx lines as before.

      A 10k pot is connected across +5v and ground; the slider is connected to analog input 0, to supply varying data.

 

     Neil Kenyon

     15 July 2014

*/

int potPin = 0;                                  // Define the Analog input

void setup()

{

  Serial.begin(9600);

  pinMode(potPin, INPUT);

}

void loop()

{

    int value = analogRead(potPin);    // read the value of the Analog Input

    Serial.println(value);                     // Print the value; can also be seen on Serial Monitor

    delay(1000);                                   // Don't send too fast or the Android buffer will flood - this worked for me

}

 

This seems to work well enough to demonstrate the ease with which we can send data from the Arduino to the Android App.


Edited on 10 August 2015........problems can arise if the Arduino Transmission and Android Receive delay times are set identically. This wasn't a problem for my set up, but seems to be for others. If you leave the Arduino delay at 1000mS, then reduce the clock/timer delay in App Inventor to 950mS, it should be good image



There are two attachments; the second one - Data_from_Arduino_A.zip does some extra error checking which some Android devices seem to need more than others.

Attachments:
Data_from_Arduino.zip
Data_from_Arduino - A.zip
  • Sign in to reply

Top Comments

  • Former Member
    Former Member over 10 years ago +2
    Thank you for all your help, I have now (after some playing) successfully able to receive accelerometer data via bluetooth to an android device!!!!! Thanks!
  • Former Member
    Former Member over 10 years ago +2
    I found that the following youtube video was very helpful: https://www.youtube.com/watch?v=DkGGilznfG8
  • Former Member
    Former Member over 10 years ago +2
    Hey everybody... Could You Do Me a Favour? I got problem here when I'm trying to make android app using AppInventor2. I'm going to make android app to showed data "TempValue", "MoistureValue", "ldrvalue…
Parents
  • Former Member
    Former Member over 10 years ago

    I found that the following youtube video was very helpful:

     

    https://www.youtube.com/watch?v=DkGGilznfG8

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neilk
    neilk over 10 years ago in reply to Former Member

    That is a neat solution to displaying 2 or items of data from different sources,. Thanks for posting it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • neilk
    neilk over 10 years ago in reply to Former Member

    That is a neat solution to displaying 2 or items of data from different sources,. Thanks for posting it

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube