Jump to content

47137

TinySine 8-channel relay Bluetooth remote control

Recommended Posts

My new layout will have seven points including one crossover so six point levers in all. I want to be able to have the control panel behind the layout or in front of it, so I have taken the plunge to go wireless and soft.

 

I have bought one of these:

TOSR08 - 8 Channel Smartphone Relay Bluetooth Remote Control Kit

and it arrived yesterday taking just nine days from China for a very nominal postage cost of £3.40. UK mail order operations take note! The package shows the value of USD20 so no customs duty either :-)

 

And it works fine. You have to plug the Bluetooth module into the relay board, and find a shaver adaptor or similar to plug the US-style 5V power unit into the mains. Download a free Android app from TinySine, install it, pair it up and it all just works!

 

post-14389-0-76834100-1426152571_thumb.jpg

 

The wiring under the layout will be simplicity. One wire from the common of each relay to a Tortoise motor. Wires from +12V and -12V supplies daisy-chained along the other relay contacts, and a common 0V return back from each of the motors.

 

Wanting to be a bit more ambitious, it would be nice to have a mimic diagram on the phone. After pairing, the software would set all the points to a default position (no feedback possible from the relay module), and then you would touch the bits of track adjacent to the points on the diagram to set the route and highlight it on the screen.

 

If I was using a Windows PC with a mouse/keyboard interface, I could tackle this in Delphi (probably Delphi 4 under XP!) with a reasonable chance of success. I'm not sure about how to go about it in Android. I have dabbled with a product called App Inventor, and have the book "Building Android Apps" by Mike McGrath, but to be honest I don't have a clue how to make it work to send commands, let alone send commands via Bluetooth. I also went through the rigmarole of installing Java and a Java development environment with an Android add-in on an old PC (now all gone) and by the time I got it working I was losing the will to live, let alone devise a program.

 

So any ideas on how to approach the app side of this would be good. In fact, if the "app" ended up as a row of eight physical toggle switches with a Bluetooth connection by whatever hardware you like to the module I'd be happy. At the end of the day, if it's just too difficult I can stay with the eight buttons on the free app from TinySine.

 

- Richard.

 

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites
 

I have looked at the adafruit site in and stopped here:
https://learn.adafruit.com/metal-inlay-capacitive-touch-buttons
"make pretty things you can touch and make bleepy noises" 

 

Imagine, a wooden control panel done in marquetry, with conductive pads beside the points. More stylish than a row of toggle switches!

 

I'd be interested to hear or see posts from anyone who has done some model railway infrastructure control (as opposed to a loco throttle) using an Arduino or similar controller.

 

- Richard.

Share this post


Link to post
Share on other sites

Hi Richard - that looks very interesting (i.e. controlling relays from Bluetooth-enabled devices).

 

If you are more comfortable with creating a User Interface using standard web technologies (HTML5, JavaScript, CSS), then it now seems possible to send Bluetooth commands from iOS/Android devices via the open BCSphere client and JavaScript library, which you can then import into an HTML5 iPhone/Android app powered by the free PhoneGap framework or similar (many tutorials available). Therefore the layout plan would basically be a web page on the phone (BCSphere app library must be installed first, I think) that would send Bluetooth commands for points as required via the hierarchy of libraries mentioned.

https://github.com/bcsphere/apps

 

At the above link, there seems to be examples for contacting Arduino modules via their Bluetooth interfaces, and even controlling a car via Bluetooth, which should get you closer to what you might want.

 

This is yet another area I would like to dabble in if I had the time... :-/    Good luck!  :)

 

 

Alan

Share this post


Link to post
Share on other sites
I would like to rewind a bit.

 

