Geoff Bunza geoffb
Front4.jpg
Figure 1. A Working Railcar Scanner 
 
Modelers operating their layout want to know the consist of each train in motion and in staging. Operators want to know this precisely, especially as trains are made up and distributed over their empire. Prototype railroads need to keep track of trains and cars as their revenue and billing is derived from the ton-mile they transport, and charges are paid to car owners as their equipment is used. This article describes a fully operational, model railroad car scanner. It begins with a short review of prototype car scanners which were developed in the 1960’s, deployed by AAR mandate. They were used until the 1970’s, and then abandoned, due to poor performance and lack of business integration. Superseded by newer technology in the 1990’s, car tracking is now used by railroads throughout North America.
 
We follow this with the details of a low cost, Automatic Car Identification (ACI) system for model railroads. This will include a relatively simple working scanner and controller, a very flexible identification tag that can be customized, and car lists generated and transferred to local displays, phones, PC’s, web pages, paper, and JMRI directly. The ACI is not dependent on scale (N-scale and larger), nor track power, nor train control mechanisms, nor signaling systems. It can be used on 4’x8’ empires and large club layouts.
 
Train consists can be monitored, saved, transmitted, and utilized via many different displays, viewers, and applications. The incremental cost per car is very low (less than a penny a car) with scanner costs less than $18 each. There are some interesting implications that can derived from clever labeling for new uses on model layouts.
 
Some History and Basic Equipment
 
IN the 1960’s Sylvania experimented with a rail car scanning system that it eventually tried out on the Boston and Maine railroad. The Federal Railroad Administration later evaluated the Sylvania system, as well as two others, in the hopes of recommending a nation-wide solution for tracking freight cars and locomotives across the US. The AAR Board of Directors announced in October, 1967 that the Sylvania KarTrack system would be the national standard, and that all cars be labeled with KarTrak colored bar-codes.  These were the first bar codes in widespread commercial use anywhere, and the precursor to the barcodes commonly found on most any item offered for sale today.
 
Label Format.jpg  KarTrak Labels2.jpg     KarTrakLabelLPN.jpg
 
Figure  2.  KarTrak RailCar Format                                        KarTrack  Codes                        Decoded:  LPN 52059  
 
ACI Installation.jpg
Figure  3.  KarTrak Prototype Scanner
 
The KarTrak system proved to be a failure, even though by 1973, 95% of all railcars were labeled. Labels became unreadable covered with dirt and road grime in the presence of harsh operating conditions. Freight haulers of long, ore trains kept using them longer, for captive use. The KarTrak system was phased out by 1977. The optically scanned KarTrak labels were superseded by a form of rugged, encapsulated RF ID tag, required to be in place by the end of 1994. These Automatic Equipment Identification (AEI) tags are now in widespread use on virtually all freight cars, passenger cars, and locomotives on the rails.
 
Automatic Car Identification (ACI) System for Model Railroads
 
This project describes an Automatic Car Identification (ACI) system for model railroads. This includes a relatively simple QR Code scanner and controller, a very flexible QR Code identification tag that can be customized and printed at will, and car lists generated and transferred to local displays, phones, PC’s, Arduinos, web pages, paper, and JMRI directly (see Figure 4. below). To identify or scan a car, it simply needs to roll over the scanner located below the roadbed. The rest is magic!
 
Operating Diagram2.jpg
Figure 4. The Operating ACI System
 
 
 
Video: ACI in Action
 
The ACI uses a relatively new sensor called the Tiny Code Reader (TCR) made by a company called Useful Sensors. Its function is entirely focused on reading graphic QR Codes like the one pictured in Figure 5. below:
MILW_67116_D&H_18661.jpg
Figure  5. QR Codes for “MILW 67116”           and                      “D&H 18661”
 
I have been experimenting with the TCR to see how small a QR Code could reliably be read, and under what conditions. QR Codes can contain many alphanumeric characters (over 200) and can be printed on ordinary office and home printers. The TCR has a practical limit herein of something less than 40 characters, and I have been limiting mine to 20 or less. Fewer characters means speedier decode time, and with a nominal 5 QR Codes read per second, I wanted to be able to read railcar labels with the train on the move! I have been able to print my own QR labels with a 600 DPI laser printer. I can reliably read QR Codes as small as 0.2 x 0.2 inches, but movement and light makes reading them problematic. I have been using 0.27x0.3” and 0.35x0.38” codes with much higher success. High train speed during scanning is not possible, so old Athearn Hustlers will not cut it. However, car scanning with a train on the move is entirely possible.
 
