Page 2 of 2
Re: DIY Arduino radio control for garden train
Posted: Tue Mar 12, 2024 12:34 pm
by Sam95
Installation of Arduino Nano:
There is a hole at the back of the boiler into the cabin. I increase a little bit the dimensions to have a goos access to the USB port on the Ardunio. Thus I can connect the Arduino to my computer without disassemble the loco.
The Arduino fits in the back of the boiler
The last part was to fit all the wires into the loco... it is not easy but possible :

Re: DIY Arduino radio control for garden train
Posted: Tue Mar 12, 2024 2:40 pm
by Lonsdaler
That's an impressive conversion. Look forward to seeing it running. And thank you from me for the link to the wiring diagram software.

Re: DIY Arduino radio control for garden train
Posted: Wed Mar 13, 2024 7:34 am
by ge_rik
Clever idea for mounting the Nano with its usb port accessible. It will save you a lot of time and effort when tinkering with the programming.
Rik
Re: DIY Arduino radio control for garden train
Posted: Wed Mar 13, 2024 9:04 pm
by Sam95
Lonsdaler wrote: Tue Mar 12, 2024 2:40 pm
That's an impressive conversion. Look forward to seeing it running. And thank you from me for the link to the wiring diagram software.
It's already filmed :
Re: DIY Arduino radio control for garden train
Posted: Wed Mar 13, 2024 9:45 pm
by Lonsdaler
Excellent. Any room for a steam loco soundcard?
Re: DIY Arduino radio control for garden train
Posted: Mon Mar 18, 2024 8:26 am
by Sam95
Lonsdaler wrote: Wed Mar 13, 2024 9:45 pm
Excellent. Any room for a steam loco soundcard?
Unfortunately not in the loco, it is too tight.
Re: DIY Arduino radio control for garden train
Posted: Mon Mar 18, 2024 8:43 am
by Sam95
To finish concerning the receiver here is the code :
Code: Select all
/*
Code for locomotive RUSTY
*/
#include "SPI.h"
#include "NRFLite.h"
const static uint8_t RADIO_ID = 10; // receiver identification
const static uint8_t PIN_RADIO_CE = 9; // connexion pin of nrf24l01
const static uint8_t PIN_RADIO_CSN = 10;
NRFLite _radio;
int POT_Value = 0; // received bariable for the potentiometer vaule
int ARU = 0; // emergency stop variable
int in1 = 4; // motor rotation direction
int in2 = 3; // motor rotation direction
int ENA = 5; // pwm motor
int in3 = 6; // entry for the light
int in4 = 7; // entry for the light
int LIGHT_Value = 0; // variable for the light
float analogVolt = 0; // vairable for voltage reading on pin A2 ==> 0.....1023
//packet structure including the received variables
struct RadioPacket {
int POT_Value;
int ARU;
int LIGHT_Value;
};
RadioPacket _radioData; // variable associated to the structure
void setup() {
pinMode(4, OUTPUT); // pin 4 output for in1
pinMode(3, OUTPUT); // pin 3 output for in2
pinMode(5, OUTPUT); // pin 5 output for ENA PWM motor
pinMode(6, OUTPUT); // pin 6 output for in3 lamp
pinMode(7, OUTPUT); // pin 7 output for in4 lamp
pinMode(A2, INPUT); // pin A2 voltage reading
Serial.begin(9600); // serial port for debug
if (!_radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN)) {
Serial.println("Cannot communicate with radio");
while (1)
;
}
}
void loop() {
while (_radio.hasData()) // awaiting character reading
{
_radio.readData(&_radioData); // reading variable radioData including the structure with 3 variables POT_Value ARU and LIGHT Value
ARU = _radioData.ARU; // writing of the value received into the declared variable
POT_Value = _radioData.POT_Value;
LIGHT_Value = _radioData.LIGHT_Value;
Serial.print("Eclairage : ");
Serial.println(LIGHT_Value);
// **** if battery voltage is under 10.8v then stop of lights and engine to save battery, otherwise continue the programm
// R1=10Kohm, R2=27Kohm ratio 0.270 max voltage of 4 batteries 16.8v*0.270=4.54v max at pin A2
// (4.54x1023)/5=929
// for the max batterie voltage we will read 929 on pin A2
// to limit undervoltage at 2.7v per element : 10.8v mini to read on pin A2
// à 10.8x0.270=2.916v
// (2.916x1023)/5=596 to limit voltage et 2.7v per element the minium read value will be 596
analogVolt = analogRead(A2); // read pin A2 variable analogVolt
Serial.println("Mesure batterie: ");
Serial.print(analogVolt);
if ((ARU == 1) || (analogVolt <= 596)) // if emergency stop OR battery voltage <10.8v
{
digitalWrite(in1, LOW); // breake to stop motor
digitalWrite(in2, LOW);
digitalWrite(in3, LOW); //light off
digitalWrite(in4, LOW);
Serial.println("Etat arret urgence :");
Serial.print(ARU);
Serial.println("Si batterie <10.8v soit <596 alors la loco stop");
Serial.println("Etat batterie =");
Serial.print(analogVolt);
}
// **** if no emergency stop or battery undervoltage ****
else {
Serial.println("Etat arret urgence : OFF");
if (POT_Value < 450) {
int mappedval = map(POT_Value, 450, 0, 80, 255); //mapping of potentiometer value to the output of L298N. If pote value is between 450 and 0 the it correspond to an output from 80 to 255. This is done to apply the power to the motore . I don't map 0 to 0 otherwise the motor will not have enough power to start and ther will be a long period of time when turning potentiometer the loco will not start
Serial.print("Reception Avant : ");
Serial.println(POT_Value); // affichage de la POT_Value du potentiometre
Serial.println(mappedval); // affichage valeur mappé pour trouver a quel valeur moteur démarre
digitalWrite(in1, HIGH); // rotation direction of motor
digitalWrite(in2, LOW);
analogWrite(ENA, mappedval); // sending of the mapped PWM value for the motor speed moteur pin 5
delay(30);
}
else if (POT_Value > 570) {
int mappedval = map(POT_Value, 570, 1024, 80, 255); // same as previously in th e other way
Serial.print("Reception Arrière : ");
Serial.println(POT_Value); // affichage de la POT_Value du potentiometre
Serial.println(mappedval); // affichage valeur mappé pour trouver a quel valeur moteur démarre
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
analogWrite(ENA, mappedval); // commande vitesse moteur pin 5
delay(30);
}
else if (450 > POT_Value < 570) {
Serial.print("Reception Stop : ");
Serial.println(POT_Value); // affichage de la POT_Value du potentiometre
digitalWrite(in1, LOW); // if pot value btw 450 and 570 no motor power to have a centered 0 on the potentiometer
digitalWrite(in2, LOW);
}
//********* LAMP command ************
if (LIGHT_Value == 1) {
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
} else if (LIGHT_Value == 0) {
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
}
}
}
I hope the comments in the code are enough to understand it.
Re: DIY Arduino radio control for garden train
Posted: Wed Jul 23, 2025 10:33 am
by Sam95
Hello,
I want to update you about this project
My layout is working since more than 1 year with this radio control and I am not very happy with it.
The main issue is that the data transmission is not stable after few minutes of use the transmission stops so I can't control the loco. Sometimes I have to reset the controller and sometimes it is not enough. I have to run after the loco to switch it OFF and ON.
After watching the last video from Rick; it seems he has the exact same issue.
After digging a bit Internet it seems that using an Arduino pro mini natively in 3.3v can improve the reliability of data transmission and adding several capacitors could be nice too.
So I have to test all that.
Other issues are :
Poor visibility of LCD screen under the sun; selection of locomotive via menu and rotary encoder is too long. I would like to replace the system by a rotary selector with 12 positions to select the loco address. And the screen can stay to display informations only. Clearly clone the system of the rctrain transmitter.
If the system is still not enough reliable with Arduino pro mini; I saw that ESP32 can also be used with ESP NOW projet to establish direct communication in Wifi between the ESP32.
More info to follow when my aliexpress order will arrive......
Re: DIY Arduino radio control for garden train
Posted: Mon Sep 15, 2025 2:37 pm
by Sam95
Hello all,
The new version of my radio control is working now. And after several running session it seems that the connexion is stable. I didn't have any link breake yet.
So the new version is based on an Arduino Uno, with an 1.3" Oled screen so the controler is smaller and fits nicely in the hand. The 12 position rotactor to select loco addresses is very responsive I like it.
Here are 2 quick videos :
The first one is just a basic overview
The second one is a quick running session from yesterday between the rain.
If you want more info I wrote an article on my blog with the code, the stl to print the case.....
https://sam95.fr/blog/2025/09/15/t-t-2-j-version-2/
It is in french but you can have the auto translation on the top right corner.
Re: DIY Arduino radio control for garden train
Posted: Mon Sep 15, 2025 4:01 pm
by philipy
That is very impressive Sam. Well done.
Re: DIY Arduino radio control for garden train
Posted: Thu Sep 10, 2026 8:47 am
by Sam95
Hello all,
I have continued developing the project, which has now evolved into GTRC – Garden Train Radio Control. Indeed the reliability was not 100% satisfactory with TT2J V2.
The hardware remains the same as TT2J V2, but the software has been redesigned with the help of AI.
It can control up to 12 locomotives from a single handheld controller using a rotary selector, all sharing the same NRF24L01 radio network.
The new software includes a global emergency stop for all locomotives, individual locomotive control, lighting control, battery monitoring with low-voltage protection, a diagnostic mode to check each locomotive battery before running, and a MEM function allowing one locomotive to keep running while another is being controlled.
The project is Arduino-based and designed to remain configurable for different locomotives, motor drivers and hardware setups. The software now uses a modular architecture, split into dedicated .cpp and .h files. The core code normally does not need to be modified: each setup and locomotive can be customized simply through configuration files.
I am now documenting the project on my blog in french but there is a translation module possible if you are interested.
https://sam95.fr/blog/category/modelism ... rdin/gtrc/
Re: DIY Arduino radio control for garden train
Posted: Thu Sep 10, 2026 11:59 am
by philipy
It's beyond me Sam, but it sounds amazing. Be very interested in seeing a video in due course.
Re: DIY Arduino radio control for garden train
Posted: Thu Sep 10, 2026 10:22 pm
by GAP
Poor visibility in sunlight can be solved by using ePaper I have been told by AI searches.
I have been dabbling with a handheld controller with a dispatcher program (similar to Rik's one) for my layout to replace the multiple transmitters I have, it is ESP32 based with !2 locos selectable and it was the recommended display method.
AI description
"E-paper (electronic paper) is a reflective display technology that mimics the look of real ink on paper by reflecting ambient light instead of emitting its own."
"e-paper works exceptionally well in direct sunlight outdoors.
Why It Works OutdoorsReflective Display:
It utilizes ambient sunlight to illuminate the screen rather than fighting against it with a bright backlight.
Zero Glare: The matte finish prevents harsh reflections, making it look exactly like printed paper.Improved
Clarity: The brighter the sunlight is outside, the sharper and more readable the text becomes."
Its the same as what supermarkets use for their shelf labels.
As example
SeekInk 1.3" ePaper Module (144x200): True electrophoretic e-ink glass active-matrix display designed for electronic shelf labels (ESL) supporting multi-color options (black, white, red, yellow).
Re: DIY Arduino radio control for garden train
Posted: Fri Sep 11, 2026 7:25 am
by Sam95
philipy wrote: Thu Sep 10, 2026 11:59 am
It's beyond me Sam, but it sounds amazing. Be very interested in seeing a video in due course.
I hope to record a demonstration video soon. But I am not very good at that !
Re: DIY Arduino radio control for garden train
Posted: Fri Sep 11, 2026 7:27 am
by ge_rik
Sam95 wrote: Thu Sep 10, 2026 8:47 am
Hello all,
I have continued developing the project, which has now evolved into GTRC – Garden Train Radio Control. Indeed the reliability was not 100% satisfactory with TT2J V2.
The hardware remains the same as TT2J V2, but the software has been redesigned with the help of AI.
It can control up to 12 locomotives from a single handheld controller using a rotary selector, all sharing the same NRF24L01 radio network.
The new software includes a global emergency stop for all locomotives, individual locomotive control, lighting control, battery monitoring with low-voltage protection, a diagnostic mode to check each locomotive battery before running, and a MEM function allowing one locomotive to keep running while another is being controlled.
The project is Arduino-based and designed to remain configurable for different locomotives, motor drivers and hardware setups. The software now uses a modular architecture, split into dedicated .cpp and .h files. The core code normally does not need to be modified: each setup and locomotive can be customized simply through configuration files.
I am now documenting the project on my blog in french but there is a translation module possible if you are interested.
https://sam95.fr/blog/category/modelism ... rdin/gtrc/
Thanks for sharing. I might dust off my Arduino project and give it another go.
Rik