Arduino Bluetooth Control From Your Mobile Phone Using MIT App Inventor

  Рет қаралды 41,985

Bytes N Bits

Bytes N Bits

3 жыл бұрын

Controlling and monitoring your Arduino project from your mobile phone adds an extra dimension to your project work. But the thought of having to write a mobile app, work out the bluetooth connection details and getting it all working can seem daunting.
But using the MIT App Inventor system and a simple bluetooth module makes the whole process very straight forward.
In this video I'll show you how to design your own serial protocol to frame your data and build robust error handling into your message. We'll then use the MIT App Inventor software to build a native mobile app using a simple drag and drop interface along with their block programming system.
This video is over a hour long as we cover lots of topics and deal with a number of errors you'll come across when developing serial communication apps. I've listed a number of bookmarks below to help you get straight to various sections.
03:42 - Overview of the finished project
05:48 - Creating a data protocol for sending data
08:25 - Coding the Arduino and adding error checking
20:34 - Testing using the serial monitor
25:04 - MIT App Inventor starts
27:00 - Starting to code the App
33:37 - Downloading initial app to your phone and testing
36:08 - Connecting to the Arduino Bluetooth module
41:32 - Sending a colour data message to the Arduino
45:44 - Adding sliders for RGB control
52:29 - Dealing with data collisions and transmission errors
55:09 - Polling the data send function
59:31 - Sending data from the Arduino to the App
Don't forget to visit my course page to find out more and see all my other projects and posts.
bytesnbits.co.uk/arduino-blue...

