Documente Academic
Documente Profesional
Documente Cultură
Publish (/about/create.jsp)
Featured: 3D Printing Class (https://www.instructables.com/class/3D-Printing-Class/) Arduino (/tag/type-id/category-technology/channel-arduino/)
Sewing (https://www.instructables.com/tag/type-id/category-craft/channel-sewing/)
License:
8 45.289 views
34 favorites
(/le/F11NFGKIJUCPG52/)
vamsikurre
(/member/vamsikurre/)
Follow 30
(/member/vamsikurre/)
More by vamsikurre:
(/le/FTBF0GCIJIX7AA7/)
I have made an Arduino based night lamp using photo resistor and problem (/id/Simple-LED-
with that is light levels was dierent from place to place, when I am testing I
have used a value as a threshold to switch on the light and after xing it in its
nal position that value is way o. Strip-Party-Lights-Using-Arduino/)
So, to get the correct value I have to data log the photo resistor reading after
xing the light in place, which was a bit harder, because I cannot leave my
(/id/Arduin-Adroid-
laptop outside for data logging for a whole day. So I need a portable solution to
my problem.
Another project was, water supply near my place was limited, we get water only
USB-Serial-Communication/)
at xed timings. so I made a device to turn on water motor at a xed timings of
day. I havent made any user interface for that device to change timings
because timings get to change very infrequently. So I need a way to change
(/id/Repair-and-
timings without connecting laptop and recompiling Arduino code, that would be
complicated for my parents.
So I decided to make an android app that would send serial data to Arduino to
Upgrade-Dodgy-Mouse/)
change timings of water motor. Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)
In this instructable, I will explain how to create an android app that can
communicate with Arduino by USB OTG cable, If you dont care about how to
just download .apk le and install it in your phone to communicate with arduino.
Serial_monitor.apk
Download (https://cdn.instructables.com/ORIG/FH2/UY6R/IJUCRORL/FH2UY6RIJUCRORL.apk)
(https://cdn.instructables.com/ORIG/FH2/UY6R/IJUCRORL/FH2UY6RIJUCRORL.apk)
Ad Fast Raspberry
Setapp. Novo Jeito de Ter Apps
+ de 60 apps gratuito por 30 dias. No exige
carto. Assine o Setapp agora!
Pi Builder
explore.setapp.com
Cayenne
(/le/FXXWFMRIJUCPE65/)
(/le/FV7PGYIIJUCPE7G/)
(/le/FO1UOEFIJUCPHWQ/)
(/le/F0ZAM4MIJUCPJHA/)
In the welcome screen you should see congure button, by selecting it you
should go to conguration page. There rst option would be SDK Manager,
by clicking that a new window will open by showing the details of current SDK.
There would be an option to launch standalone SDK Manager, by clicking
that good old SDK manager will be opened there you can add new SDK tool as
required.
Android studio has an emulator to test the android code, but unfortunately we
cannot use that for this scenario because this involves a physical device talking
to another device. Instead we can use an android phone itself to debug the
code.
Since we are using android device to debug the code we can just download
SDK Platform of that specic version of the device, rst know the android OS
version of the phone. In my case I am using Samsung note3 which has 5.0
(lollipop) so just download SDK Platform from Android 5.0.1 (API 21) that
should be enough.
The library I was using to make the communication is called physicaloid from
http://www.physicaloid.com/ (http://www.physicaloid.com/) which was last
updated 2 years ago and nal update was not working (for me at least). So after
discussing with people in github repository I managed to get the old working jar
le for that library.
By using this library we can not only communicate with Arduino but we can
upload compiled hex les into Arduino, this library has avrdude functionality
built-in.
physicaloidlibrary.jar
Download (https://cdn.instructables.com/ORIG/FNM/9MXQ/IJUCPKBD/FNM9MXQIJUCPKBD.jar)
(https://cdn.instructables.com/ORIG/FNM/9MXQ/IJUCPKBD/FNM9MXQIJUCPKBD.jar)
(/le/FVYFLCEIJUCPP4W/)
First I want to make an app that looks same as Arduino's serial monitor
window.
In the welcome screen of android studio there will be an option to create new
project, select Start a new android studio project
In the next page give your project name and location, then click next
In the next page select the platform for which we are developing application
and select correct version of your phone and click next
In the next page by default Blank activity will be selected and leave it as it is
for now. And in the next page name your activity (your main screen in the app).
Then click nish, newly created project will be opened in android studio and we
can work on it now
(/le/F3D4LRCIJUCPTBX/)
In the top left side of the main screen there will be a drop down menu ladled as
android, change the option to project to see the directory structure of the
project.
In the directory structure by expanding app folder you can nd lib folder that
is the default folder to place our libraries.
Copy the physicaloidlibrary.jar le and paste it in libs folder
After pasting click sync project with gradle les button on the top.
Now the library is added we can use its features in our code.
Main activity that was automatically created when we rst created project will
be located in
App > src > main > java > YOUR_ACTIVITY
And layout will be located at
App > src > main > res > layout > activity_serial_monitor.xml
(/le/F6WD02YIJUCQ5DN/)
<uses-feature android:name="android.hardware.usb.host"></uses-feature>
Line above
my manifest le looks like
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Serial_monitor"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
By adding that line we are asking permission of the user every time we connect
a USB device to OTG port
(/le/FXDQUDPIJUCQ85R/)
<resources>
<string name="app_name">Serial Monitor</string>
<string name="action_settings">Settings</string>
<string name="baud_prompt">Choose Baudrate</string>
<string-array name="baud_arrays">
<item>300 baud</item>
<item>1200 baud</item>
<item>2400 baud</item>
<item>4800 baud</item>
<item>9600 baud</item>
<item>19200 baud</item>
<item>38400 baud</item>
<item>576600 baud</item>
<item>744880 baud</item>
<item>115200 baud</item>
<item>230400 baud</item>
<item>250000 baud</item>
</string-array>
</resources>
content_serial_monitor
Download (https://cdn.instructables.com/ORIG/F8L/F5P8/IJUCQ87O/F8LF5P8IJUCQ87O.xml)
(https://cdn.instructables.com/ORIG/F8L/F5P8/IJUCQ87O/F8LF5P8IJUCQ87O.xml)
(/le/FSB06FMIJUCR6JB/)
That's all everything is completed just connect your phone and run the program
it should install and open.
Serial_monitor.java
Download (https://cdn.instructables.com/ORIG/F3T/71R7/IJUCQVC1/F3T71R7IJUCQVC1.java)
(https://cdn.instructables.com/ORIG/F3T/71R7/IJUCQVC1/F3T71R7IJUCQVC1.java)
(/le/FT2IVT4IJUCRFEW/)
(/le/FJBVQHDIJUCRCZO/) (/le/F3CPZL3IJUCRD11/)
Now connect phone and run the code by using play button on the top, now
device chooser dialogue pops up and ask's in which device should this app
install.
Note: if you did not nd your phone in the list try reinstalling the phone drivers.
Disconnect the phone from pc and connect to Arduino with OTG cable, and
send some data it should come back
serial_test.ino
Download (https://cdn.instructables.com/ORIG/FB6/6N6G/IJUCRBXD/FB66N6GIJUCRBXD.ino)
(https://cdn.instructables.com/ORIG/FB6/6N6G/IJUCRBXD/FB66N6GIJUCRBXD.ino)
(/le/FSDXEV6IJUCRTVZ/)
You can modify the layout and code to suit your needs and make an app for
each device you make separately
For example I have modied same project to work as a Interface for my motor
timer controller.
This can also be used for communicating with raspberry pi serial interface using
USB to UART converter as shown in adafruits
https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-
cable (https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-
console-cable) tutorial.
SerialMonitor.rar
Download (https://cdn.instructables.com/ORIG/FEY/ADCF/IJUCRMW6/FEYADCFIJUCRMW6.rar)
(https://cdn.instructables.com/ORIG/FEY/ADCF/IJUCRMW6/FEYADCFIJUCRMW6.rar)
Ad
Download Cleaner for Mac
Award-winning System Utility. Clean Mac les
Right Now!
MacKeeper.com
hi there, thank you very much for your work and eort!
unfortunately i've the same "cannot open" issue as others few days ago.
i just spent hours to check every single step and cannot nd the problem.
it's arduino compatible so if, then only the USB_Vendor could be wrong..
how to nd and where to replace the NodeMCU vendor_id?
or am i wrong?
Can anyone help me to make a function that receives data in Android so I can
call it on other activities and use that data there?
Hi, can you make a video of everything you did? That would be awesome!
Best Regards,
Weikang
Regards,
6 months ago
Thank you for the advice! May I know what is the y axis
variable to plot the graph?
6 months ago
Im amazed and thankful for your prompt response! I meant
the y variable in your code. As I am reading a list of numbers from
Arduino, I simply want to plot them into a graph but I do not know what is
the name of the variable in your code.
line gets the serial data from arduino and populates it into 'buf' byte array
variable, I guess you need to convert that byte array into string or integer
to plot graph. you can use 'public void onRead(int size)' function to get
the event of receiving new data to update your graph.
Regards
Thanks
X
|
nancyjohns (/member/nancyjohns)
Check out our new classes! >> (/classes/?utm_medium=cta&utm_source=banner)
8 Very nice. I must point out that the name of the instructable a year ago Reply
FEATURED CHANNELS
Woodworking Paper Kitchen Hacks Puzzles Laser Cutting Space Homesteading 3D Printing Sewing
(/tag/type- (/tag/type- (/tag/type- (/tag/type- (/tag/type- (/tag/type- (/tag/type- (/tag/type- (/tag/type-
id/category- id/category- id/keyword- id/category- id/category- id/keyword- id/category- id/category- id/category-
workshop/channel-craft/channel- kitchen%20hacks/?play/channel- workshop/channel- astronomy/? home/channel- technology/channel-
craft/channel-
woodworking/) paper/) sort=FAVORITES) puzzles/) laser-cutting/) sort=FAVORITES) homesteading/) 3D-Printing/) sewing/)
Newsletter About Us
Join 2 million + to receive instant Who We Are (/about/)
DIY inspiration in your inbox. Advertise (/advertise/)
Contact (/about/contact.jsp)
enter email I'm in!
Jobs (/community/Positions-available-at-Instructables/)
Help (/id/how-to-write-a-great-instructable/)
Find Us Resources
Facebook (http://www.facebook.com/instructables) For Teachers (/teachers/)
Youtube (http://www.youtube.com/user/instructablestv) Artists in Residence (/air)