Arduino Bluetooth Control From Your Mobile Phone Using MIT App Inventor

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 มี.ค. 2021
  • 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 ปีที่แล้ว +8

    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 ปีที่แล้ว +2

      Glad it was helpful!

    • @brunodragas8661
      @brunodragas8661 5 หลายเดือนก่อน

      ​@@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 5 หลายเดือนก่อน

      ​@@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

  • @khaledabd-elhalim1899
    @khaledabd-elhalim1899 2 ปีที่แล้ว

    Thank you so much, this is exactly what I needed😍🥰

    • @BytesNBits
      @BytesNBits  2 ปีที่แล้ว

      You’re welcome 😊

  • @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.

  • @prashantparkhe6125
    @prashantparkhe6125 ปีที่แล้ว

    A complete tut great work 👏 👍 Many Thanks 😊

  • @rinokentie8653
    @rinokentie8653 2 ปีที่แล้ว

    Very useful! Thanks.

    • @BytesNBits
      @BytesNBits  2 ปีที่แล้ว

      Glad it was helpful!

  • @petermccool9396
    @petermccool9396 2 ปีที่แล้ว +1

    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.

  • @keithmefferd8728
    @keithmefferd8728 5 หลายเดือนก่อน

    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  5 หลายเดือนก่อน

      Glad you found it useful. Thanks.

  • @takudzwamutepfa9952
    @takudzwamutepfa9952 6 หลายเดือนก่อน +1

    You gained a new subscriber 🔥

    • @BytesNBits
      @BytesNBits  6 หลายเดือนก่อน

      Great! 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!

  • @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 5 หลายเดือนก่อน

      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.

  • @joanacoronelsoler3977
    @joanacoronelsoler3977 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน

      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.

  • @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  29 วันที่ผ่านมา

      I don't think it needs a connection but I haven't actually tried it.

  • @manfredbogner9799
    @manfredbogner9799 หลายเดือนก่อน

    Very nice

    • @BytesNBits
      @BytesNBits  หลายเดือนก่อน

      Thanks

  • @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.

  • @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?

  • @umutkayacan7659
    @umutkayacan7659 3 ปีที่แล้ว

    Love it!

    • @BytesNBits
      @BytesNBits  3 ปีที่แล้ว +1

      Thanks!!

    • @umutkayacan7659
      @umutkayacan7659 3 ปีที่แล้ว +2

      @@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 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +2

      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.

  • @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

  • @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 ปีที่แล้ว +2

      Thanks for the to. I'll give that a go.

  • @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.

  • @user-bk7ee4xb3m
    @user-bk7ee4xb3m 8 หลายเดือนก่อน

    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  8 หลายเดือนก่อน +1

      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 8 หลายเดือนก่อน

      @@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  8 หลายเดือนก่อน

      @@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.

  • @semnal.m2581
    @semnal.m2581 2 หลายเดือนก่อน

    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  2 หลายเดือนก่อน +1

      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.

  • @andrewshepherd7429
    @andrewshepherd7429 6 หลายเดือนก่อน

    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  6 หลายเดือนก่อน

      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 6 หลายเดือนก่อน

      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.

  • @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  ปีที่แล้ว +1

      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..

  • @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 2 หลายเดือนก่อน

    Can you please help me with error 507: unable to connect error while connecting the app with my laptop? Thank you..

    • @BytesNBits
      @BytesNBits  2 หลายเดือนก่อน

      I'm not sure what that error means.

  • @dungnguyen-si2sz
    @dungnguyen-si2sz 7 วันที่ผ่านมา

    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  7 วันที่ผ่านมา +1

      I'm not sure what that would be. Do you get any screen prompts?

    • @dungnguyen-si2sz
      @dungnguyen-si2sz 6 วันที่ผ่านมา

      @@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.

  • @thiensuutv1286
    @thiensuutv1286 ปีที่แล้ว

    hi....i want to create on time and off time to on/off led!
    can you help me!

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว +1

      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 ปีที่แล้ว

      @@BytesNBits Do you have any examples related to this?
      can i have a reference?

    • @BytesNBits
      @BytesNBits  ปีที่แล้ว

      @@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.

  • @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/

  • @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.

  • @junaidahmad6753
    @junaidahmad6753 9 หลายเดือนก่อน

    i used the same method but Bluetooth connection interface is not open

    • @BytesNBits
      @BytesNBits  9 หลายเดือนก่อน

      Can you connect to the Arduino in the terminal app on your phone?

  • @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.