Bluetooth interfacing to Outside World

42 views
Skip to first unread message

Old Timer

unread,
Jan 9, 2019, 5:26:19 PM1/9/19
to mitappinv...@googlegroups.com
Looking for Chris:

Hi Chris

I guess the last post I submitted wasn't recorded and that post we have been talking on has since been closed out. Is there something we can do about that because this is really a continuation of that topic?

I just received the 8 Channel Relay Board from TinySine. Tried out the software we are working on BLE_2_RelaySwitch_C.aia and I was not able to connect. I notice there is no ListView attached to it. Is that a problem? Also would you happen to have any time, I know you are extremely busy, to add some comments to the Bluetooth section of the code. Since I am really new to this type of Bluetooth coding I am having some difficulty following along. I get the rest of the code

Old Timer

unread,
Jan 9, 2019, 6:44:54 PM1/9/19
to MIT App Inventor Forum
Something Interesting Chris

Out of curiosity I ran the code for the BLE_2_RelaySwitch_C.aia code and was able to connect to the TinySine 8 Channel Relay Board. Of course the relay controls do not work but the Bluetooth connection code seems to work fine.

Chris Ward

unread,
Jan 10, 2019, 10:59:11 AM1/10/19
to mitappinv...@googlegroups.com
Hello James

The TinySine 8 Channel Relay is different, I produced a different set of files for it, which you should find on the original Forum Post (you can't add to that Post but you can download from it).

Chris Ward

unread,
Jan 10, 2019, 11:44:14 AM1/10/19
to MIT App Inventor Forum
The original Post
The  App Inventor Project (.aia) is attached to the post, it does not use an extension.
Post Date: 20/12/2018

Old Timer

unread,
Jan 10, 2019, 3:55:33 PM1/10/19
to MIT App Inventor Forum
Right on Chris

BT_EDR_8_RelaySwitch.aia is the last version I believe you sent me. That's the one I say will not link to the module. The other project I am working on uses the DSD Tech 2 Channel Relay board. That is the one that does link up to my TinySine 8 Channel Relay board even thought the control for the relays are a different protocol and do not work the Bluetooth does link to the board.

Chris Ward

unread,
Jan 10, 2019, 4:57:32 PM1/10/19
to MIT App Inventor Forum
Hi James

OK - by link I think you mean connect. BT_EDR_8_RelaySwitch.aia is using "Classic" Bluetooth (as opposed to BLE). It could be then that we should use BLE, but that wasn't the guidance received from TinySine.

Questions about the test device
  1. What Device (Smartphone) are you testing on?
  2. What is the exact version of Android?
  3. What is the exact version of Bluetooth?
This could present an issue for the final product because there is a lot of variation between Smartphones concerning Android Version and Bluetooth version, per phone. Some phones that claim support for BLE will not work with BLE unless they are running on Android 5.0 or above. They should be backwards compatible with Classic BT, but....... doesn't always work out that way - I think for some of the manufacturers, BT is just another tick on the features list for marketing, without enough effort to ensure it can communicate with more than just another phone of the same make/model.



Old Timer

unread,
Jan 10, 2019, 8:22:05 PM1/10/19
to mitappinv...@googlegroups.com
Hi Chris

Yes, the phone has linked to the PC board through Bluetooth.

To answer your other questions:
1. Samsung Galaxy J3 Achieve
2. Version 8.0.0
3. See attached image 


2019-01-10 20.10.03.jpg

I can note that when I upload the software to Google Play that should help right? Perhaps I can offer 2 versions? I can also refer our customers to some of the canned software that is available out there. That is how I have been using this board until now.

Chris Ward

unread,
Jan 10, 2019, 9:41:11 PM1/10/19
to MIT App Inventor Forum
Hi James

The image proves that BT-EDR should work, and also that the BLE is the earliest version thereof (2010), which we might wish to avoid if we can.

So, I think my code should work, I will take a look at it tomorrow (Friday 11th here), to see if there is a bug.

Old Timer

unread,
Jan 10, 2019, 9:48:38 PM1/10/19
to MIT App Inventor Forum
Thanks Chris

I wish I understood it better I could debug it myself. my expertise however does not extend this far. I understand the flow as far as manipulating the relays but the Bluetooth  is something else. Plus I have only been looking at this software for a couple of weeks.

Chris Ward

unread,
Jan 12, 2019, 6:11:50 PM1/12/19
to MIT App Inventor Forum
Hi James

I'm setting up a hardware test here to mimic relay control, as I can't see any bugs in the file - with the hardware, I should be able to catch the errors if there are any.

We can also try using BLE, but I recall the manufacturer's response suggesting that the board is not really good to go with BLE.

Old Timer

unread,
Jan 12, 2019, 6:32:35 PM1/12/19
to MIT App Inventor Forum
Hi Chris it's me again. Hey it looks like I got the software to pair but now I am getting another error see attached.

Screen Shot 2019-01-12 at 6.18.30 PM.png


When I press a button on the phone.


2019-01-12 18.19.55.jpg
If you look at the code you can obviously tell I don't know what the heck I am doing

Trailer Mate Code.png


Chris Ward

unread,
Jan 12, 2019, 7:00:07 PM1/12/19
to MIT App Inventor Forum
Hi James

There are a some things wrong with your version of the code - did you test my code without modification?

Old Timer

unread,
Jan 12, 2019, 7:03:22 PM1/12/19
to MIT App Inventor Forum
I did Chris. It would not pair with module. :(

Old Timer

unread,
Jan 12, 2019, 7:05:18 PM1/12/19
to MIT App Inventor Forum
I wasn't sure if it was just because there was no list to choose from or not.

Chris Ward

unread,
Jan 12, 2019, 7:18:53 PM1/12/19
to MIT App Inventor Forum
...If there is no list to choose from, that could easily be something else, such as the device is there but not found. However, if Classic BT is failing to find the device but BLE is finding it, then we should use BLE. You can't mix and match the comms though, so you can't send with Classic having connected with BLE - you must send with BLE.

Chris Ward

unread,
Jan 12, 2019, 7:27:59 PM1/12/19
to MIT App Inventor Forum

Typos.png


Old Timer

unread,
Jan 12, 2019, 7:35:23 PM1/12/19
to MIT App Inventor Forum
I thought as much Chris. My Problem is that I do not know enough about Bluetooth Classic vs. Bluetooth BLE to be of much help.

Old Timer

unread,
Jan 12, 2019, 7:45:57 PM1/12/19
to mitappinv...@googlegroups.com
I new this wasn't right Chris. Mixing the two didn't make much sense. When I set BluetoothClient1.IsConnected  = True then the buttons do not respond to the routine. However I get the error. I also agree. Using an image to make a decision does not make sense. Can I use GotFocus or Buttondown = True

Chris Ward

unread,
Jan 12, 2019, 8:32:11 PM1/12/19
to MIT App Inventor Forum
Hi James

There is a snippet on my website about toggling image buttons using a list to store status as 1 or 0 (True or False):

Old Timer

unread,
Jan 12, 2019, 8:54:22 PM1/12/19
to mitappinv...@googlegroups.com
Chris Got it to pair using BLE but I could use some help rewriting button code. See Code attached. I an sure there are some other errors in the code as well. :)

Trailer Mate Code.png


Old Timer

unread,
Jan 12, 2019, 8:57:34 PM1/12/19
to MIT App Inventor Forum
Not sure what happened Chris just had something weird happen to my computer system, Locked up and some other things. I opened another post because this one wouldn't let me do any addition posts. STRANGE!
Reply all
Reply to author
Forward
0 new messages