Bluetooth + WS2812 LED's

JBWolfJBWolf Posts: 369
edited 2020-07-10 - 19:59:13 in Propeller 1
Hello,
I need to control a few feet of WS2812 LED's via phone app and am assuming BlueTooth is the best way to go about it.
This will be my first time programming a propeller for bluetooth, and I'm hoping theres already an app available for iPhone/Android.
The $50 modules are a bit much, but I found HC-05 and HC-06 on ebay quite inexpensive.

Which BT module should I go with... HC-05 or HC-06
What is the difference between them?
Will any of these OBEX modules work directly with them or will I need to write one from scratch?

Thanks!

«1

Comments

  • JonnyMacJonnyMac Posts: 6,846
    edited 2020-07-10 - 20:09:38
    I did a fun little Bluetooth to WS28xx project when I was assisting EFX-TEK with product development and trade shows. This should get you going.

    -- http://www.efx-tek.com/php/smf/index.php?topic=2352.0

    I wrote a little Android app using App Inventor (blocks style programming) but any Bluetooth terminal will do. The HC-8+ is a P1-based prop controller (I designed it for EFX-TEK, and like to use it in client projects).
  • I see there are master, slave, then master + slave modules...
    Assuming slave is ok?... Such as this one
  • JonnyMacJonnyMac Posts: 6,846
    edited 2020-07-10 - 22:03:28
    Master and slave mean they're configured to communicate with each so you can simulate a wired connection immediately after power-up. You want it to operate in vanilla UART mode.

    As long as it has 3.3v IO, that board should be fine.
  • JBWolfJBWolf Posts: 369
    edited 2020-07-10 - 22:31:05
    So master + slave modules are only needed for self testing?
    Does a master module only send & slave only receive? or do they both have 2-way?

    Its a waterproof outdoor sign, cnc machined and the led's light it up at night.
    The configuration method for this project will be:
    Phone app sets what color & brightness or auto color change mode
    Phone app can set on/off time schedule or light sensor mode
    And basic on/off

    So I dont absolutely need bi-directional comm, but it would be nice to have the sign show on the phone app what mode its in and what time schedules are set.
    Does that mean I can use any of the HC-06 bluetooth modules? mast/slave/both?
  • JonnyMacJonnyMac Posts: 6,846
    edited 2020-08-04 - 03:01:51
    Once you have a connection with the BT module, it acts like any other serial port. Get a module, connect it to your Propeller, and do some experimenting. Or hire a consultant (I'm a consultant). :)
  • Peter JakackiPeter Jakacki Posts: 9,367
    edited 2020-07-11 - 00:02:35
    I've used the HC05/06 modules for many years in conjunction with Tachyon. Once Tachyon has been loaded onto the Prop then all other programming and "commands" can be done over Bluetooth. There was one project I detailed on a Google doc that scheduled driveway gate opening and closing times as well as allowing for remote control over Bluetooth and RFID entry and logging etc. I have used a couple of different Android apps including "Serial Bluetooth Terminal" by Kai Morich which includes user configurable buttons that I might load a command like OPEN or CLOSE onto but still have the serial terminal console available.

    I also modified one of these apps for a tablet so that I could control the color and size of characters and backgrounds etc via Bluetooth. This was especially important since it needed to monitor and provide operator controls for 1.5MVA "regulator".

    SInce I use a 4x2 connector or a 5x1 in place of the 4x1 Prop plug connection, I also have +5V available on the header so it is an easy thing to plug a Bluetooth module in on the serial port of my board.

    BTW, Tachyon has an on-chip OBEX practically and also includes WS2812 drivers and high-level operations..
  • JBWolfJBWolf Posts: 369
    edited 2020-07-11 - 00:13:36
    Thanks guys!
    I enjoy learning new things like this, but im so new that I am wary of wasting money on the wrong products and a week or two in shipping and fruitless experimenting.
    since bluetooth is brand new to me, understanding the basics gives a great jump over trial and error... things that are so basic that you probably assume I already know.
    for example I wasnt sure if a slave module is full duplex or if I need a master + slave module for that... and I'm not sure what you mean by a 'VT Module'... I assume that was a simple typo and meant to be 'BT Module'?

    I've already completed the WS2812 programming, scheduling and so forth on the prop.
    Understanding which bluetooth module to buy and programming basics helps incredibly.
    I appreciate your time helping me get started!
  • You're going to find it's very simple -- it's just serial.
  • HC05 can be either master or slave, whereas the HC06 is a slave. But slave is what you want since the phone/PC is the master and initiates the connection. I normally communicate with these modules at around 230400 and they have a rather large buffer too, so 115200 is fine but you do need to configure them first unless you drop back to slow n pokey 9600.
  • Any advice on a phone app?
    Should I search app store for bluetooth serial, or is there one you can recommend already suited for WS2812?
  • I mentioned an app already but none of these apps have anything to do with WS2812, that's up to your code to accept the data and commands from serial, which is why I use Tachyon because it is a cinch and I can load new code over the Bluetooth.
  • I'm with Peter -- unless you want to create a custom app, it may be best to use a generic terminal on your phone. That demo that I pointed you to has a very simple command parser.
  • This is a modified Bluetooth terminal running on a cheap tablet and using a HC06 talking via Tachyon.
    3024 x 4032 - 2M
  • JonnyMacJonnyMac Posts: 6,846
    edited 2020-07-11 - 01:35:00
    I made a simple phone app with Android Inventor -- I don't know if there is a similar tool for iOS products. This app was used to control a WS2812 add-on board for my DEF CON 22 badge. I added an HC05/06 radio to the badge and used a similar text input strategy. The Android app simply sent the command strings to the Propeller. The fun thing about this is that you can do your initial testing through the programming port. My friend Peter will smile and point out that he can do that anyway, because Tachyon (his version of Forth -- that I haven't yet mastered) is always live; this gives him the ability to update his application at any time. I do my coding in Spin, so my route is a little more traditional.

    The point is, you can do this -- and it should be fun.
    720 x 1280 - 125K
  • Peter JakackiPeter Jakacki Posts: 9,367
    edited 2020-07-11 - 01:47:34
    +1 Jon :)

    Yes, the point is to just do it. That means that while you might ask a question or two, you really need to take some initial steps yourself and try stuff out. Then you get a better idea about stuff. Just find a Bluetooth terminal app and try it out by opening a terminal on your PC and connecting to it.

    "You can do this"
  • Hi

    In case you need a bit of 'grounding' in the use of bluetooth with propellar then you might find this instructable- by the much missed 'gadget gangster', useful.
    https://www.instructables.com/id/How-to-use-Bluetooth-with-your-Propeller/

    Dave
  • Dave - Do you still have the archive of source code from the Instructable? It's missing from Dropbox.
  • Hi
    Sorry- no!
    Dave
  • Parts should be here soon!
    Found this site appypie.com that is supposed to be good for creating apps for both iphone and samsung... havent tried yet though.
  • I looked at that site. If you're doing something for yourself, that my not be the best way to go -- their cheapest plan is $18/month per application.
  • For what it's worth, I shared a couple videos with my thoughts about App Inventor 2.

    Here's the last of the three videos where I show an app to change LED colors (color changing occus at 2:22 in the video).



    The app is horibly ackward but maybe it will provide some additional insight to AI2 over what Jon has already provided.

    Here's a link to the first video in the series.

    I haven't used AI2 for several years. I use Android Studio to write my apps now. It's not nearly as fast or easy as AI2 but the block code style of AI2 becomes unmanagable for all but simple programs.

    I've done multiple projects using Bluetooth with the Propeller. I prefer the HC-05 over the HC-06. The HC-05 can be used as a both master and slave. Using HC-05 it's possible have Bluetooth communication between Propellers.

    I'm also a fan of the ESP32 modules. These have both Bluetooth and WiFi. You can off load some tasks to the ESP32 if the Propeller is becoming burdened (or running low on RAM). The ESP32 can also provide the Propeller with ADC inputs.

    The ESP32 would require a program to pass the Bluetooth data through to the hardwired UART.
  • JBWolfJBWolf Posts: 369
    edited 2020-07-28 - 06:48:18
    Bluetooth module just arrived!
    For now I want to do just a basic interface such as a PST interface on prop to show received commands from a phone app.
    I figure that will be the best way to start since I can simply redirect received commands for other uses in code
  • So I definitely know now that I need to make an iOS app, not android.
    I didnt realize that appypie requires $, any advice on even a basic ios interface? Tachyon blows my mind on complexity, but its overkill for my needs.
    appearances are not a concern right now, just a simple app I can program a button to relay code or value to the prop would be a great start.

  • I've not seen a simple/free app create for IOS that will give you GUI capabilities. This is why designed my BT apps to accept command strings; it allows me to use a generic BT terminal app from any platform. This will get you started. If you do find an app development tool later, you can program the UI to send the strings your're already using (In fact, I did that with my IronMac app).
  • @JonnyMac You have an object for the HC-05 and HC-06. Do you also have an object for the HM-19 module that also supports BLE?
  • JBWolfJBWolf Posts: 369
    edited 2020-07-29 - 20:06:07
    I have hooked up the HC-06 BT slave module via 3.3v (also tried 5v)
    Trying the "jm_hc-06_configurator__17-03-21.spin"... updated tx/rx pins (no resistors between prop and bt module)... It will not connect
    The BT module led is blinking red.
    Here is the exact module I purchased
    any ideas?
  • JonnyMacJonnyMac Posts: 6,846
    edited 2020-07-29 - 20:35:54
    David Betz wrote: »
    @JonnyMac You have an object for the HC-05 and HC-06. Do you also have an object for the HM-19 module that also supports BLE?

    Not necessary -- it's a straight-up serial connection. I did create a little program to configure the HC-06 because it doesn't use CR as a line ending, and the time-out is too fast for normal human interaction. I've attached a couple archives for a project that I did back in the days of EFX-TEK where I used the Propeller to control [WS28xx] Christmas lights as in the show "Stranger Things."

    I have this in the program:
    con { serial connection for remote commands }
    
      #0, M_USB, M_BLUE                                             ' serial connection modes
    
      CMD_MODE = M_BLUE                                             ' command mode
    
    During development the mode is set to M_USB which lets me use PST to send command strings into the program. When I'm happy I switch the mode to M_BLUE which uses the BT module instead.

    Those constants are used in the setup() method:
      if (CMD_MODE == M_USB)
        term.start(RX1, TX1, %0000, USB_BAUD)                       ' use PST *
      else
        term.start(RX3, TX3, %0000, BT_BAUD)                        ' use Bluetooth *
    

    The core of the program is a very simple parser that looks for known words. Anything it doesn't know, e.g., a name, it will spell out by dimming the bulb associated with the letter.

    The project.
    stranger_things_banner.jpg
  • JBWolf wrote: »
    I have hooked up the HC-06 BT slave module via 3.3v (also tried 5v)
    Trying the "jm_hc-06_configurator__17-03-21.spin"... updated tx/rx pins (no resistors between prop and bt module)... It will not connect
    The BT module led is blinking red.
    Here is the exact module I purchased
    any ideas?

    Make sure that the TX pin defined on the Propeller is connected to the RX pin of the HC-06, and vice versa -- this is a common error. The configurator should poll the module until it finds the baud rate and from there you can change things like its ID and PIN code.
  • JonnyMac wrote: »
    David Betz wrote: »
    @JonnyMac You have an object for the HC-05 and HC-06. Do you also have an object for the HM-19 module that also supports BLE?

    Not necessary -- it's a straight-up serial connection. I did create a little program to configure the HC-06 because it doesn't use CR as a line ending, and the time-out is too fast for normal human interaction. I've attached a couple archives for a project that I did back in the days of EFX-TEK where I used the Propeller to control [WS28xx] Christmas lights as in the show "Stranger Things."

    I have this in the program:
    con { serial connection for remote commands }
    
      #0, M_USB, M_BLUE                                             ' serial connection modes
    
      CMD_MODE = M_BLUE                                             ' command mode
    
    During development the mode is set to M_USB which lets me use PST to send command strings into the program. When I'm happy I switch the mode to M_BLUE which uses the BT module instead.

    Those constants are used in the setup() method:
      if (CMD_MODE == M_USB)
        term.start(RX1, TX1, %0000, USB_BAUD)                       ' use PST *
      else
        term.start(RX3, TX3, %0000, BT_BAUD)                        ' use Bluetooth *
    

    The core of the program is a very simple parser that looks for known words. Anything it doesn't know, e.g., a name, it will spell out by dimming the bulb associated with the letter.

    The project.
    stranger_things_banner.jpg
    Thanks! I'll have to try writing a library on top of that to do BLE stuff.

  • There are some BLE models that provide a standard UART interface; I experimented with one a couple years ago but do not remember the part number.
Sign In or Register to comment.