Still can't connect to Bluetooth module

112 views
Skip to first unread message

Old Timer

unread,
Dec 15, 2018, 8:51:05 PM12/15/18
to MIT App Inventor Forum
I have checked out numerous examples on how to connect to a Bluetooth module. Followed several different ways in which to connect and still I am not able to even see the Bluetooth module I am trying to connect to in the list. Can anyone help me figure out what I am not doing show me what I need to do in order to talk to this module. I can use BLE Scanner and LightBlue both work fine but I need to create a custom app that goes with a new product that I have developed. See Code Below: I am still using the MIT App inventor 3.0 can't seem to load MIT App Inventor 2 on my system on my Mac also using AI2 Companion

Thanks

Screen Shot 2018-12-15 at 8.41.36 PM.png



Chris Ward

unread,
Dec 15, 2018, 9:57:41 PM12/15/18
to MIT App Inventor Forum
Hi

Well, you probably aren't using App Inventor 3 as it is not out yet........To run App Inventor 2, try Firefox or Chrome instead of Safari.

The commands in your Blocks image are for Bluetooth Classic, not BLE, which is actually very different. So we need to know exact information about your hardware setup and then we can help you.

Questions:
  1. Bluetooth Module - Make, Model, Bluetooth version number
  2. Since it is a "Module", are you using it in conjunction with a seperate microcontroller?
  3. Android Device (e.g. SmartPhone) Make, Model, Android Version, Bluetooth version number

Old Timer

unread,
Dec 15, 2018, 11:10:25 PM12/15/18
to MIT App Inventor Forum
Thank for the Help

1.& 2. DSD TECH 2 Channels Bluetooth Relay Module for Remote Control Switch Compatible with iPhone and Android    4.3 and Later. Built-in SH-HC-08 Bluetooth 4.0 BLE module

DSD TECH 2 Channels Bluetooth Relay Module for Remote Control Switch Compatible with iPhone and Android 4.3

3. Android Galaxy J3 Achieve
    Model: SM-J337P
    Android 8.0


Old Timer

unread,
Dec 15, 2018, 11:24:13 PM12/15/18
to MIT App Inventor Forum
Also Chris I just tried running App inventor 2 from the internet using Chrome and it appears that because 1 is on my Mac it keeps running it. Here is the Logo of the App that's running.

Screen Shot 2018-12-15 at 11.23.12 PM.png


Old Timer

unread,
Dec 18, 2018, 10:43:15 AM12/18/18
to MIT App Inventor Forum
Hi Chris

Looks like your pretty busy based on all the posting I see. I was wondering how things are going with a response to my issues, Just getting a little antsy because I am just about done with the second prototype I have been working on that is also Bluetooth and I would really like to test it using a phone app that is customized to accommodate its needs. This new prototype utilizes Tinysine's 8 Channel Bluetooth relay board. 

Tintsine.png


Thanks

Chris Ward

unread,
Dec 18, 2018, 4:24:30 PM12/18/18
to mitappinv...@googlegroups.com
Hi again

Yes, we are all pretty busy at the moment - thanks for your patience.

Let's solve the App Inventor mystery. The logo is the logo - that never changes, except that oddly enough it did change in recent past! 
App Inventor has just had another bug fix release, so now we are on nb173. To find out if you are on this release when you open App Inventor:

Verify AI Version.png


Chris Ward

unread,
Dec 18, 2018, 4:31:25 PM12/18/18
to MIT App Inventor Forum
Hi

The DSD TECH 2 Channels Bluetooth Relay Module is that still in the equation, or has your Project moved on to Tinysine's 8 Channel Bluetooth relay board?

I see the latter has a Bluetooth dongle for PC/MAC. 

Whichever board you are using, we need the specifications from you. For example, does the Tinysine stand alone as a microprocessor + BLE as the DSD TECH 2 Channels Bluetooth Relay Module appears to. What files were included with this hardware?