There are real advantages to using QR Codes:
  1. They can be easily printed on an ordinary home or office printer, either ink jet or laser.
  2. Labels can contain alphabetic, numeric, and special characters like AT&SF 123456789
  3. They are very low cost to print in any quantity (like less than a penny a piece).
  4. Scanning reliability can be increased at higher train speeds by applying the same label more than once
  5. ACI labels can perform “interesting” model railroad functions, since we can put anything onto the label:
  6. The railcar name and number are obvious -- NYC 173210
  7. More than one label can be added per car – EOT for End of Train or FOT for Front of Train
  8. An F for Front or R for Rear can be added to an individual car label – RDG 89191F or SOU 2302111R
  9. Additional labels could be posted for routing information similar to the “thumbtacks” on cars of old
  10. Locomotives can be labeled, as well as cabooses, passenger cars, and MOW equipment
  11. Labels can be scanned and read via most cell phone cameras
  12. Labels can be made removable by using weak glues like Aleene’s Tack-It Over & Over without damage
  13. Removable, magnet-backed labels can attach to the screws of car trucks
 
I have considered these possibilities for car labels: FOT (Front of Train), EOT (End of Train), Car Front, Car Back, Running Extra, Train 25 (train number), RR & Car Number with F or R for Front or Rear (NYC 125023F), Express, and the like. The code is designed to eliminate duplicate car labels to multiple labeling for increased reading reliability with higher train speed over the scanner. Even with multiple labels, high speed and scanning do not mix. Examining the scan reports shows that an additional number per label is randomly generated, anticipating the possibility of using the scanner situated at a weigh scale. It can easily be turned off.
 
QR Codes can be printed using a free open source application called “QR Code Generator” downloadable from here: https://sourceforge.net/projects/qr-code-generator    I also include it in the downloads zip for this article. When you resize the codes for printing (after generating) make sure they are equally, proportionately resized. Changing the size ratio is not a good idea and may cause the code not to be read. I use MS Powerpoint to bring in the newly generated code, resize and label them and the print them out. Select the QR Code picture in your Powerpoint, right click on it and select “Size and Position.” Then change either the scale height or scale width and note that the other one will follow – do not force them to adjust differently. Print them out on normal 20lb or 24lb paper, non-glossy. Cut them out with a white border so the scanner can “find” them.
 
QR Codes Experiment4.jpg
Figure 6. Example printed QR Codes
 
I have successfully used Aleene’s Tack-It Over and Over glue to attach the labels to the bottom of cars. This is a similar glue used in “post-it notes.” Repeated use will wear the glue out. Simply re-apply to re-use the QR Label.
 
One of the neatest appliques for car labels I have found is to use a 4mmx1mm magnet from Supermagnetman.com:  https://supermagnetman.com/products/d1021?_pos=3&_sid=8562318e2&_ss=r
Glued to a thin piece of styrene with superglue. This forms a placard holder for a QR Code than can be attached to the steel screw holding a truck to the chassis of a car. To prevent the holder from rotating by itself, I glued a small wire from the magnet out towards the side of the cat and truck. I then filed a small groove in the side of the bushing for the truck screw. The wire is the “key” in the groove that follows the truck motion – simple, easy, and cheap! See Figure  7. below.
 
Magnetic_Label.jpg
Figure 7. Keyed Magnetic Label
 
Please take note that the label shown in Figure 8. Is not lying flat to the bottom of the car. This has a tendency towards missed label readings. It is often easier to affix the paper label to a thin piece of plastic or stiff card, and then apply it to the truck or car as appropriate. Doing this will spare you problems in the future.
 
Truck_Label.jpg
Figure 8. “Bumpy” Non-Flat Label
 
