Bluetooth and Arduino

ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Whilst away on my hols (in sunny France - and yes it was hot!!), I got to grips with the (very) basics of Arduino. Now I'm back I've been experimenting.

Still early days yet, but I've written up wot I dun on my blog for those who might be interested
https://riksrailway.blogspot.com/2019/0 ... phone.html

Total outlay on the control bits = £17.81. I could have done it more cheaply if I'd bought the bits directly from China - but I didn't want to wait.

Hope it's of interest.

Rik
 
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
Shocked at the prices you paid!

Did mention using Bluetooth many moons ago, met with the usual apathy!
Might resurrect the ideas again some time in the future.
 
Last edited:
PhilP

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
22,947
334
Tamworth, Staffs.
I had not realised you could get the Arduino in that small a package. - I expected something the size of a Raspberry Pi?

127316_2eb7925851a472586347f29f1e715563.png
 
ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Shocked at the prices you paid!
Shocked in how high or how low?
I bought them from UK suppliers as I didn't want to wait for them to be delivered from China. I could probably get them cheaper via AliExpress etc

Rik
 
JimmyB

JimmyB

Phase 1 complete, roll on Phase 2
23 Feb 2018
1,549
159
65
Weston-super-Mare
Rick, very interesting and food for thought.
 
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
Shocked in how high or how low?
I bought them from UK suppliers as I didn't want to wait for them to be delivered from China. I could probably get them cheaper via AliExpress etc

Rik
Nano + BT & L298N £2.72
Pro Mini + BT & L298N £2.60
STM32 + BT & L298N £3.43

Latest order I placed, delivery time 3 days from China! More than likely stuff these days arrives quicker from China that it does from Mainland UK..........

Brief decsription of the STM32 below, higher spec than the Arduino, have been experimentating with them for the last two or three weeks, for comparision, the Arduinio is like a LADA against the STM32 which is akin to a Rocket in terms of speed.

STM32, Cortex-M3 processor, running at 72MHz.
Storage resources: 128K Byte Flash, 20KByte SRAM;
Interface Resources: 2x SPI, 3x USART, 2x I2C, 1x CAN, 37x I / O ports,
Analog-to-digital conversion: 2x ADC (12-bit / 16-channel)
Timers: 3 general timers and 1 advanced timer

I'll at some point, up date the *.INO's, and make avaialble the *.APK's for Android devices and produce a PDF, for anyone who should be interested, and wants to have a tinker.................me, I'm staying with DCC!
 
Last edited:
  • Like
Reactions: ge_rik
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
I had not realised you could get the Arduino in that small a package. - I expected something the size of a Raspberry Pi?

View attachment 254077
It also comes as this................and can do exactly the same job as the Nano, about 11p in real money! Ok, the skill factor is to program it!

127328_b04dec07bfcde3739888576919f8ab48.jpg
 
-bbbb

-bbbb

Registered
21 Dec 2017
195
24
Idaho
Still early days yet, but I've written up wot I dun on my blog for those who might be interested
https://riksrailway.blogspot.com/2019/0 ... phone.html
Looks like there was a typo on that site: 'cheap was' should be 'cheap way'?:
"Overall, Bluetooth enabled technology does seem to offer a flexible and relatively cheap was of controlling model trains."

Always nice to see cheap ways of doing things, I wonder about the range.
 
Madman

Madman

Registered
25 Oct 2009
12,965
115
Pennsylvania, USA
Like John S, I too lack the umps to fully explore arduinos. I experimented with a kit, a few years ago, but lost interest when it came to programming it.

My Lionel "O" gauge locomotives come equipped with the bluetooth technology. It's all nice and tidy and thought out for me.....:D
 
dunnyrail

dunnyrail