Chris Ward

unread,
Dec 18, 2018, 4:44:59 PM12/18/18
to MIT App Inventor Forum
....also, there is a reason for asking for exact hardware Model and version numbers - it's because they can have the same name but a different release can use a different chip - sometimes a completely different chip from a different manufacturer. Despite the fact that BLE is a pretty decent standard, there are no standards in terms of how hardware manufacturers meet the spec, meaning there are different requirements, no single solution to setting up the comms.

Chris Ward

unread,
Dec 18, 2018, 5:10:35 PM12/18/18
to MIT App Inventor Forum
So, need your confirmation but it seems that the Tinysine board is modular and your version uses a 'Bluetooth Bee' to deliver Bluetooth comms - apparently Classic Bluetooth as opposed to BLE? (confirmation need via exact version).

I note that Tinysine offer their own Android App, so at least we know it actually works with Android, but we need information with respect to how to identify each relay and control each separately.

Old Timer

unread,
Dec 18, 2018, 5:53:03 PM12/18/18
to MIT App Inventor Forum
My screen looks the same as the one you posted Chris

Old Timer

unread,
Dec 18, 2018, 6:29:16 PM12/18/18
to MIT App Inventor Forum
Hi Chris

I have two different project that I am developing at the same time. one uses this DSD TECH 2 Channel Bluetooth 4.0 Relay Board. This is the only info they provide on their APP splash screen. Is there something else I need to find?

DSD Tech
UUID: 5AFB1BBD-33F4-EF4B-0FA2-9F1FD41931D7

This I got off the Amazon site as far as operational instructions. The rest I gave you in an earlier email.

Control instruction(Hexadecimal format):
Channel 1 ON: A00101A2
Channel 1 OFF: A00100A1
Channel 2 ON: A00201A3
Channel 2 OFF: A00200A2

This DSD TECH board

UUID: 5AFB1BBD-33F4-EF4B-0FA2-9F1FD41931D7

This is all I have and it's from their generic app

Old Timer

unread,
Dec 18, 2018, 6:36:01 PM12/18/18
to MIT App Inventor Forum
Thank Chris 

I think I understand. It is however a little confusing. I am able to use LightBlue with this board however it is very difficult to use as overtime I start  the app I have to re-enter the on and off values as described in the previous post. DSD TECH has their own app also.

Old Timer

unread,
Dec 18, 2018, 6:40:55 PM12/18/18
to MIT App Inventor Forum
OK I'll see what I can find out about that one. I use this Tinysine 8 Channel Bluetooth Board on the other project I am working on.

Chris Ward

unread,
Dec 19, 2018, 12:49:28 PM12/19/18
to MIT App Inventor Forum
In case you don't already know, there is a very nice program for producing Schematics: http://fritzing.org Works on the Mac and Windows.

Chris Ward

unread,
Dec 19, 2018, 5:20:46 PM12/19/18
to mitappinv...@googlegroups.com
Hi