By simply adding an R and/or F to the car label we can determine car orientation on the rails. By adding an FOT (Front of Train) or EOT (End of Train) tag we can mark an note when a train is starting or ending scanning. I’m sure other train/car “flags” will be added. While I have anticipated placing the scanners below the tracks, the physical orientation does not matter. Labels could be placed on the side of cars and scanned from the side of the train just as well. Although I have not figured out how to disguise the label, or reduce its size to a point where it is inconspicuous in this manner. Colored backgrounds of labels may also be possible, but label contrast is very important for successful reading. More experimentation is warranted. The most beneficial action I’ve taken is to place 2 labels (not immediately next to one another) on a car for increased reading reliability. It also seems to allow for a bit higher train speed while scanning. Why? I don’t know. Placing more than one label on a car is fine, but experience shows they should not be immediately next to each other.
 
I have found that sufficient light is very important. Useful Sensors suggested that their camera had no infrared filtering, and so near-infrared (invisible to the naked eye) might work for illumination. After trying a couple of near-IR LEDs for illumination, I found there simply was not enough light, and I could not locate cheap, ultra bright near- infrared LEDs. I did have some cheap, 18000 mcd (millicandela) 3mm green LEDs. I built my first sensor platform with two switched LEDs for illumination, shown below in Figure  9. I later switched to 20000 mcd white LEDs. This was a personal preference. What was needed was enough light for the scanner. Both green and white works well at these light levels.
 
IMG_7562.jpg
Figure  9. Early Mock Up testing using green 3mm LEDs
 
I also developed a simple scheme to point the LED at the correct scanning area, by placing a strip of paper or thin white plastic on the track area for scanning and watching the lighted “coverage area” as I adjusted the LED manually. This is shown in Figure  10. :
 
LED_adjustS.jpg
Figure  10. LED Adjustment View
 
I started using 0.5x0.5 QR Codes printed on high gloss photo paper (thinking resolution was important). I used two switched high brightness green 3mm LEDs. To my disappointment, I could barely read a code (attached to the underside of an HO car)… with the car stopped precisely above the reader! Oh no! After many hours of trial and error, I found two LEDs were not better than one with glossy tags! Lowering the light improved the readings. Also I fiddled with the top of sensor to top of rail distance -- 2.17” -- (and hence the sensor to QR Code distance) to determine that there was a nice working depth of field of about 0.5-0.75” for the reader. The reader runs in read cycles of about 200ms, or 5 per second. I was hoping to see if the reader could scan a moving train at any speed at all. Otherwise I would have to stop each car precisely above the sensor – its position and centering should be workable, but I wanted to scan a moving train. After several frustrating trials, I decided to change from glossy paper to plain, 20 pound office paper. Unbelievably, the readings improved considerably.
 
Hardware
 
With the scanner basics confirmed, I went on to put together the rest of the system. I wanted a WiFi connection, initially to a web page list that could be read anywhere. I also wanted the ability to retain train lists and detailed car information for at least 500 cars. I eventually selected an ESP32 PICO module variant for processing and communication, low cost, high pin count, with a large 8MB program memory and 2MB working PSRAM. With all features turned on, only 66% of program storage is currently used.
 
Figure  11. and Figure 12. below show all the major components. The ESP32 PICO and the TCR are connected via a four pin I2C cable. I also used a 128x128 OLED display for local readings and debugging. This display is optional. The display can be daisy chained via the four line I2C cabling for a very easy “build.” A review of all the working ESP32 variants are discussed in the Bill of Materials (BOM) below. Once a car label is read, it can be displayed on the local OLED display, or transmitted via USB serial port to a PC, or transmitted as an updating web page via WiFi, or transferred via WiFi to an MQTT server and onto any subscriber -- like JMRI reporters. JMRI can collect and store latest car label scans, build a train consist, and retain all car labels for all railcars passing through your layout empire.
 
ACI Basic Config.jpg
Figure  11. ACI Basic Diagram
 
There are several workable options that one can choose for the processor module and the local displays. Most any I2C 3.3 Volt display will work, as long as its I2C address does not conflict with the TCR address of 12 (or 0x0C Hex). Be careful when substituting processor modules with less memory. I believe there will be additions and enhancements to come sometime later. Also be cognizant of the 3.3 Volt regulator current limitations on the processor module. The Adafruit ESP32 PICO QT PY I first used had a current capability of 600ma, which I thought was fine for both a small display and the TCR. However when I changed my display from a 128x64 to a 128x128 display, it ran very warm to the touch! It never failed, but I found out the WiFi RF current peaked around 425ma under long transmission loads. As it turned out the ESP32 PICO Dev Board M-02 was cheaper and supplied 800ma. It was an easy choice.
 
ACI Componennts.jpg
Figure  12.  BOM Options
  1. ESP32 PICO (I have used these successfully and recommend these):
ESP32-PICO-DevKitM-2 Dev Board – available from many vendors, these had them for $10 each:
Adafruit QT Py ESP32 Pico - WiFi Dev Board with I2C QWIIC connectors  $14.95 -- https://www.adafruit.com/product/5395
TinyPICO ESP32 Development Board $21.95 --  https://www.adafruit.com/product/5028
 
Here are the boards I evaluated:
ESP32 PICO
Flash
PSRAM
SRAM
QUIIC I2C
SDA/SCL
SDA1/SCL1
Current
V Reg
Price
Adafruit QT Py ESP32 Pico
8MB
2MB
 
Yes
4/33
22/19
600ma
AP2112K-3.3
14.95
Adafruit ESP32 Feather V2 MINI-02
8MB
2MB
 
Yes
21/22
 
600ma
AP2112K-3.4
19.95
Adafruit ItsyBitsy ESP32 MINI-02
8MB
2MB
 
Yes
21/22
 
600ma
RT9080-3.3
14.95
SparkFun ESP32 Qwiic Pro Mini MINI-02
8MB
2MB
 
Yes
15/5
 
600ma
AP2112K-3.4
9.95
Digikey Espressif ESP32-PICO-DEVKITM-2
8MB
2MB
 
No
21/22
 
800ma
SGM2205
10
Espressif ESP32-PICO-DEVKIT-4.1
4MB
 
0.5MB
No
21/22
 
1000ma
AMS1117
18
Espressif ESP32-PICO-KIT-1
4MB
 
0.5MB
No
21/22
 
800ma
SGM2205
10
UM/Adafruit ESP32 TinyPICO
4MB
4MB
 
No
21/22
 
700ma
NCP167BMX330TBG
22
             
The Espressif ESP32-PICO-DEVKITM-2 Board has the most memory, lowest price, and an 800ma Voltage regulator which will easily power the QR Reader and an OLED display. The QT Py ESP32 Pico with a 600ma regulator will work, but the regulator runs very warm. In this case, I did not like “very warm.” All will work and handle a 200 car train in memory.
  1. Optional OLED displays – only I2C connected displays are recommended, for price and convenience. Try these for Adafruit, although most any I2C display with an SSD1327 driver will work. Smaller 128x64 OLED I2C displays are cheaper and will work too. Adafruit has displays with their QWIIC plug connectors which eliminates some soldering and hassle, but will cost a bit more.
  2. The Tiny Code Reader (TCR) QR Code Scanner – there is only one kind at present, available from:
Tiny Code Reader from Useful Sensors  Adafruit.com #5744   7.00
USEFUL SENSORS TINY CODE READER SEN-23352  digikey.com 1568-SEN-23352-ND  8.62
Useful Sensors Tiny Code Reader  Sparkfun.com   SEN-23352  7.00  
  1. 18000 or 20000mcd 3mm LED – white or green, like these:
 
  1. 30 Ohm 1/4 Watt resistor
Digikey CF14JT30R0TR-ND   0.10     RES 30 OHM 5% 1/4W AXIAL Resistor
Digikey 2019-RK73B2ATTD300JTR-ND   0.10    RES 30 OHM 5% 1/4W 0805  CHIP Resistor
 
Besides 5 Volt power connections to the ESP32 Dev Board M-02, all the connections are shown above. This is an easy electrical build. The only solder attachment needed is the 3mm LED to GND (short lead) and through the 30 Ohm resistor on the long lead to the 3.3 Volt pad on the TCR – see BOM Options Figure 8.
You can use the Adafruit STEMMA QT / Qwiic JST SH 4-Pin Cable  https://www.adafruit.com/product/4210
Or equivalents to make quick work of interconnecting the local display and the TCR. You can also use it to connect to the Adafruit QT Py ESP32 Pico - WiFi Dev Board with I2C QWIIC connectors if you use this processor (Figure 13.). I prefer to use the ESP32-PICO-DevKitM-2 Dev Board and the Adafruit STEMMA QT / Qwiic JST SH 4-pin cable  https://www.adafruit.com/product/4397  instead. I cut off the female connectors and solder the connections directly as pictured in Figure 9.  Five Volt power comes into the processor board via the USB connector or the +5V and GND pins.
 
qwiic cable.jpg
Figure 13. Adafruit QWIIC Cable for easy I2C connections
 
Mechanical Mounting
 
The early mock-up shown in Figure 9. and Figure 14. attached the TCR to a bottom shelf and the distance from the top of TCR to the top of rail (eventually at 2.17 inches). This was done by shimming the TCR mount which I made out of scraps of styrene strip. The TCR has components on both sides of the board and only one 2mm mounting hole. Leveling the TCR so it looked straight up, and centered between the rails was very important. My belief was that this did not represent the most likely mounting scenario for most model railroads. Rather, I assumed that the TCR would more likely be suspended below the track/railbed. Remember that a length of track would need the center set of ties removed (1 5/8 inches) so the QR labels were visible with no obstructions or shadows. I wanted a very low cost mount that did the job.
 
TinyCodeReaderMount1b.jpg  TinyCodeReaderMount1.jpg
Figure 14. Prototype Mount                                                                                              Figure 15. TCR
 
Ultimately, I decided to try my hand with a 3D printed mount, that would hold the TCR suspended by four 1/16 rods connected to a simple mount above the ties alongside the track. Amazingly, it all worked! Figure 16. Shows the 3D print of the TCR mount. It took about 18 minutes to print and has 5 holes/dimples placed to allow for drill alignment. All 3D printer files are in this article’s zip file for downloading.
 
TCR_Mount2.jpg
Figure 16.  TCR 3D Printed Mount
 
TCR_Mount2b.jpg
Figure 17.  TCR Mounted
 
Four 1/16 holes were drilled in the four corners of the TCR mount. The fifth hole was drilled for a 2-56 screw and threads tapped for the board mount. Remember that when the LED was attached to the TCR with dropping resistor, no protrusions were allowed below the board. This was to permit an even mount in the base. Two styrene strips were chosen to fit above the track ties and below the rail tops. Four more 1/16 holes were drilled slightly wider than the 4 holes in the TCR mount to provide a little tension on the supports. You can see a slight bend in the 1/16 rods in Figure 18.
 
Suspended Mount.jpg
Figure 18. Suspended TCR Mount
 
You will find that the rods are a tight fit after you drill the support holes. I used a small reamer from MicroMark.com https://micromark.com/products/micro-size-precision-reamers-set-of-6?keyword=reamer
(See Figure 19.) to just barely allow the rods into the holes with a little effort with some smooth long nose pliers. You want the friction to hold the mount in place as you position it to the right height and center the TCR lens between the tracks. If you make the holes too large (for too loose a fit) you can use some long nose pliers to slightly crimp the styrene rod near the hole site, to create a tighter fit. Besides depth and centering, it is important that the vertical axis of the lens be perpendicular to the track, even if the track is on a grade. Once the TCR mount is set, power on the TCR and the LED should light. Put a piece of paper over the track and center the light in the middle of the cleared ties in the track as demonstrated in Figure 10. Be careful to hold the TCR board in place to not rip the LED off the board or disturb the suspended mount. You will find you can rotate the mount in place, change its height, level, and position relative to the track. This is not difficult if you take your time and are careful. It only took me three tries. 😛 Once the mount is stable and tested, it can be permanently fixed in place with a few drops of glue. If you have to remove it, you can drill out the mounting holes and re-suspend the mount anywhere.
 
Reamers.jpg
Figure 19. Reamers
 
While this mount works, and is relatively easy to put in place, I asked fellow modeler, good friend (and national treasure), Dave Merrill to see if a self-aligning, and self-positioning mount could be designed to make this even more simple. After quick iteration Dave redesigned my mount to produce an easy, elegant solution, shown in Figure 20. It replaces a few ties on either side of the scanner, and is very easy to install. It self aligns the TCR between the rails. It can be glued, screwed or spiked in place. The 3D CAD files are also included in the download. A 2mm screw is used to fix the TCR in place. The PLA plastic will take the screw as is, to form the threads. A 2-56 screw will do the job too.
 
SelfMount1.jpg  SelfMount2.jpg
Figure 20. 3D Printed Partially Self-Aligning TCR Mount
 
NewMount.jpg
Figure 21.  New TCR Mount in Use with White LED
 
 I encourage modelers more talented in this area than me to present a better solution. I very much suspect there are even better solutions to be invented.
 
