ESP8266 Wifi Shield for Arduino DCC++ Base Station

TexasRailroader May 8, 2017

  1. TexasRailroader

    TexasRailroader TrainBoard Member

    90
    26
    7
    Venturing into new territory, I'm configuring an ESP8266 for use as a wifi shield on my Arduino Mega DCC++ Base Station. I've installed the WiFiEsp library v2.2.1 and added it to the startup routine.

    Now what?

    It is broadcasting and I can connect my phone to it.
    Link Speed: 54 Mbps, Frequency: 2.4 GHz, Security: none
    It has a Static IP Gateway and IP Address or can use DHCP.

    Shield is an AI-Thinker ESP8266, 802.11 b/g/n

    Never used one of these and would like to use it with JMRI.
    Please advise where to go from here.
    ESP8266-1.png ESP8266-3.png
     
    Curn likes this.
  2. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    Seems nobody is advanced more than you on this.

    Want to have a stand-alone WiFi like your, but connect my phone directly to the Uno. Do not want to run JMRI.

    I have a program that should connect directly and set it up like JMRI connection.

    Engine drive should work also maybe.

    Dennis
     
  3. Curn

    Curn TrainBoard Member

    752
    500
    32
    I tried last night as I have one of those wifi cards, but just never tried to program it. I got as far as getting it to connect to my home wifi network, and was able to ping it, but I was unable to connect to it through JMRI.

    My attempt involved programming the wifi shield as shown in post #1404 (page 70) and described in post #1397 (page 69), using the code from post #1317 page (66) of the introduction to DCC++ thread. I configured the code to have my home networks SSID and wifi password, compiled and uploaded it. I needed to install 3 libraries to get it to compile. I spent most of my time finding them and figuring out how to install them. It had no issues connecting to the home network.

    This weekend I will try the code from the following thread to see if it works. I'll report back with the results. If I am successful I will try to write some instructions so that it's easier for the next guy. http://www.trainboard.com/highball/index.php?threads/dcc-basestation-with-wifi-esp.102984/

    The general idea is that DCC++ will be on the home network. Desktop running JMRI with wifithrottle server and web server will be running on the network will link up with DCC++. IOS or android devices with throttle app can connect to JMRI and control trains. I hope I can get it working and eleminat the USB cable.

    Matt
     
  4. TexasRailroader

    TexasRailroader TrainBoard Member

    90
    26
    7
    Very interested in your progress on this.
     
  5. TexasRailroader

    TexasRailroader TrainBoard Member

    90
    26
    7
    Unable to find post #1404 (page 70).
     
  6. Curn

    Curn TrainBoard Member

    752
    500
    32
  7. Curn

    Curn TrainBoard Member

    752
    500
    32
    Well, I haven’t had much luck getting mine to work. Looking at various posts spread around the DCC++ forum, the WangTongze shields are hit and miss. The problems seem to be with getting them to program, and or with the serial communications not working. I can program mine, and can get it to connect to my home network, ping it, but JMRI wont connect to it. It seems like I'm having problems with the serial communications to the DCC++ base station. There was some mention of lowering the baud rate, and I tried lowering the baud rate in UK Steve's ESP8622 .ino code (Intro to DCC++, Page 71, post #1417) to 57600, but saw no improvement. There is also some comments in the DCC++ base station code that indicates the Ethernet shield only works with Arduino Megas, so maybe my Uno isn’t enough.

    A Raspberry Pi is still my DCC++ Wifi connection of choice.
     
  8. TexasRailroader

    TexasRailroader TrainBoard Member

    90
    26
    7
    I have a Mega and it doesn't work with it either. If Arduino still made their WiFi Shield I'd buy it, but they don't make it anymore.
     
  9. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Hi guys! Wanted to let you know I am still around and my branch of the DCC++ base station should work with this shield. I don't have that shield but it should work. If you see problems with it let me know and I can try and track down one of these sheilds to test with. I also recently updated my code with the missing libraries and fixed a few issues that were reported. You can find my branch here: https://github.com/atanisoft/BaseStation
     
  10. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    I tried compiling your new base station code, but something is wrong. It cannot find my Mega and stops.

    I am new to using Arduino and need help in what file directory structure should look like.

    Yes I do have my base station up and running with your original code, with a couple of changes to see if it fixes a problem with reading indexed CV's of different decoder.

    Could you show where the updates should be installed in what directory?

    My setup is simple right now.

    Mega 2560
    Pololu motor shield
    Waiting on the WiFi shield to be delivered.
     
  11. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    You should be able to simply do a checkout from github the same as you did previously. The majority of changes are on the esp side with this update. The arduino side is only updated for sending the length of the ap name as part of the Connect string.

    Aldo which ide are you using? I use arduino eclipse but I have heard of success with the arduino ide as well. Make sure after you pull down the new code that you ensure the project is configured correctly for your arduino board and esp board.

    Sent from my ONE E1005 using Tapatalk
     
  12. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    Got back to Square 1.

    Here is the error message.

    Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

    C:\Program Files (x86)\arduino-1.8.3\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\arduino-1.8.3\hardware -tools C:\Program Files (x86)\arduino-1.8.3\tools-builder -tools C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\arduino-1.8.3\libraries -libraries C:\Users\Dennis\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10803 -build-path C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041 -warnings=default -build-cache C:\Users\Dennis\AppData\Local\Temp\arduino_cache_51221 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -verbose C:\Users\Dennis\Documents\Arduino\BaseStation-master\DCCpp_Uno\DCCpp_Uno.ino
    C:\Program Files (x86)\arduino-1.8.3\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\arduino-1.8.3\hardware -tools C:\Program Files (x86)\arduino-1.8.3\tools-builder -tools C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\arduino-1.8.3\libraries -libraries C:\Users\Dennis\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -ide-version=10803 -build-path C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041 -warnings=default -build-cache C:\Users\Dennis\AppData\Local\Temp\arduino_cache_51221 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr -verbose C:\Users\Dennis\Documents\Arduino\BaseStation-master\DCCpp_Uno\DCCpp_Uno.ino
    Using board 'mega' from platform in folder: C:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr
    Using core 'arduino' from platform in folder: C:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr
    Detecting libraries used...
    "C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10803 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\variants\mega" "C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041\sketch\DCCpp_Uno.ino.cpp" -o "nul"
    "C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10803 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\libraries\Wire\src" "C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041\sketch\DCCpp_Uno.ino.cpp" -o "nul"
    "C:\Program Files (x86)\arduino-1.8.3\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10803 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\variants\mega" "-IC:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\libraries\Wire\src" "C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041\sketch\DCCpp_Uno.ino.cpp" -o "C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041\preproc\ctags_target_for_gcc_minus_e.cpp"
    In file included from C:\Users\Dennis\Documents\Arduino\BaseStation-master\DCCpp_Uno\DCCpp_Uno.ino:171:0:

    C:\Users\Dennis\AppData\Local\Temp\arduino_build_262041\sketch\DCCpp_Uno.h:135:35: fatal error: LiquidCrystal_PCF8574.h: No such file or directory

    #include <LiquidCrystal_PCF8574.h>

    ^

    compilation terminated.

    Using library Wire at version 1.0 in folder: C:\Program Files (x86)\arduino-1.8.3\hardware\arduino\avr\libraries\Wire
    exit status 1
    Error compiling for board Arduino/Genuino Mega or Mega 2560.


    Seem to have a file missing that i need to comment out.
     
    Last edited: Jul 28, 2017
  13. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    When you downloaded did you get the LiquidCrystal_PCF8574 directory under DCCpp_Uno? It is configured as a submodule in git so that it should pull down automatically via the git client.

    You should also be able to disable this include via the config.h file towards the bottom of the file is a #define for LCD (I thought I had it disabled by default).

    EDIT: just checked and it was not disabled by default, you can disable it by doing this edit: https://github.com/atanisoft/BaseStation/commit/b3116e51997bd3417c7e80b0f3192924579a5a27
     
  14. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    Atani:

    I did a manual comment out of the LCD in Config.H and it now compiles.

    Also tried your change and it worked too.

    Thanks
     
    Last edited: Jul 28, 2017
    Atani likes this.
  15. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    Great! How did you download the latest? Was it via the github download option or was it via the git client?
     
  16. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    I am not familiar with Github changes, just did a finger change.
     
  17. Atani

    Atani TrainBoard Member

    1,469
    1,756
    37
    ok, how did you get the new code after I published?
     
  18. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    Just clicked on the link you gave me and looked at the changes needed.

    Compile and Uploaded to the Arduino Mega and so far it is operating well. Waiting on the slow boat from China with my WiFi Shield.

    Thanks
     

Share This Page