I have contacted DSD for more details about how to use their relay boards via BLE. They are in China so there is a time gap (I'm in the UK). In the meantime, I have made a Skeleton App that you can try. In the Blocks you can see how to test that Bluetooth is enabled on the SmartPhone, how to scan for BLE devices, toggle buttons etc. That would all be pertinent for your 8 Channel App too.

I can't attach the Project file here because it includes the BLE extension and Google do not permit files with extensions. So I have made it available on my website:


Gui_BLE_Relay_2_Channels.png



Edit: Blocks image removed, see next post

Chris Ward

unread,
Dec 19, 2018, 8:06:01 PM12/19/18
to MIT App Inventor Forum
Hi again

I made an error in the Blocks of BLE_RelaySwitch.aia, so please delete it and download BLE_2_RelaySwitch.aia

In that new file, a BLE type connection is used, but apparently there is compatibility with Bluetooth Classic, which might mean we should use Classic, since you are not running the Bluetooth module from a battery power supply? So, if the BLE approach fails, we can try Classic and see if that works.


Blocks_BLE_Relay_2_Channels.png




Old Timer

unread,
Dec 19, 2018, 8:46:58 PM12/19/18
to MIT App Inventor Forum
Thanks for the help Chris. BLE_2_RelaySwitch was able to connect with no issues. When I run the program using AI2 Companion on the phone I get the following error however when I attempt to turn a relay on.

Screen Shot 2018-12-19 at 8.35.56 PM.png


Chris Ward

unread,
Dec 19, 2018, 11:04:00 PM12/19/18
to MIT App Inventor Forum
Hi

That must be a bug in my code, I will see if I can find it. Hypothetical at the moment because we don't know if the Bluetooth send data method is correct.

Chris Ward

unread,
Dec 19, 2018, 11:18:49 PM12/19/18
to MIT App Inventor Forum
Hi again

The 8-Channel Relay supports Bluetooth EDR, so I have put a Skeleton App together for this one too. Again, since I don't have the target device (relay board), I have no idea how close (or far away) the code is to sending viable instructions. The basic framework though should be ok. Ten Channel buttons in all (All On, All Off, plus a button for each individual channel). 

The Project File (currently) is not using an Extension, so it is attached to this Post.

Gui_BT_EDR_8_RelaySwitch.png


Blocks_BT_EDR_8_RelaySwitch.png



BT_EDR_8_RelaySwitch.aia

Chris Ward

unread,
Dec 19, 2018, 11:47:53 PM12/19/18
to MIT App Inventor Forum
Hi

2-Channel Relay file, fixed the bug I think (can't test here). I do not know if the data send method or the data itself is what the board wants - the only way to know (at the moment, still waiting for info) is to try the App and see what happens.

Old Timer

unread,
Dec 20, 2018, 6:03:27 AM12/20/18
to MIT App Inventor Forum
I think where getting closer here is what I am getting now. The app still connects fine. I am still getting an error however (see below).

Screen Shot 2018-12-20 at 5.57.13 AM.png


Chris Ward

unread,
Dec 20, 2018, 6:43:12 AM12/20/18
to MIT App Inventor Forum
Ah - we have gone forward one step, but we are two steps back on the BLE. I'm going to butcher the file to try another angle. 

Chris Ward

unread,
Dec 20, 2018, 6:56:36 AM12/20/18
to MIT App Inventor Forum
....can you test the 8 RelaySwitch App? 
Message has been deleted

Chris Ward

unread,
Dec 20, 2018, 7:37:45 AM12/20/18
to MIT App Inventor Forum
Hi again

A different approach to the two-relay board. This may not be any better than the previous test but since we are waiting for the manufacture to supply their technical info, might as well try something :)

See the attached Project File: BT_2_RelaySwitch_A.aia

I'm away from my desktop now for probably the rest of today, but please post your test results here.
BT_2_RelaySwitch_A.aia

Chris Ward

unread,
Dec 20, 2018, 11:27:05 AM12/20/18
to MIT App Inventor Forum
Hi

So, DSD got back to me. For BLE, the Uuids that we had were wrong apparently.

New Project File: BLE_2_RelaySwitch_C.aia

Available for download from my website:
Message has been deleted

Old Timer

unread,
Dec 20, 2018, 12:06:15 PM12/20/18
to MIT App Inventor Forum
So Chris is every UUID unique like a serial number? I have included the App screens also for the two projects I am working on just to put a face to the projects.

Screen Shot 2018-12-20 at 11.33.35 AM.png

Screen Shot 2018-12-20 at 11.59.27 AM.png


Chris Ward

unread,
Dec 21, 2018, 2:49:53 AM12/21/18
to MIT App Inventor Forum
Hi

In the case of the relay boards, which are "dumb", the Uuids are not unique. It might be possible to flash them with unique codes but that's not mentioned in the specifications.

Both of your GUIs look great, very professional graphics.


Old Timer

unread,
Dec 21, 2018, 11:30:21 PM12/21/18
to MIT App Inventor Forum
Sorry about the reply on your email. Long day.

Chris I anticipate thousands of these 2 Channel Bluetooth Relay modules to be used in the production version of this project.The potential of 2 or more units in close proximity of each other is high. Will the possibility of someone else being able to connect to the owners product exist? If so is there a way to assign a unique passcode to the product owners device so there would be no chance for any other users who have the same product to accidentally gain control? 

Chris Ward

unread,
Dec 22, 2018, 6:31:49 AM12/22/18
to MIT App Inventor Forum
Hi James

With the actual device under test, it seems most likely that they are insecure and cross-customer issues could occur. I see the unit as being aimed at the hobby/electronics enthusiast, so there might be other aspects about the board that are undesirable for production, I don't know, I have never seen one so I can't judge that aspect.

You will need to query this with the manufacturer, it's beyond my remit as a MIT App Inventor Power User.

The possibilities are:
  • The boards are already using a flashable chip that can be given a unique ID via a PC based program or special device
  • The boards are not flashable but the Manufacturer is willing to make a batch with unique IDs
  • The Manufacturer/other can supply a commercial grade board with unique IDs
If you can buy in large quantities I'm sure you can find what you need and probably keenly priced. One tip with that regard is to haggle over the price (input from my wife, she is Chinese).

So, with my App Inventor hat on, I'm keen to know: have you got the prototype to work with BLE_2_RelaySwitch_C.aia?




Old Timer

unread,
Dec 22, 2018, 8:38:19 AM12/22/18
to MIT App Inventor Forum
Hi Chris

It is in fact working. There are some issues that I am working through because of the way the buttons need to work but I am getting there. Also there is a port to flash the part. However I thought there was a command on the Bluetooth module to set a unique password. 

Screen Shot 2018-12-22 at 7.47.10 AM.png


Chris Ward

unread,
Dec 22, 2018, 9:16:48 AM12/22/18
to MIT App Inventor Forum
Hi James

That's very interesting. Did the board come with any documentation about that P3?  It could be that a Unique ID could be applied using AT commands via a PC software such as the Arduino IDE. It is generally not something that should be done via Bluetooth, since that in itself could present security problems.


Old Timer

unread,
Dec 22, 2018, 10:05:47 AM12/22/18
to MIT App Inventor Forum
No it did not Chris. I will contact the supplier however. Also Chris I am having an issue with disconnecting the module, using the "DISCONN" button and then reconnecting the module, using the "SCAN" button . The "ListView_DevicesFound" dialog box is not visible. I thought by adding this code that it would reenable it but that is not the case. It Show the dialog "Select Target Device from List" in the "Label_Msg" however.

Screen Shot 2018-12-22 at 10.04.08 AM.png

 


Chris Ward

unread,
Dec 22, 2018, 12:14:13 PM12/22/18
to MIT App Inventor Forum
Hi

That should be True or False (see other similar blocks)

Old Timer

unread,
Dec 22, 2018, 2:39:09 PM12/22/18
to MIT App Inventor Forum
 Right On Chris!

i think we can close this side of the help you have provide. I will attempt to finish this one on my own. I really appreciate all the help you have provided. Is this project something that should be posted when I finish it?

Chris Ward

unread,
Dec 22, 2018, 5:04:55 PM12/22/18
to MIT App Inventor Forum
Hi James

I will add it as a "how to" on my site, in generic form, along with some others I have yet to polish for upload. When your Product is ready to Market, I think it would be great if MIT could refer to it in a newsletter - exactly the sort of thing that will encourage the youngsters to believe in their ideas. 



Mich Ro

unread,
Dec 22, 2018, 7:05:36 PM12/22/18
to MIT App Inventor Forum
Hi
Just for your info
I have version 3 installed on my MacBook
Installed it yesterday.


Chris Ward

unread,
Dec 22, 2018, 7:48:53 PM12/22/18
to MIT App Inventor Forum
No you haven't Mich, we are on App Inventor 2, version nb173 [12/15/2018]. It is not "installed" either, it is a Cloud based application.... 

Chris Ward

unread,
Dec 23, 2018, 8:19:43 AM12/23/18
to MIT App Inventor Forum
Hi James

You can indeed flash the chip with a unique ID :)