Loading and Configuring the ESP32 Processor
 
No programming is needed to make your ACI scanner operational, but you do need to give it some operating information and load your processor. All the files are provided in the article download found here:
 
The modeler will need to learn to download the code (sketch) to the ESP32 and edit any variations he wants to make.
 
Arduino IDE setup has been covered before several times including here: A modeler’s introduction to the Arduino,  MRH, Dec 2016 --  http://mrhpub.com/2016-12-dec/online/html5/index.html?page=1&noflash
Loading an ESP32 requires a bit more work, described in Production\Additional_Materials\Additional_Documentation\Starting Arduino Editor & ESP32 PICO.pdf in the accompanying download package.
 
When you are done setting up the Arduino editor software, put the entire contents unmodified of the\Production\Additional_Materials\Arduino\Sketches folder from the download link into your …\Documents\Arduino\ directory. Put the entire contents unmodified of the \Production\Additional_Materials\Arduino\libraries folder from the download link into your …\Documents\Arduino\libraries directory. Put the entire contents unmodified of the\Production\Additional_Materials\Arduino\tools folder from the download link into your …\Documents\Arduino\tools directory. Find the QR_Reader_Server_128Disp_2_15_MQTT.ino file in the QR_Reader_Server_128Disp_2_15_MQTT folder you added, open, compile, and load it into your ESP32. It is still possible to program ESP32 PICO  after it is connected to your ACI scanner.
 
To use ACI, you should change the Wifi ssid and password in QR_Reader_Server_128Disp_2_15_MQTT.ino to whatever you want to use. QR_Reader_Server_128Disp_2_15_MQTT uses your own local WiFi.
 
Playing Wifi, JMRI, and MQTT reconfiguration games is beyond the scope of this article, but I may add more detail later, if needed. I hope the information presented in this article will point modelers in the right direction.
 
On ESP32 File System Load
 
One means of generating Car/Train reports is through web pages to any browser. To load the HTML used by the ESP32 you will need to load a file set into the internal file system called SPIFFS in your ESP32. You will need to use the Arduino 1.8.19 version of the Arduino editor (IDE) to do this, as the file transfer mechanism is not available as yet in the newer Arduino 2.3.2 IDE. First, verify that you have downloaded and setup your Arduino 1.8.19 IDE (described previously). Make sure you copied in whole the ESP32FS folder and its contents from the article zip:  Additional_Materials\Arduino\tools to your folder …\Documents\Arduino\tools folder.
 
Open the Arduino IDE, select the correct Board from menu: Tools->Board->ESP32 Arduino->ESP32 Dev Module. Once you have the correct board selected make sure under menu pick Tools and check that you have these options selected:
Board: ESP32 Dev Module
Flash Size: “8MB (64Mb)
Partition Scheme: “8M with spiffs (3MB APP/1.5MB SPIFFS)”
PSRAM: Enabled
Port:     ß Make sure this is correctly selected
Next, select from the Tools menu pick ESP32 Sketch Data Upload
And a window should open with  Select FS for QR_Reader_Server… / data folder
In the selection bar select SPIFFS  and the select   OK
In the messages at the bottom of the window you should see SPIFFS Image Uploaded with the last message
->Hard resetting via RTS pin…
 
Operating with Automatic Car Identification
 
Once built, operating ACI is pretty easy. ACI needs a 5 Volt DC source connected to its +5V and GND. You can also power the ESP32 Board via the USB connection. The local OLED display should power up quickly and display Car Reports. If you have the Serial Monitor enabled through the ESP32 USB connection, messages should begin appearing after power up.
 
Before power is connected to the ACI module, set up your WiFi connection to the net with the ssid and the appropriate network password. If you know your local router’s IP Address, and Gateway, you have the option to specify a static local IP Address for your ACI scanner by uncommenting line 10 and specify the static IP Address in line 95. Select using the Serial Monitor in the Arduino IDE and watch for:
Connecting to WiFi..
Connecting to WiFi..
192.168.1.177
Client ACI-10C:8B:95:B7:94:E8 contacting MQTT broker
 