The control protocol for the relay board is simple enough (it doesn't need to worry about data errors) and so it has one Ascii character for each relay position - 16 characters in all. I can think of a few ways to send these to the board:

 

1. The freebie Android app

2. The freebie Android app decompiled (easy) and rebuilt with new screen icons (laborious)

3. A new Android app, with a suitable mimic diagram

4. A Windows PC running Hyperterminal (press a key, a relay moves)

5. A Windows PC with a modified keyboard - take the bottom off a keyboard and take a pair of wires from each relevant key switch to push buttons on a physical control panel (and run Hyperterminal, no new software)

6. A microcontroller (e.g. Arduino) to send the serial commands, and getting its inputs from a row of toggle switches, a mechanical lever frame or a control panel with some touch sensors.

 

... all these before Alan's suggestion of a web page issuing serial commands!

 

My current thinking is towards touch sensors or push buttons which react to a short touch/press to change a point, and a long touch/press to set a route extending through the point. The route might be the longest route possible on the layout, or the last-chosen route, or a route defined in the software. The objective being to end up with something intuitive and natural to use.

 

I have played with the freebie Android app, but I find the phone screen saver and power saving functions frustrating, and I get the feeling a hardware control panel with some smart behaviour will be more satisfying. At the end of the day, I am looking to build controls for a model railway, rather than an emulation of the controls of a real railway. I can find examples of commercial Android apps for use with DCC systems, but I'm wanting a purely "traffic" (not "traction") oriented approach which can I can implement independently of the train controller. I also feel a commercially available, non-dedicated relay board is sensible and economical approach to point and signal control (at least for smaller layouts) so I'd welcome any more ideas.

 

- Richard.

Edited by 47137

Share this post


Link to post
Share on other sites

I am in the same sort of situation as Richard. I need a control panel for my new shunting plank layout, but initially this should also be some sort of movable control module for front or back of layout. Although I am going in the direction of computer control, the lack of tactile response from a phone or touch screen bothers me. I had thought of using a bank of budget secondhand Hornby levers, but a pictorial 'mimic' panel would certainly be better, and quicker to spot any potential problems in operation.

 

I am planning to use an Arduino as the points controller for driving the point servos, so this could include a bluetooth or WiFi dongle - that looks relatively easy. It's the panel itself that is still hard to work out, as Richard says.

 

I think it might have to be another mini battery-powered Arduino with BT module on the back of a cutom-made mimic panel controlling (and displaying) point positions. Does anyone know of a method to make (and easily modify later) such a mimic-type panel? I always remember the pictures of the old Hornby Zero1 mimic panels, where you just taped on your track diagram and plugged in the point LED pairs, making later modifications easy. They didn't, however, include switches for the points on the panels themselves. If only it would be that easy...?

 

Richard - I'll be interested to know any solution you work out...  :)

 

 

Thanks,

Alan

Share this post


Link to post
Share on other sites

Communications with the relay module are very much one-way (no feedback) so I wouldn't want to attempt a mimic diagram with LEDs. Also with a small layout you can usually see how the points are set.

 

I picked up a bank of H&M section switches as used on their Powermaster controllers - brand new, still in its tissue paper and box, with the customary guarantee slip of the period - 1960s I suppose. Such a thing mounted onto a wooden cigar box would have a nice tactile feel and fairly ooze nostalgia. Some AA batteries inside the box to run the Arduino. 

 

The H&M switches are rather "handed" i.e. you really want the 'off' position away from you. Perhaps the solution is a discrete toggle switch on or inside the box which tells the micro controller how to 'read' the switch bank. So you always hold the box the same way up, and the left-most switch always operates the left-most points, whether you are in front of the layout or behind it. It would be easy to print out two track diagrams to go with the two sets of lever numbers.

 

In the meantime, I have got as far as fixing the relay module onto the baseboard. There is a USB socket at the left, which I'll only use if I need to debug Bluetooth problems. The DC power jack is at the other end.

 

- Richard.

 

post-14389-0-84763100-1428419873_thumb.jpg

 

(Edited for a typo)

Edited by 47137

Share this post


Link to post
Share on other sites

Great Richard - looking forward to see those section switches too!

Share this post


Link to post
Share on other sites

Richard

 

do you have link on ebay for this board. I am unable to find any near that price, even from china

 

Alan

Share this post


Link to post
Share on other sites

 

I would like to rewind a bit.
 
The control protocol for the relay board is simple enough (it doesn't need to worry about data errors) and so it has one Ascii character for each relay position - 16 characters in all. I can think of a few ways to send these to the board:
 

5. A Windows PC with a modified keyboard - take the bottom off a keyboard and take a pair of wires from each relevant key switch to push buttons on a physical control panel (and run Hyperterminal, no new software)

 
- Richard.

 

Probably easier said than done.

Have you tried soldering to very thin flexible plastic printed wiring assembly?

 

Keith

Share this post


Link to post
Share on other sites

Probably easier said than done.

Have you tried soldering to very thin flexible plastic printed wiring assembly?

 

Keith

Yes I am showing my age and it is a long time since I had a keyboard in pieces. My current thinking is I do want some tactile feedback through mechanical lever switches, so I ought to use the freebie Android app for testing, and the H&M lever frame / Arduino, as a project in its own right, as the goal to aim for.

 

Right now, the track is wired but relies on Croc clip leads to set the frog polarity. Usability will take a leap forward when I can install the point motors and wire up the frogs properly. I could start this right now if I wasn't sidetracked into arranging a narrow gauge feeder. Then again, it is a hobby!

 

- Richard.

Share this post


Link to post
Share on other sites

Richard

 

do you have link on ebay for this board. I am unable to find any near that price, even from china

 

Alan

 

Hi Alan,

 

This is the kit I bought:

http://www.tinyosshop.com/index.php?route=product/product&path=141_144&product_id=371

 

The kit contains the relay board, the Bluetooth module (which you have to plug into the relay board), a mains power supply for the +5V to drive the board and a Bluetooth dongle to plug into a USB port. The power supply is auto-ranging for the mains voltage but has US prongs so you need a shaver adaptor for the UK. So I first tried out the module in the bathroom, before I found a plug adaptor in Poundland :-)

 

I went for the budget USD $4 delivery service and the kit arrived in six days, packed in a sturdy box. The value was written on the package so no customs duty to pay.

 

Sorry for this rather tardy response, I simply didn't notice this post 6 minutes before the post after it.

 

- Richard.

Edited by 47137

Share this post


Link to post
Share on other sites

The module has now been in service for two weeks and has performed faultlessly.

 

When the board powers up, the Bluetooth link is always down and all of the relays are de-energised. So I have arranged the wiring from the board to the point motors so that in these circumstances, each turnout is set to its 'normal' route. Switching a relay 'on' then reverses the turnout.

 

The Bluetooth link is always initiated from the control device. I am using my Android phone with the TinySine freebie app. If the link is broken (typically by taking the phone out of range) the link drops out (and must be remade manually) but the relay settings remain. During the link creation process, the board sends the state of each relay to the app. It is impossible for the controller and the board to get out of sync with each other.

 

The only real drawback is the communications from app to board is unidirectional. Having wired the track for DCC, it has occurred to me I could use IR detectors to switch trailing turnouts to avoid a derailment. For this level of sophistication I would be looking towards some kind of bespoke solution to manage the relays and the IR detectors - which would take away all of the simplicity.

 

I am using seven relays, not six as per my original post. I decided to motorise a turnout for a siding which I had intended to be a local lever. Using the freebie Android app, I memorised the seven point lever numbers straight away. So the idea of a mimic diagram is a bit of a luxury. I do fancy the idea of some kind of route-clearing functionality, whereby setting one turnout returns unrelated turnouts to their 'normal' position. This makes me look towards doing something in Java for the Android platform rather than a bespoke hardware control panel with an Arduino. The only real snag with the phone is losing the link when the phone rings and I wander away from the layout. Perhaps I should buy a small tablet.

 

The Bluetooth module identifies itself as 'BluetoothBee' with a pre-set password. You need a USB adaptor to change these details and to change the baud rate. I've ordered up one of these boards, partly for engineering satisfaction but also so I can set the ID to match the name of the layout. Probably pure vanity I'm afraid, but it might start discussions at shows if anyone is scanning for Bluetooth devices.

 

So there - a working wireless remote control system for a layout, independent of the track controller technology, with off-the-shelf hardware, no programming and even no soldering to the board!

 

- Richard.

  • Like 1

Share this post


Link to post
Share on other sites

Well done Richard!

 

Sounds like it's proving to be a great alternative control method, and as you say, the sky is the limit if you start customising the Android app. I would think that shouldn't be too hard once you get the Android SDK working, as you say (been there, experienced that!). Is the app source code made available?

On the same note - I guess app customisation and custom board creation is the only way forward if you wanted to control more than 8 points, using some method of multiplexing via the Bee I/O ports? Or can you see some way to accomplish this without custom boards?

 

The unidirectional communication is obviously limiting, but for such an apparently cheap wireless system (assuming Android or Apple phones and tablets are available), it doesn't deter from the attraction. Having said that, how much did the board and Bee cost you?

Unfortunately I can't view the board links you provided to tinyosshop.com due to an apparent virus infection discovered on the site by my PC's (corporate) virus scanner. However, on Ebay it looks like the relay board and Bee would cost about 50 USD or so, is that accurate?

 

Thanks,

Alan

Share this post


Link to post
Share on other sites

I bought the kit directly from the TinySine web site and the payment was just under £47 including the postage. I was impressed by the level of service - as though I would get the same treatment if I wanted 500 boards instead of just the one. I run AVG anti-virus free under Win 7, which has no problems here although it does detect the rmweb as a source of viruses from time to time!

 

I haven't worked out whether the board is aimed at hobbyists or the OEM home automation market. It seems to be a "well rounded" sort of thing, it works and I can't think of anything to add without spoiling its universality. It would be nice if you could download the source for the freebie app but I did find something called "Jad v1.5.8e" which has returned 127 files in 27 folders. I installed the Android SDK under XP most of three years ago and it was so long-winded, and my lack of Java knowledge was so overwhelming, I produced a "hello world" app and vowed never again. However, if some of these 127 files can be tweaked - for example, to do add the route clearing functionality I have described - and put back together - solved. I still have the XP box stowed away!

 

The control protocol does include a command to get relay states, this returns a byte where bit set = relay on. So it is possible for any app (or a Windows .exe for that matter) to initialise itself to match the relay board.

 

- Richard.

Share this post


Link to post
Share on other sites

On the same note - I guess app customisation and custom board creation is the only way forward if you wanted to control more than 8 points, using some method of multiplexing via the Bee I/O ports? Or can you see some way to accomplish this without custom boards?

 

You can save relays by working points in tandem. For example 2a and 2 (trap point) and 7a and 7 on my layout:

post-14389-0-84673700-1433661068_thumb.jpg

If I was pushed, I could work 3 and 4 from one relay, and even 6 with 7 and 7a.

 

As it stands, I have one spare relay (number .8.) which will work one point on a leftwards extension. If the extension had a run-round loop or a kick-back siding the two points could be worked in tandem. Point x is only for use at exhibitions and doesn't need a motor, and the one point on the fiddle yard is worked by a reed switch tripped by the turntable there. So all in all, I can have 12 points on the whole layout and be happy with 8 relays.

 

The approach using the relay board doesn't extend very easily. I think for more than 8 relays I would investigate some kind of bus-based system which addresses relays individually. I am not a great fan of bespoke electronic hardware because it makes maintainability and documentation difficult. As it stands, if the Bluetooth module fails one day I can use a USB connection, and if the relay board fails I can pull it out and rewire with 8 SPDT toggle switches.

 

I forgot to mention, if you want to power the relay board from the layout power supplies, remember to budget for a +5V regulator.

 

- Richard.

Share this post


Link to post
Share on other sites

It might be nice if JMRI had a driver for this board. The protocol is really simple and using JMRI on a Raspberry Pi (or PC) you could use a JMRI mimic panel remotely on a tablet/phone/etc. via Wi-Fi and the Pi could talk wireless (Wi-Fi, Bluetooth or Zigbee) to the relay module making use of the feedback to show the state of the relays (and therefore the state of the points and signals).

 

It could form the basis of a control system for a modular layout with minimal wiring which might be attractive eliminating an accessory bus command station and accessory decoders.

 

I suspect the biggest complication might be having a lot of separate wireless connections if a lot of these modules were in use, perhaps there might be use for a Pi or Arduino app to consolidate the multiple wireless connections to several boards into a single interface.

 

It will be important to use feedback in any automation app. because the relays return to state '0' when the unit is powered on, and the power for the tortoises will need to be the same source as the power to the relay unit to be able to maintain point position in the event of power failure (trains will need to be moved clear of any points before power can be restored). It is a shame that they do not have an option for a module with latching relays.

Share this post


Link to post
Share on other sites

It will be important to use feedback in any automation app. because the relays return to state '0' when the unit is powered on, and the power for the tortoises will need to be the same source as the power to the relay unit to be able to maintain point position in the event of power failure (trains will need to be moved clear of any points before power can be restored). It is a shame that they do not have an option for a module with latching relays.

I guess I have fallen on my feet here because I am running the layout (including the relay board) from the UPS I use for the computer in the office.

 

To be fair, a Tortoise motor stays in its requested state if the power fails. So the problem with stock fouling point blades will happen when the power is restored, all the relay contacts are in the off position, and all the points move to their normal routes. In fairness, I think we could expect some diversity of point positions. I hope so because this will even out the load on the split rail DC supply to the motors. Analytically, during "normal operation" (meaning, running one train at a time and with a purpose, and not trying out every turnout), the largest number of turnouts which need to be reversed for any single movement is three. This is one of the routes from from end to end along the front of the layout. For me, the longest imaginable train can only bridge two of these sets of point blades. However, this argument is very much tailored to my own layout.

 

Momentary power failures will be a headache, longer-term ones will be easier to deal with. The simplest solution for an exhibition might be to take along a small UPS.

 

- Richard.

Share this post


Link to post
Share on other sites

The Bluetooth module identifies itself as 'BluetoothBee' with a pre-set password. You need a USB adaptor to change these details and to change the baud rate. I've ordered up one of these boards, partly for engineering satisfaction but also so I can set the ID to match the name of the layout.

The USB adaptor arrived from China today, 12 days after placing the order - seems good service to me, especially for only £3.40 P&P.

 

The board has header sockets for the Bluetooth module, a USB socket, and five solder pads:

5V

Gnd

Rst

Tx

Rx

so it looks as though you could use this board (with the module) to turn an existing RS232 device into a Bluetooth client. Hmm.

 

Edit: or a host. Either is possible.

 

- Richard. 

Edited by 47137

Share this post


Link to post
Share on other sites

Here is a photo of the relay board wired up, I took this yesterday just before I fixed the rear profile panels onto the baseboard:

post-14389-0-51062500-1434559563.jpg

The foam board is quite good for cable management.

 

- - 

 

When you have the TinySine USB adaptor (my last post), you can change the factory configuration of the Bluetooth module. You have to take the module out of the relay board and put it into the USB adaptor. Move two DIP switches on the module. Connect the adaptor to a PC USB port and run up the utility software from TinySine. Make the config changes. Power down the module, reset the switches and return it to the relay board. This is very easy to do but you do need the USB adaptor, you cannot do this with the module installed in the relay board.

 

You can change the device ID string, password and baud rate. I set the device ID to the name of the layout and kept the default 9,600 baud. So when the freebie Android app is connected to the layout, the screen now looks like this:

post-14389-0-33751400-1434559578.jpg

 

After you have made one successful connection, the Bluetooth module appears in the app's list of its previous pairings:

post-14389-0-63141000-1434559591.jpg

 

And, if you look around before pairing, your other Bluetooth devices can find it:

post-14389-0-54088300-1434559620.jpg

 

I am sure some members will see all this as intellectual m*st*rbtn, but it's not much different to putting the name of the layout onto a control panel with a bit of Dymo tape.

 

I'll wait and see who hacks the layout at its first show.

 

- Richard.

  • Like 1

Share this post


Link to post
Share on other sites

Great info and useful screenshots, Richard, thank you.

 

So is it pretty much working as you want it to? If you do combine this with a tablet running the JMRI Driver app or similar, it would be great to sit 10 feet away during the exhibition and watch the bewilderment as the layout seemed to operate itself!

 

It's a novel control method to complement the great looking layout and trackplan, so I'm looking forward to see how you do the final landscaping and eventually how the exhibition goes (when is it?).

Share this post


Link to post
Share on other sites
I have probably done everything that I can with the TinySine relay board. I have one of the eight relays unused at the moment, but I have ideas for an extension to the layout, this will usefully have one turnout and will use up the spare capacity.

 

The range of the Bluetooth module (plugged into the relay board) lets me sit in the living room below the room with the layout, switch all the motors simultaneously and listen to the noise they make. So I can do a sort of manual soak test of the motor linkages sitting in front of the TV. The RF link drops out if I take the phone into the garden, or indeed go out(!) but the relay board holds its settings and when you tell the app to recreate the link it interrogates the relay board for its present settings and retrieves them.

 

Ergonomically the arrangement is not at all bad. It's a lot better than pacing up and down some scale-length 00 station at an exhibition, hunting for wire-in-tube levers. I would prefer tactile switches instead of an Android screen (momentary push buttons would be fine) and I would like some kind of "route clearing" functionality whereby setting a turnout clears down the last route to the default power-on state. I'd like to keep control of "traffic" separate from "traction", even tho' I operate the layout on my own.

 

I have memorised the seven (or eight) buttons so it's hard to justify a "soft" mimic diagram for control, even tho' I fancy trying to code one. It would be better to have mechanical push buttons on a physical panel.

 

It would be extremely easy to hard-wire the Tortoise motors to a physical mimic diagram. I am running the motors from a split supply (+12 / 0 / -12 V), so two LEDs connected in anti-phase in the common wire to the motor will show the state of the motor. The motor winding provides the dropping resistance! The LEDs could be the "LED lighting strips" you buy by the roll nowadays. The mimic diagram could be hung on the wall behind the layout, while you sit in the armchair with the phone in your hand.

 

- - 

 

There are two ways to control a model railway layout. On my last layout "Castell y Bwrdd" I had an interlocked lever frame and an arrangement very close to the real thing. This was a very simple track plan. It satisfied me to build it and to show it to visitors at exhibitions, but I want something more model-orientated for my new layout.

 

I'm not too keen on the JMRI at the moment ... it looks like hard work to get working :-)

 

- Richard.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.