DSD Connection Ids.jpg

From Eric of DSD TECH:


Yes,it is possible. There is a UART interface in the board. If you have a USB to ttl Converter , you can give each board a unique ID.
About USB to ttl Converter ( please search "B07BBPX8B8" or "B072K3Z3TL" ).

and DSD TECH provide a free software to modify bluetooth name( unique id for each board)
With this software, you can quickly complete the Bluetooth parameter settings, such as Bluetooth name and baud rate.
You can download the software at the following URL:


Old Timer

unread,
Dec 23, 2018, 10:20:29 AM12/23/18
to MIT App Inventor Forum
WOW! Chris you are really, really going above and beyond in support on these projects. I so appreciate all the help you have given me. I would be honored to have you reference our projects on you website. I am all about helping community. So much so that I started a non-profit back in 2012 designed to helps veterans. One of the other App projects, not related to NIRDCO, that I would love to build is an App to provide information to veteran. It requires a huge database that will need to be accessed to retrieve this info.

Chris Ward

unread,
Dec 23, 2018, 11:39:12 AM12/23/18
to MIT App Inventor Forum
Hi James, thanks.

The Veterans database sounds interesting. I'll warn you now, that will be a challenge and a half to create :)

Chris Ward

unread,
Dec 23, 2018, 11:54:45 AM12/23/18
to MIT App Inventor Forum
Hi again James