DOGS, Garden Railways, Steam Trains, Jive Dancing,
25 Oct 2009
14,638
262
71
St.Neots Cambridgeshire UK
Certainly of interest in the cost department. But a big but for me is using a Phone or Tablet to control with. Yes most of us have them but there are often issues with Light blocking out the screen view on a bright day. My Garden is mostly in full Sun most of the day so this is a big issue. Also the Battery Time of a Phone, probably not too much of an issue for a lot of you but my Timetable Running days tend to be 4-6 hours long and that time on Blue Tooth will certainly drain a phones battery somewhat. I could also see this being an issue for Casey at his CFR where he is entertaining the public all day, however in his case I guess another Loco can be used if the Phone goes phut for want of Battery Power. Finally Range, no reply to -bbbb’s wonder as yet. Though I think this may have been resolved on another thread? As for possibly having to program anything Blue blub blub..........

Nice comprehensive review though as ever Rik.
 
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
Looks like there was a typo on that site: 'cheap was' should be 'cheap way'?:
"Overall, Bluetooth enabled technology does seem to offer a flexible and relatively cheap was of controlling model trains."

Always nice to see cheap ways of doing things, I wonder about the range.
Nowadays, the use of Bluetooth amongst Garden Railway enthusiasts appears to be non existent, but not quite obsolete, there have been mutterings amongst the dysfunctional for a resurgence!

Despite the latter day influence on IoT’s devices, merits and contingencies, Bluetooth has become endangered, but not extinct.
Likewise some of the offerings available in the 2.4GHz band aimed at Garden Railway owners, are prehistoric in their design and outrageously expensive, for their limited capability.

There is a widely held misconception that Bluetooth, despite not being a line-of-sight technology, can only operate at short distances. This is not true.
As listed they are the intended ranges, which is where the other part comes into play. Ranges can be drastically reduced by obstacles between the two devices, such as walls that attenuate signals. Thus, the range is influenced by transmitter strength, receiver sensitivity, and obstructions in the device’s proximity.

Newer versions of Bluetooth boast ranges from around 250 feet to 800 feet, so updating the device seems to be the most obvious solution. However, ranges can also be stretched by recruiting signal repeaters. These are intermediate devices that capture the signals, amplify them and then re-transmit or repeat them without any distortions. For instance, a 33-foot range device connected to a 1,000-foot repeater allows the device to enjoy a 1,000-foot range.

You could also take the matter into your own hands. There are several DIY methods to extend Bluetooth ranges by tinkering with the Bluetooth modules. So, grab a soldering iron, a few screwdrivers and rouse your inner engineer. Another cost-effective method is to align your devices such that their signals cannot be interrupted by the obstacles.

Range of Bluetooth is dependant on its class and primarily there are three classes of Bluetooth:
Class 1 transmitting at 100 mW with a range of 100 meters or 328 feet.
Class 2 transmitting at 2.5 mW with a range of 10 meters or 33 feet
Class 3 transmitting at 1 mW with a range of fewer than 10 meters.

Never have understood the lack of interest amongst the Garden Railway Fraternity to make more use of Bluetooth enabled devices to run and operate their empires!

Dunnyrail's observations, a transmitter device can be used with a good old fashioned rotary control, no phone needed!, as for possibly having to program anything, it is really a relatively simply exercise...........



Therefore power to your elbow Rik, maybe a spark may awaken the masses to the use and possibility of using Bluetooth amongst the Battery Brethren.
 
Last edited:
dunnyrail

dunnyrail

DOGS, Garden Railways, Steam Trains, Jive Dancing,
25 Oct 2009
14,638
262
71
St.Neots Cambridgeshire UK
Looks like I may well have to do an investigation, but please never tell me that programming is easy - not for me it ain’t! My mind looses the will after any failure which is every time I try to get involved in the Witchcraft that is programming. Yes I can mess about with DCC now, but that knowledge was hard won after much ‘impatient’ explanation by certain friends that I was involved with. Though once I get it I am OK and this has always been the issue for me with trying to Program, the ‘Teachers’ all see it as easy and hack around on the screen going from one thing to another leaving me in a blur of misunderstanding. But I do like the possibility of this kit with a Knob to twiddle rather than a Mobile Phone.

Perhaps sometime soon someone will be offering Plug and Play Kits that just need a little bit of Soldering to the Motor and perhaps Battery Wires. Perfect.