Пікірлер: 88
@josiahbrunson873
@josiahbrunson873 2 жыл бұрын
This is phenomenal. I've watched a ton of videos on communication protocols and your code is by far the easiest to read! Thank you so much!
@BytesNBits
@BytesNBits 2 жыл бұрын
Glad it was helpful!
@brunodragas8661
@brunodragas8661 6 ай бұрын
​@@BytesNBitshi, I have a problem, when I open mit app inventor companion and click ,,scan for device", there is nothing there and I connected my phone to bluetooth module as you said. Can you please help?
@brunodragas8661
@brunodragas8661 6 ай бұрын
​@@BytesNBitshi, I managed to overcome this problem where no devices were found, but unfortunately another one came across, when I click on hc 05 it says error 507:unable to connect. Is the device turned on. Any help?
@guvensahin6811
@guvensahin6811 2 жыл бұрын
Great video, I solved the coding problem on two or more slider controls. thank you so much
@BytesNBits
@BytesNBits 2 жыл бұрын
Glad it helped!
@mrmotorvator
@mrmotorvator Жыл бұрын
Very good pace, structure and explanation. Will now read about MIT AI with a better knowledge of what is possible and then run through lessons again.
@BytesNBits
@BytesNBits Жыл бұрын
Glad you found it useful.
@khaledabd-elhalim1899
@khaledabd-elhalim1899 2 жыл бұрын
Thank you so much, this is exactly what I needed😍🥰
@BytesNBits
@BytesNBits 2 жыл бұрын
You’re welcome 😊
@prashantparkhe6125
@prashantparkhe6125 Жыл бұрын
A complete tut great work 👏 👍 Many Thanks 😊
@BytesNBits
@BytesNBits Жыл бұрын
You are welcome!
@takudzwamutepfa9952
@takudzwamutepfa9952 7 ай бұрын
You gained a new subscriber 🔥
@BytesNBits
@BytesNBits 7 ай бұрын
Great! Thanks.
@rinokentie8653
@rinokentie8653 2 жыл бұрын
Very useful! Thanks.
@BytesNBits
@BytesNBits 2 жыл бұрын
Glad it was helpful!
@keithmefferd8728
@keithmefferd8728 6 ай бұрын
I echo the comments below: As a career software developer, this message management is both elegant and very solid, not to mention expertly explained. I'm brand new to Arduino world as well as just starting to think about Android App development so this tutorial was excellent to find. Definitely subscribed!
@BytesNBits
@BytesNBits 6 ай бұрын
Glad you found it useful. Thanks.
@bdspvl
@bdspvl 2 жыл бұрын
Wow it so happens I just started studying this subject today!
@BytesNBits
@BytesNBits 2 жыл бұрын
Great. I hope it helps.
@jirizamek7875
@jirizamek7875 2 жыл бұрын
Very good, thank you very much!
@BytesNBits
@BytesNBits 2 жыл бұрын
Glad you liked it!
@petermccool9396
@petermccool9396 2 жыл бұрын
You might want to replicate the way the NEO-6M handles NMEA serial messages and add a checksum to the end of your messages. If you use the same message format, you could use the same code between other serial devices. I'm currently working on a GPS speedometer for my Yamaha Virago but taking a break to work on my smoker. This video has been very educational as I want to use BT to control the temperature of the smoker from my smartphone. I should be able to use my GPS sketch with slight modifications for the BT interface.
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi Peter. Those sound like great projects. I'll look into the message format on the next BT project. Thanks.
@manfredbogner9799
@manfredbogner9799 2 ай бұрын
Very nice
@BytesNBits
@BytesNBits 2 ай бұрын
Thanks
@umutkayacan7659
@umutkayacan7659 3 жыл бұрын
Love it!
@BytesNBits
@BytesNBits 3 жыл бұрын
Thanks!!
@umutkayacan7659
@umutkayacan7659 3 жыл бұрын
@@BytesNBits i feel like im the only one watching your videos and that makes me sad. Some day you will be discovered. Keep it up!
@mimi-mk9eu
@mimi-mk9eu 3 жыл бұрын
@@umutkayacan7659 not the only one
@umutkayacan7659
@umutkayacan7659 3 жыл бұрын
@@mimi-mk9eu well most of the time im the only one who comments sooo yea
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi Guys. I'm just grateful that you're all taking the time to watch them. The channel is growing quite well now so I'll be keeping up with the videos as more people find it. See you in the next one!
@petermccool9396
@petermccool9396 2 жыл бұрын
I meant to add, for timed interrupts or events, I use the Watchdog timer say set to 250mS. You could count 4 interrupt events for 1S. ,or any combination to suit your project. I have never used millis().
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi Peter. Thanks for the tip on using the watchdog timer. I guess both options have their uses.
@mykeruiz2129
@mykeruiz2129 2 жыл бұрын
This video is a great tutorial! I am new to arduino and android app design. I'm trying to get the value of the slider and pass it to arduino as character. I'm using the slider as a speed control to my arduino bluetooth controlled car. When the slider is slide to the right it increases the speed and when it is slide back it decreases the speed. Hoping for a suggestion or idea. Thank you! By the way i like the way you code. You use naming conventions and it is helpful in tracing or tracking the components.
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. The sliders in the video should show you how to get a value passed over Bluetooth. After that it's a matter of using that value to control the motor speed. What sort of motor control are you using?
@edwintjoa6099
@edwintjoa6099 2 жыл бұрын
Thanks for the great video!! Always wanted to learn how to create a data protocol. Is there a suggestion on data protocol if there are 2 slave nodes trying to transmit data to 1 master node?
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. I guess the main issue here is working out a way of controlling who has access to the main node. You'll need some sort of polling scheme to allow a slave to request the comms channel. After it's got control of the comms the protocol can be whatever you want.
@keithmefferd8728
@keithmefferd8728 6 ай бұрын
I had written software back in the late 80's that communicated in grocery stores to managed FM-based price checking devices. Multiple terminals communicated with my master app to query a database. Part of the message stream included a 1-character poll ID and a 1-digit message counter 0-9. The master app and each device kept track of which message counter number was expected per Polling device so we could ensure we stayed in sync.
@Steinninn
@Steinninn 2 жыл бұрын
Pro tip: If you add "0:00 intro" to your description then there will be some handy dandy chapters right in the timeline.
@BytesNBits
@BytesNBits 2 жыл бұрын
Thanks for the to. I'll give that a go.
@Paul_VK3HN
@Paul_VK3HN Ай бұрын
This was a very helpful tutorial. Thanks! Question, does the MIT App Inventor app run off-line (without a Cellular connection)? I have a use case in mind which involves being out of cell coverage. It shouldn't need it but you never know with some apps...
@BytesNBits
@BytesNBits Ай бұрын
I don't think it needs a connection but I haven't actually tried it.
@joanacoronelsoler3977
@joanacoronelsoler3977 9 ай бұрын
Thank you so much for the video sir. I would like to also produce 1sec sounds when pressing a button on the screen. Which components do you advise me to get?
@BytesNBits
@BytesNBits 9 ай бұрын
You've got a choice. The easiest is to use a simple on/off buzzer or tone generator. You simply turn on an output connected to the device and you get a sound, but you can't control what it sounds like. If you want to play sound samples or controllable tones you'll need a speaker which you'll have to drive with a voltage signal from the Arduino. There are a number of ways to this so your best bet is to look for a tutorial. I haven't made one for the Arduino. I hope this helps.
@renvill1100
@renvill1100 3 жыл бұрын
Do you have anything for Adafruit feather? nrf52832 with their 8 channel servo wing controlled by BLE using MIT App???
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi Eric. I haven't used the Adafuit device. Usually they use the same libraries as other Arduinos so the communications link should work the same. It's then down to you to create a mini language to describe the servo positions and other data that the app and feather wrong can use to talk to each other. I hope this helps.
@ken9651
@ken9651 Жыл бұрын
Hi Bob, We're lookiing to build tool cabnits and would like a locking system using NFC, could you please steer us the right direction.
@BytesNBits
@BytesNBits Жыл бұрын
Hi. You can buy NFC readers that use the SPIO channel to talk to the Arduino. This will let you read the id card so you can lock / unlock. e.g. www.ebay.co.uk/itm/354109727290
@mhamedhamadaembaby2502
@mhamedhamadaembaby2502 3 жыл бұрын
Sir ,i try to do an application but i needed more one screen in Bluetooth app. So i do what you do in my first screen . But in other screens the module doest response the ordes .but just from the first one.what is the problem?
@BytesNBits
@BytesNBits 3 жыл бұрын
Hi. I'm not sure about that one. I'll have a look and get back to you.
@venkatyalamati3285
@venkatyalamati3285 Жыл бұрын
Thanks for the video sir... Plz make a video on how to store the data received from Arduino (analog read data) to a text file and store the text file in a shared folder like Documents of internal storage... I am trying for this but not successful...
@BytesNBits
@BytesNBits Жыл бұрын
Have a look at ai2.appinventor.mit.edu/reference/components/storage.html#File. This component should do what you want.
@venkatyalamati3285
@venkatyalamati3285 Жыл бұрын
@@BytesNBits Thank you sir..
@user-bk7ee4xb3m
@user-bk7ee4xb3m 9 ай бұрын
This is great! Hope you make other projects like this. I'm trying to modify the app to send a command by using a list picker to make the LEDs blink but it seems that the arduino doesn't recognize or receive the command. I replicated the format of the command by using the same start and end token like this "?e=1;" and print it on the serial monitor but it doesn't even print the "message start". Please help :/
@BytesNBits
@BytesNBits 9 ай бұрын
Did you manage to get the tutorial code working? If yes then it should just be a matter of decoding your messages correctly in your sketch code.
@user-bk7ee4xb3m
@user-bk7ee4xb3m 9 ай бұрын
@@BytesNBits I did. I just copied the code for decoding messages and edited some parts. But the main problem i think is the serial comms. The text message from the app is not printing on the serial monitor. I added a list picker to the app which will send a code "?e=" + selection + ";" but the serial monitor doesn't even print "message start". What do you think is the error? I am new to coding and I am out of ideas.
@BytesNBits
@BytesNBits 9 ай бұрын
@@user-bk7ee4xb3m Can you get the arduino to simply print out everything it receives. Then get the app to send some characters on a button press and your list picker. This should confirm of the list picker is actually sending any characters. If none are being sent have a look at the app documentation on how to use the list pickers. Usually there will be an event or trigger when the list value changes. You'll need to use that to send the message, or use a button press to read the list picker value and send that.
@bettgilbert6923
@bettgilbert6923 2 жыл бұрын
an interesting project I would like to give a try... code description, please
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. I tens to have a project page for each video - link in the description. You'll find the code there. bytesnbits.co.uk/arduino-bluetooth-control-mit-app-inventor/
@mosidalnajjar2782
@mosidalnajjar2782 Жыл бұрын
hi, i am trying to make fingerprint system i just can't send sensor data to phone, can you help me please
@BytesNBits
@BytesNBits Жыл бұрын
Hi. You basically need to get the Arduino to compile the sensor data into some sort of formatted text stream (usually people use JSON or XML). This gets sent to the phone as in the video and then gets decoded.
@md.rifatrahmanrafi2771
@md.rifatrahmanrafi2771 3 ай бұрын
Can you please help me with error 507: unable to connect error while connecting the app with my laptop? Thank you..
@BytesNBits
@BytesNBits 3 ай бұрын
I'm not sure what that error means.
@semnal.m2581
@semnal.m2581 3 ай бұрын
Hello and thanks for your effort. In my case this application only works if I have AI Companion open. If I run app alone from my Samsung phone does not work. Can you help? I made only the part with Bluetooth connection and I try to connect to my Bose speaker. Does not work, app does not find anything when I click on Scan for Devices.
@BytesNBits
@BytesNBits 3 ай бұрын
The code in the video works at a very basic level. Various Bluetooth devices identify themselves and their functions and I don't think the Arduino code can recognise all of them, just the basic device type. You should be able to upgrade the code to handle more complex devices but I haven't tried that myself.
@semnal.m2581
@semnal.m2581 Ай бұрын
@@BytesNBits In order to be able to detect HC05 Bluetooth, after installing the application in the phone, we must navigate in the phone settings and find our application in the Application list. Then tap on our application and then in Permissions we must grant access to nearby devices.
@dungnguyen-si2sz
@dungnguyen-si2sz Ай бұрын
i have tried the block "Bluetooth connectivity" but when I connect it through AI2 companion, open Bluetooth on the app and there's only black screen ( I have connected to HC-05 before and tested it on some applications and it worked), can you help me pleaseeee
@BytesNBits
@BytesNBits Ай бұрын
I'm not sure what that would be. Do you get any screen prompts?
@dungnguyen-si2sz
@dungnguyen-si2sz Ай бұрын
@@BytesNBits thank you for replying me :)) i solved it, still dont know what the propblem is, but now i can select and connect to HC_05, thank you for clear tutorial, Sir.
@andrewshepherd7429
@andrewshepherd7429 7 ай бұрын
Hello. I am trying to adapt your code from this video for my own purposes. I have noticed in line 46 of the code you present in the video that the daya type 'String' formats in green, whereas the code I downloaded from your website formats the the same thing in black. Does this mean that the IDE version I am using doesn't recognise 'String' as a data type? I am using IDE Version: 2.2.1 on an Apple Mac. Copyright © 2023 Arduino SA
@BytesNBits
@BytesNBits 7 ай бұрын
The String class is just a standard data type in the Arduino system. You shouldn't have any issues with using it. www.arduino.cc/reference/en/language/variables/data-types/stringobject/
@andrewshepherd7429
@andrewshepherd7429 7 ай бұрын
Thanks for the prompt reply. So I am wrong to assume that the text needs to turn green if it is being recognized by Arduino IDE as a reserved word with a specific purpose. I am certainly OK with that. I was just concerned that my later version of Arduino IDE meant something had changed.
@junaidahmad6753
@junaidahmad6753 10 ай бұрын
i used the same method but Bluetooth connection interface is not open
@BytesNBits
@BytesNBits 10 ай бұрын
Can you connect to the Arduino in the terminal app on your phone?
@rahafqnes5525
@rahafqnes5525 Жыл бұрын
whats the led called so i can buy it?
@ayosh555sh
@ayosh555sh Жыл бұрын
yesss please we would to know its name
@BytesNBits
@BytesNBits Жыл бұрын
It's a neopixel strip from Adafruit - www.adafruit.com/product/1426. Most electronics suppliers will sell them.
@sudhirkoparkar5007
@sudhirkoparkar5007 Жыл бұрын
what is error 516 and how to fix it please guide
@BytesNBits
@BytesNBits Жыл бұрын
Hi. I have no idea. Try Googling the error code.
@thiensuutv1286
@thiensuutv1286 2 жыл бұрын
hi....i want to create on time and off time to on/off led! can you help me!
@BytesNBits
@BytesNBits 2 жыл бұрын
Hi. The app on your phone is really an input device to your code on the Arduino. Use some of the selector objects on the app to create a date / time selector and then have that data sent down to the Arduino. Your code will have to interpret this data and then take the appropriate timing actions. Remember the basic Arduino doesn't have access to real world time so you'll need to build that into your code as well.
@thiensuutv1286
@thiensuutv1286 2 жыл бұрын
@@BytesNBits Do you have any examples related to this? can i have a reference?
@BytesNBits
@BytesNBits 2 жыл бұрын
@@thiensuutv1286 I don't have any examples to show you. The video shows you how to use the app creator tools to create a control and then how to send a message to the arduino. You need to have a look at the other controls in the app maker and then expand upon the message system to send the data you need. Have a look at the documentation on the various controls. Send a time value with the message so the arduino knows what time the message was sent. You can then use one of the in built timer functions to keep track of time from there. Not a very accurate solution but gets you started.
@CrackinWithARB
@CrackinWithARB Жыл бұрын
Hello! I commented on your other video where you redirected me to this one. My idea is simple because all the output I have from my phone is a 0 or a 1, so how would I go about making my arduino code? Would it be something simple like: if digitalread(rxPin) == 1: myServo.write(90); else: myServo.write(0) Do you think this should work?
@BytesNBits
@BytesNBits Жыл бұрын
Did you want the phone to talk to the Arduino so that you press a button on the phone which tells the Arduino to start the motor? If so you'll need to modify the project in the tutorial to get the button press passed over Bluetooth to the Arduino. Once you've got the signal on the Arduino you can then test the value and do the appropriate action. I hope this helps.
@mrmotorvator
@mrmotorvator Жыл бұрын
Very good pace, structure and explanation. Will now read about MIT AI with a better knowledge of what is possible and then run through lessons again.
@BytesNBits
@BytesNBits Жыл бұрын
Glad you found it useful.
Connect an SPI SD Card to Your Arduino - connection and coding
31:23
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 51 МЛН
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 35 МЛН
Получилось у Вики?😂 #хабибка
00:14
ХАБИБ
Рет қаралды 6 МЛН
HC-05 Bluetooth Module with Arduino-MIT App Inventor
27:57
BINARYUPDATES
Рет қаралды 963 М.
Bluetooth controlled Robot using Arduino Uno and MIT APP Inventor
14:39
Srishti Robotics
Рет қаралды 80 М.
How to Build an Android App to Control Your WiFi Enabled Arduino
12:55
Extracting Firmware from Embedded Devices (SPI NOR Flash) ⚡
18:41
Flashback Team
Рет қаралды 552 М.
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27