The IP Address displayed --  192.168.1.177 – is the address of your ACI Scanner. Enter this address
in your browser URL address and watch for the car IDs read from the scanner. If you have set up a local OLED display, it should power up with the words “Car Reports” and then display ear car ID read with a scaled random number (which I was imagining might be a car weight).
 
To use MQTT transmission correctly your must provide the IPAddress or host ID of the MQTT broker in line 97
and the topic on which to publish the ACI data in line 98 like “trains/track/reporter/1” which is consistent with the MQTT naming convention in JMRI. Reporter #1 must be set up in the JMRI Reporter Table as MR1. Any number may be used. Each ACI scanner should correspond to a unique JMRI Reporter.
 
MQTT brokers must be running and ready before JMRI and the ACI Scanners are powered on. I used the Mosquitto MQTT broker freely available online at https://mosquitto.org/download/   and also included in the Additional Materials in this article’s download zip. If you install mosquito on your PC you will need to add the config file mosquitto.conf included in the Mosquitto MQTT Broker folder in the download zip to where ever you installed mosquito (likely C:\Program Files\mosquitto ). The mosquito MQTT Broker is started from a windows command line:
  1. Open a window with the command prompt
  2. Change directory to the folder where you loaded mosquito (likely C:\Program Files\mosquitto )
  3. type mosquito.exe -c mosquito.conf
And a widow should open indicating something like:  mosquito version 2.0.14 running
 
The first space in the QR Label (like NYC 201229) will be deleted by the ACI system and transmitted to the MQTT broker as the first parameter, which JMRI will search for and create a unique ID in the IDTag Table, like NYC201229
Together with Where seen (the Reporter ID – MR1) and When seen (the date-time stamp)
What the modeler wants to do next in JMRI is up to them.
 
If you have set up a connection to an MQTT server, a successful connection will be indicated like:
Connecting to WiFi..Connecting to WiFi..192.168.1.177Client ACI-10C:8B:95:B7:94:E8 contacting MQTT brokerACI broker connected
 
If no MQTT broker is found after 10 attempts, you will see:
Client ACI-10C:8B:95:B7:94:E8 contacting MQTT broker
Client ACI-10C:8B:95:B7:94:E8 contacting MQTT broker
Client ACI-10C:8B:95:B7:94:E8 contacting MQTT broker
Failed MQTT Connection state -2
and MQTT communication will not be re-attempted until reset or the next power cycling.
Assuming you have mounted the ACI scanner below your roadbed, and opened up a “scanning window” between the rails, generate an appropriate car label, like UP 7328812, resize it appropriately, and attach it to the underside of a test car. Place the car on the track near the ACI scanner, and slowly roll it over the powered scanner. The LED will light the underbody of the car, regardless of the ambient lighting in the room, and the scanner should read the car label, and publish it via all enabled communications lines – local display, USB serial port, HTTP web service, and via the MQTT broker. You may need to aim the LED better if you forgot this step before. Manually move the car over the scanner faster and faster until it will not read at all to get an idea of the speed acceptable for scanning. Try putting two of exactly the same tag on one car and see if it improves your ability to read the car. The small blue LED on the top of the TCR will turn green when the TCR successfully scans a QR code. You can leave it directly above the TCR and it will repeatedly read the same code over and over again.
 
You can set line 29 in the sketch from:
bool displayall = false;   // Set this true to recognize every ACI read
to
bool displayall = true;   // Set this true to recognize every ACI read
to eliminate multiple reads of the same label.
 
Line 30: 
#define MaxCarsInTrain  200
Is set to remember a maximum of 200 cars internally. I have set this higher (500) but see no reason for the higher number at present. When it hits the maximum it will flush the table and start over.
 
I am anticipating more changes are likely to be made, and be suggested sometime in the future, which is why I opted for more memory in the processor module. Realize that inventive minds, with new labels, could tune the ACI read to become something more than a car counter for their railroads in time. Just consider the added information to supplement your railroad operations. For me, this is actually more integral to: SMA45 Intelligence On Board – Ideas for Model Railroading Beyond Mobile DCC Control
than it is to what most modelers would consider “Operations.”
 
Please let us know what you do with your own ACI Scanner… and Have Fun! 😊
As always, appropriate comments and suggestions are always welcome.
 
Have fun!  😊
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 19
Geoff Bunza geoffb
Hi All,
 