As for Riks installation, would it fit the 0 Gauge Terrier you did? Tried to add this query to your blog Rik but Google got in the way, lost my post in a blur of forgotten passwords. See my problem?
 
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
Cross purposes… was not proposing the actual coding of the program, rather that if the code was available, the actual process of programming (uploading the code) itself was a simple process.

I’ll give the subject some further thought, can easily supply a list of parts, wiring diagram, and the coding, maybe go as far as programming the Arduino itself, and just supply a kit of bits.

As an aside, met up with Alan Eccles over the weekend (he was down here on holiday) we had a very in-depth chewing the cud session on the subject of techno phobia, several practical and workable ideas have gone back with him for “The Committee” to ponder!
 
ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Latest development

Steve Massikker of arduinorailwaycontrol.com has been in touch and wants me to collaborate on the final development and testing of an app designed specifically for large scale trains.

Watch this space as they say! :eek:

Rik
PS Range isn't a problem in my garden. The greatest line of sight distance in my garden is 17m and it coped easily with that even with foliage in the way. I might get around to doing a longer range test later - strolling down the street with phone in hand... Just like youngsters do.:think:

PPS - Programming isn't really a problem doing it this way. The code is copied from Steve's website, pasted into the Arduino IDE program and then uploaded to the Arduino chip. The most difficult bits are:
  1. Making sure the right driver is loaded for the Ardunio board - especially if a cheaper clone is used rather than the original product
  2. Wiring up all the bits. I tried using Dupont male and female push-on leads but the connections were sometimes a bit iffy, especially when trying to cram it into the loco - in the end, I soldered the leads - and the pads are a bit small on the Nano.
 
Last edited:
ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Nano + BT & L298N £2.72
Pro Mini + BT & L298N £2.60
STM32 + BT & L298N £3.43

Latest order I placed, delivery time 3 days from China! More than likely stuff these days arrives quicker from China that it does from Mainland UK..........
Ouch! That is a lot cheaper. My prediction of half the price was a serious under-estimate. I presume those prices also include postage.

Rik
 
ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Looks like there was a typo on that site: 'cheap was' should be 'cheap way'?:
"Overall, Bluetooth enabled technology does seem to offer a flexible and relatively cheap was of controlling model trains."

Always nice to see cheap ways of doing things, I wonder about the range.
Now corrected - also spotted I had used 'to' instead of 'too' ...
Rik
 
John S

John S

Registered
5 Nov 2017
634
110
Exeter, Devon, UK
Rik,
  1. Wiring up all the bits. I tried using Dupont male and female push-on leads but the connections were sometimes a bit iffy, especially when trying to cram it into the loco - in the end, I soldered the leads - and the pads are a bit small on the Nano.
Hot Glue Gun............is extremely useful to hold every thing in place.

Prices included FREE P&P............
 
-bbbb

-bbbb

Registered
21 Dec 2017
195
24
Idaho
Nowadays, the use of Bluetooth amongst Garden Railway enthusiasts appears to be non existent, but not quite obsolete, there have been mutterings amongst the dysfunctional for a resurgence!
...
I've been hearing about the cancer risks of bluetooth earbuds, But I don't suppose people will run bluetooth trains around their heads. Long range repeaters might be concerning though. I've been using a bluetooth speaker for loco sounds for some time. It's a convenient self contained package with built in rechargeable battery, very loud and clear. I just link the ipod to it and play the audio track while the train goes. It would be nicer to have an app for bluetooth audio that controls layers of sounds separately so the chuffing could be linked to loco speed without an expensive sound card, and the choo choo-ing, bells, and conductor calls could happen at the press of a button. Maybe it already exists somewhere, hopefully for free?
 
ge_rik

ge_rik

British narrow gauge (esp. Southwold and W&LLR)
24 Oct 2009
9,596
132
Cheshire
www.riksrailway.blogspot.com
Just did a highly scientific range-test - 46m! (I put the loco on a length of track on the front lawn and wandered off down the street with my phone until it no longer responded. It took 46 large strides to get back again.

Rik
 
PhilP

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
22,947
334
Tamworth, Staffs.
Careful Rik!
You could get burned as a 'witch', for that sort of thing in some villages! ;):giggle::giggle: