Shop OBEX P1 Docs P2 Docs Learn Events
RN-42 bluetooth for Board of education — Parallax Forums

RN-42 bluetooth for Board of education

HindsVo-TechHindsVo-Tech Posts: 5
edited 2014-04-11 10:20 in Accessories
Hello, I am trying to locate the necessary instructions to integrate an RN-42 Bluetooth module with the Board of education series BOE-BOT. The goal is to make a boe-bot function via cellphone or tablet with one of the available applications on the android market. We are having troubles locating any code or instructions to do so. If you could please provide us with either a resource link or instructions on how to make this build it would be greatly appreciated. If this build is not possible then if you could provide us with the information on what type of hardware would make it possible. We have seen this idea work in a couple of videos but none of them had any links with information and schematics. Any help you could give us on this issue would be greatly appreciated.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-03-24 16:35
    Hello,

    The biggest barrier I have found with this is not so much in the code on the BOE-Bot, but rather the Bluetooth App for the phone. The way some of them deal with what is sent to the remote end makes it difficult sometimes to work with the BASIC Stamp 2, however I will dig out my BOE-Bot tomorrow and see if I can at least get it working to demonstrate. Please follow-up if you would like me to do this.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2014-03-25 22:55
    but rather the Bluetooth App for the phone


    This may help if you want to write it.

    Basic4android is the simplest and most powerful Rapid Application Development (RAD) tool available for the Android platform



    http://www.basic4ppc.com/

    RN-42 Bluetooth


    http://www.basic4ppc.com/android/forum/threads/bluetooth-microcontroller-communication.24604/#content





    http://www.basic4ppc.com/android/forum/attachments/bluetooth-zip.15147/

  • HindsVo-TechHindsVo-Tech Posts: 5
    edited 2014-03-26 10:37
    @ Mr. Savage:
    I would really appreciate that demonstration Mr. Savage.

    @ Mr. Lawerence:
    I am looking into the software that you posted. It looks promising, so thank you for that.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-03-26 10:50
    I am in the Rocklin office today, however If I recall correctly the code wasn't super smooth because of how fast the data is sent from the Android side.
  • HindsVo-TechHindsVo-Tech Posts: 5
    edited 2014-03-26 11:25
    Hello Again Everyone,

    Right now I am using Itead Studio and it is working with Boe-Bot. The issue that I am having is that the the code of the program only works in short bursts and only after you release the "buttton". For instance, if you press the forward "button", the Boe-Bot will go forward in a short jerk. The problem here is that I am looking for something that will continue to go forward until I release the "button". I've read what Mr. Savage said about his code not being smooth due to the fast nature of the data speed. Would this have something to do with not finding any software compatible with the features I am looking for? I have looked around the Google Play store looking for applications compatible with RN-42, do you have any other recommendations that may give me what I am looking for. I also am not adverse to trying to create an application, though I would definitely need some ground code to work from. P.S. I really appreciate any help you could give me.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-03-26 15:01
    What you're describing is what I experienced with the code for the Boe-Bot application for Android. That is what I was looking into and trying to fix. The problem stems from the fact that the BASIC Stamp can only do one thing at a time and the servos need to be refreshed every ~20 ms, but you also need to be at SERIN to get the next byte. I had something I was working on. I will re-test it and post it tomorrow along with a link to the app I am using.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-03-27 15:20
    Okay, I found my code and cleaned it up a bit (read: made it more readable). This code was literally written in about 5-10 minutes. I used a Logic Analyzer (Saleae) to determine what was being sent to the RN-42 Bluetooth Module. Turns out it was simply the WASD keys, so in theory you could connect from a PC with Bluetooth and use a terminal and these keys to do the same thing. However I downloaded the following Android App, Boe Bot Controller onto my phone and used that. Sadly this App has no STOP button, just the 4 directions and the ability to send a value via input box. Also, when you press any direction button the data is sent out in a continuous stream until you release the button. Because of this I opted to only refresh the servos when data was received by the RN-42 Bluetooth Module. The code is attached to this post. Here is how the RN-42 Bluetooth Module was attached to my BOE-Bot:

    IMG_20140327_131329_605.jpg
    IMG_20140327_131803_796.jpg
    IMG_20140327_131816_687.jpg


    Please note that this BOE-Bot has the High-Speed Servos and the Lithium Ion Battery Pack for the BOE-Bot. Here is a video of this code in action on this robot. If you have any questions please let me know.

    The next thing I am going to try is the following Android App called, Robot Control. I have not tried this one yet, but it has a stop button, which means the code can be made more robust.
  • jplrobotjplrobot Posts: 12
    edited 2014-03-27 18:21
    Chris,

    Thank you for this code and "how to". I am sure it will help a lot of folks who purchased the RN-42 having visions of a truly remote controlled robot. I will look to adapt your code to function via a Bluetooth enabled laptop computer.

    Once again, thank you for your efforts.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-03-28 09:18
    You're welcome. Once I decode what the other application is sending out I will create a more robust application using it. For now this was more of a quick and dirty, "Here's how you might do this". Hopefully it will inspire someone to make something more of it.
  • HindsVo-TechHindsVo-Tech Posts: 5
    edited 2014-03-31 10:58
    Wow, thank you so much for your help on this. You have gone above and beyond. Currently I am trying to build an Android Application that revovles around the RN-42 that incorporates grippers and offers more mobility in the sense of additional direction options (oblique forward right, etc.). Your code has made this within reach. When I finish I'll be sure to publish everything here.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-02 08:25
    You're welcome. Since there was no example of using the module in such a manner it was a reasonable request. There should be one. I'm glad it helped.
  • jplrobotjplrobot Posts: 12
    edited 2014-04-11 04:05
    Chris,

    Tried out your code on my BOE-Bot without success. I am assuming that the computer transmits the code [via its Bluetooth connection] to the Stamp via the RN42 module. What are some of the reasons for a “No BASIC Stamps found” error other than low batteries. Here is what I have done so far:
    1. Paired the RN42 Module to the Bluetooth connection on my Sony Vaio laptop running 32-bit Vista. Passkey used was 1234.
    2. Device name is RN42-6055. Service Class is Serial Port and Service Name is SPP. Port is COM40, which is my Bluetooth port [only port shown] in Device Manager.
    3. RN42 Bluetooth module mounted on BoeBot per Chris Savage images. [ RN42 module GND to Vss; Vin to Vdd; RTS and CTS jumpered; TX to P0].
    4. Turned BoeBot switch to Position 1 and observed Green LED in configuration mode. Then it went into Discoverable/Idle mode.
    5. Connected laptop to RN42-6055. Now shows as connected in the laptop dialog. Green LED on RN42 still blinking in Discoverable/Idle mode.
    6. Under Edit/Preferences Terminal #1 COM Port is COM40. There is only this port shown in the Serial Port search list.
    7. Ran Chris Savage’s Bluetooth BOE-Bot Demo.bs2
    8. Green LED and Blue LED ON solid.
    9. Download Progress shows COM40 with Loopback [NO] and Echo [YES]
    10. Communication Error “No BASIC Stamps found”
    11. Click Okay.
    12. Green and Blue LEDs still on solid.
    13. Disconnected the Bluetooth connection from the laptop.
    14. Blue LED turned off. Green LED is once again in Discoverable/Idle mode.
    15. Going back through the forum, I replaced the batteries with a fresh set.
    16. No change from above sequence of events in many attempts after the fresh set of batteries.
    I am missing something very obvious I think. My plan was to run Chris’ software and then use another Terminal to control the BOE-Bot. But the “No BASIC Stamps found” has thrown me off track. Should I run the code with the USB cable connected to the BOE-Bot as a first step and then attempt to go wireless? Any suggestions to make this work? Thanks.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-11 09:10
    The only thing I don't see in your list of things you did was move the switch to position #2. In position #1 where you did mention moving the switch, the servos do not get power.

    Also note that every PC I tested pairing the RN-42 Bluetooth Module to produced two COM port entries. Only one worked, but two were listed for each RN-42 I paired up.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-04-11 09:13
    Actually, re-reading your post again almost sounds like you're trying to download the program over the Bluetooth connection. You mentioned downloading it after you attempted to connect to the Bluetooth device. The code I posted should be on the BOE-Bot before you ever try to connect with your terminal program.
  • jplrobotjplrobot Posts: 12
    edited 2014-04-11 10:20
    Chris,

    Thank you for nudging me in the right direction. I had wrongly assumed that the RN42 module would carry the code to the Stamp. All is well now and the BOE-Bot can now move about on its own thanks to your code. Regarding the ports, I observed that BT Port (COM40) is the only port available in Device Manager. When I plug in the USB cable to download the code to the Stamp, it creates a USB Serial Port (COM30). I disconnected the USB cable after the code tokenized and downloaded [Green and Blue LEDs ON solid]. The USB Serial Port no longer appears in Device Manager. After this, however, the BOE-Bot responds wirelessly to commands [w, a, s, d] from a Terminal. So a very big thank you for helping me to get it right.
Sign In or Register to comment.