First, a big thank you for all those who have continued to point out typos and other mistakes. There is a bug in the forum software (reported) where if I edit the article, I will loose the embedded video, which I want in the article. So I am either waiting for a fix, or I will figure out another way to work around the bug, maybe with the "Part 2" filler comment I added earlier.
 
Next, part of the speed up with fewer characters in the label is due to decoding lots more characters and the transmission of the I2C lines to the processor.
I don't think there is much savings below the 20 character number that I suggested. It's one of those observations that just seemed to fit!
 
I will be publishing an update soon to the reader system. Thanks for all the interest and kind comments-- all appreciated.
 
Have fun!  🙂
Best regards,
Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 4
barr_ceo
Back in February Amazon offered a small Bluetooth/USB printer that would print QR codes on 1/2 inch tape... small enough to use on N scale cars and locomotives.
 
Here is the thread from then... an example of the QR code is in one of the posts.

Read my Journal / Blog...

!BARR_LO.GIF Freelanced N scale Class I   Digitrax & JMRI

 NRail  T-Trak Standards  T-Trak Wiki    My T-Trak Wiki Pages

Reply 0
Neil Erickson NeilEr
So I am either waiting for a fix, or I will figure out another way to work around the bug, maybe with the "Part 2" filler comment I added earlier.
@geoffb - how about an errata page? Not uncommon and a way to address issues and not affect the video.  

Neil Erickson, Hawai’i 

My Blogs

Reply 3
jeffshultz
A video of the 2nd Division Meet where Geoff introduced this project will soon be uploaded to YouTube:
 
 
While he did ask me to delay publishing the section where he demo'd the ACI, I'm pretty sure he didn't expect me to take this long... (I got turned off of editing videos due to the reaction of someone who thought I was videoing his layout for profit... Joe doesn't pay me for that stuff. Long Beach seems to have gotten me back into it.)

orange70.jpg
Jeff Shultz - MRH Technical Assistant
DCC Features Matrix        My blog index
Superintendent, 2nd Division PNR, NMRA
Northwest Oregon/Southwest Washington

Reply 1
eastwind
Somehow I missed this thread until now. Great stuff!
 
While there are no add-ons to the camera, there still might be an easy/cheap way to add an external lens that would reduce the focal length and let you reduce the depth of the under-layout pocket. Given that the depth is only two inches or so to start with, I think this idea is probably not worth bothering with, but I thought I'd throw it out anyway, maybe someone will be able to improve on it.
 
What I'm thinking of is to cannibalize a pair of reading glasses and use one of the lenses. It's going to be way to large, but the extra size gives you attachment area. It should be easy to add some posts to the 3d printed mounting bracket and then attach the lens to the posts with CA. If desired a specific pair of glasses from amazon could be standardized upon so once the mount has been designed and adjusted others won't have to re-fiddle it.
 
I'm not sure whether drugstore lenses, with a plus diopter will do the right thing or whether what's needed is a minus diopter, but I think it should be plus, and therefore non-prescription.
 
I am also wondering if it is possible to 3d print lenses using hobby printers. Is there a resin that dries clear? That would let you print a custom lens for the module.
 
I think there is a pretty good use case for Geoff's creation even with only one reader per layout, and that would be to generate paperwork for operators. When setting up for operations, you assemble the train in staging however you want, and then drag it over the reader to produce the list of cars in the train.

You can call me EW. Here's my blog index

Reply 1
kenheywood
In an ops session a few months ago, my job was "driller".
The drill takes arriving trains in the yard, breaks them, and shoves the rolling stock into classification tracks.
Normally, the drill needs a good pair of eyes to read the car ID, check the list to determine which track.
The host spoiled me because each car, loco, and caboose had an RFID chip.
All I had to do was shove the string past the sensor on the arrival track.
The sensor read the chip and the computer displayed the proper track to place the car.
The computer running JMRI software used the car ID with an OperationsPro switch list to determine track.
 
Jeff's QR code reader on that arrival track could perform the same function.
The QR label seems much easier to create than programming a RFID chip and maybe less expensive.
And, using a cell phone, the car could be ID'd off layout as well (staging/storage maintenance).
Neat.
Reply 1
CATPLUS
Hello,

I have been using RFID detection (see video) for several years for 2 types of equipment.
125Khz for cars, 13.56Mhz for locomotives
I made an Arduino to Excel interface
 
 
Regards
Reply 1
Reply