.................................. Return to Sumner's Home Page....
Return to N Scale RR Main Menu........ Return to SpeedTrap Menu
=========================================
..............Previous Page..............................Next Page If There Is One
=========================================
…..........--- N Scale SpeedTrap Speedometer – Pt. 5 ---
..... --- Load the Software/Sketch for esp32 ---
=========================================
This can be the hardest part of the build possibly if you haven't done this before. I remember it being pretty overwhelming the first time I had to load the software/sketch for an Arduino. An esp32 uses for the most part the same software and you load it the same as you would for an Arduino. So if you've done that you are probably home free. If not see if the following instructions and if that doesn't work search the web for help, contact me ( contactsumner1 (at) gmail (dot) com ) or look to support on Discord ( HERE ) or on one of the other internet boards.
=========================================
Loading the code (if the first time for this take your time and follow the steps slowly):
1. Connect the SpeedTrap speedometer to your computer and Download the Arduino IDE.
...Available from https://support.arduino.cc/hc/en-us/articles/360019833020-Download-and-install-Arduino-IDE
2. Open the Arduino IDE.
3. Download the esp32 boards in the Arduino IDE with the following steps. ( Use ESP32 by Espressif Systems Ver 3.0.0 or later)..
...a.) In the Arduino IDE, go to 'File' > 'Preferences'
...b.) Enter the following into the 'Additional Board Manager URLs' field (bottom of page):
..…....…... https://dl.espressif.com/dl/package_esp32_index.json
...c.) Then Use the 'Boards Manager' in the 'Arduino IDE' to install the esp32 board support:
...…...... Go to 'Tools' > 'Board' > 'Boards Manager'
...…...... Put 'esp32' in the search window.
...…...... "esp32" by Expressive Systems should show as an option.
...…...... Install it.
...d.) Next you need to install LiquidCrystal I2C library by Frank de Brabander.
...…...open the Library Manager in the Arduino IDE and install it from there.
...…...... Go to 'Tools' > 'Manage Libraries'
...…...... Put 'LiquidCrystal_I2C' in the search widow.
...…...... 'LiquidCrystal I2C' library by Frank de Brabander should show as an option.
...…...... Install it.
...e.) Open the 'Arduino folder' in 'Documents' and create a folder called SpeedTrap.
...f.) Re-open the Arduino IDE if it is not open (there should be a short sketch showing).
...…...... Open the internet link shown next that is for the software/sketch you want to load:
...…...…...... Sketch for 'straight' SpeedTrap showing MPH........ ( HERE )
...…...…...... Sketch for 'curved' SpeedTrap showing MPH......... ( HERE )
...…...…...... Sketch for 'straight' SpeedTrap showing KPH........ ( HERE )
...…...…...... Sketch for 'curved' SpeedTrap showing KPH......... ( HERE )
...…...... Copy and paste the sketch from the link into the Arduino IDE over the top of what is there creating a new sketch.
...…...... Go to 'Tools' > 'Boards' > 'ESP Arduino (or esp)'
...…...... Go down the esp boards and select 'WEMOS LOLIN32 Lite'
...…...... Go to 'Tools' > 'Port' and select the COM port you are connected to. Probably the second one or plug and un-plug to see it.
...…...... Go to the top of the screen and click on the 'upload arrow' under 'edit' to the right of the 'check mark'.
...…...... As it loads you will probably get the following warning. Ignore it.
.……....…...... WARNING: library LiquidCrystal_I2C claims to run on avr architecture(s) and may be incompatible
.……....…...... with your current board which runs on esp32 architecture(s).
...…...... The program/sketch should load and SpeedTrap should start with a 'Waiting on Loco' message.
...…...... If it doesn't compile and load there should be an error message that will help you or someone else.
...…...... Most likely it is something fairly simple that needs fixed. If you can't figure it out reach out for help.
4. The software you loaded will work for either the 'straight' SpeedTrap or the 'curved' SpeedTrap as it is written.
...Using it with the 'curved' version speeds will be 1-2 mph higher due to the distance between the IR sensors
...being slightly closer. You can adjust that in the software by changing the following two lines of code as shown.
...…................................................................................................................................................................................................................................
...…...... Down in the 'void setup() section of the code change from the following:
constantMph = 57000; // Use for Straight SpeedTrap--Comment out with '//' if you are using the 'Curved SpeedTrap'
..... // constantMph = 55500; // Use for Curved SpeedTrap--Remove the '//' in front of constantMph = 55500 -- Comment out the line above.
...…...... To the following:
. // constantMph = 57000; // Use for Straight SpeedTrap--Comment out with '//' if you are using the 'Curved SpeedTrap'
constantMph = 55500; // Use for Curved SpeedTrap--Remove the '//' in front of constantMph = 55500 -- Comment out the line above.
...…................................................................................................................................................................................................................................
...If you only use one or the other of the two SpeedTraps the 1-2 mph probably isn't going to make a difference. If you use
...both on the layout like I do I would download the 'straight' SpeedTrap code into the 'straight' one and then make a second copy
...of the code with the changes for the 'curved' one and load that code into the 'curved' SpeedTrap.
SpeedTrap Operation:
...Operating SpeedTrap is very simple. It will read a locos speed coming from either direction. It will show the speed and hold
...…... the speed on the top line of the display. To read a new speed push the reset button on the top of the case. The last speed
......... will move to the bottom line and it will wait for a loco again.
..................................................................................................................
For the whole SpeedTrap speedometer build go ( HERE ).
=========================================
...........................On..............e.........Next Page If There Is One