.... something missing - did the BT_EDR_8_RelaySwitch.aia file work?


Old Timer

unread,
Dec 23, 2018, 1:39:13 PM12/23/18
to MIT App Inventor Forum
This one will require a special group who will need to monitor, phone calls and keep the information current. Basically a full time  J O B for a group. Perhaps a group of kids? Maybe the App could pay for the upkeep (25 million veterans in US alone, Another 50 million still in service) ??? something to think about.

Old Timer

unread,
Dec 23, 2018, 1:43:19 PM12/23/18
to MIT App Inventor Forum
Hi Chris, I am not at the location where the project is and have not been able to try it out. I am however starting to design the GUI for it in anticipation that your code is golden, as always. 

Chris Ward

unread,
Dec 24, 2018, 8:35:50 PM12/24/18
to MIT App Inventor Forum
Hi James

New info about the 8-Channel Relay from TinySine re Unique IDs.

DIY - Each board can be given a unique ID via a PC, USB to USB mini cable and an Xbee USB adapter module (only one required):

TinySine have PC software supporting this:

If you purchase the boards in bulk, they will set Unique IDs on the production line for you.

Have a good Holiday!

Old Timer

unread,
Dec 27, 2018, 10:56:59 AM12/27/18
to MIT App Inventor Forum
Hi Chris

Just wanted to give you an update on the 8 channel Bluetooth relay board App. It has proven to be to distracting trying to code in the field. I have ordered a second board that I can use at the office to do the work. It should be here within the week. Not sure if you want to close this thread and start a new one once I am able to get back at it or if you just want to put this one as still pending. I will let you know as soon as the board arrives and I am back at it.

Also I wanted to wish you Happy Holidays. 

Chris Ward

unread,
Dec 27, 2018, 5:51:39 PM12/27/18
to MIT App Inventor Forum
Hi James

Yes, it's own Forum Post would be good - first entry, a link to this one.

I wish you Happy Holidays too!
Reply all
Reply to author
Forward
0 new messages