ESP32 Built-in OLED – Heltec WiFi Kit 32 DCC++ Questions

LMSFan72 Jan 15, 2019

  1. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    I have put an LED in parallel with the MOTORBOARD_ENABLE_PIN_MAIN pin and tried each of the pins I identified in my earlier test. I cannot find a pin that is switching! The DCCpp32 station responds on the OLED but it doesn't seem to send anything to the pins.... Could this be the board config file? I'm running out of ideas..

    I wonder if anyone has a very simple sketch I can use to set a pin high or low so I can check the actual board?
     
  2. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Wow. I think I have cracked it... The board layout as downloaded from http://www.heltec.cn/download/WIFI_Kit_32-Diagram.pdf is not the same as my board. All the pins on the LHS on the diagram are on the RHS and visa versa..... I can't believe it. I ran the Blinker sketch from the Arduino IDE examples on each pin and proved each one, confirming input only pins at the same time... Hopefully a simple fix now..
     
  3. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    I have reverted to Mike's original pin configuration. The thing that I had missed before was that pin 25 is also the on board LED therefore, now that I have JMRI talking properly I can see it turn on when I turn on the track power! Motor shield revisiting tomorrow..
     
  4. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Success! So, documenting the the Heltec Wifi Kit32 and Pololu set up:

    On my board, OLED displaying so it's readable normally left-to-right I have the USB connector on the RHS. Top left pin is A0 (pin 36) and bottom left pin is 21 (SDA). This is the reverse of the Heltec WIFI_Kit_32-Diagram.pdf. Orientation is most easily checked by putting an LED into Pin 25 and running a simple sketch to blink it. The on-board LED will blink and to show it's working and the LED connected to the pin will also blink if you have the correct pin.

    Config_OLED.h:

    #define INFO_SCREEN_SDA_PIN 4
    #define INFO_SCREEN_SCL_PIN 15
    #define INFO_SCREEN_RESET_PIN 16
    #define OLED_CHIPSET SH1306
    #define INFO_SCREEN_OLED_I2C_ADDRESS 0x3C
    #define INFO_SCREEN_OLED_VERTICAL_FLIP false
    #define INFO_SCREEN_OLED_LINES 5
    #define INFO_SCREEN_OLED true

    Config_MotorBoard.h:

    #define MOTORBOARD_NAME_MAIN "MAIN"
    #define MOTORBOARD_ENABLE_PIN_MAIN 25
    #define MOTORBOARD_CURRENT_SENSE_MAIN ADC1_CHANNEL_0
    #define MOTORBOARD_TYPE_MAIN POLOLU
    #define MOTORBOARD_NAME_PROG "PROG"
    #define MOTORBOARD_ENABLE_PIN_PROG 23
    #define MOTORBOARD_CURRENT_SENSE_PROG ADC1_CHANNEL_3
    #define MOTORBOARD_TYPE_PROG POLOLU
    #define DCC_SIGNAL_PIN_OPERATIONS 19
    #define DCC_SIGNAL_PIN_PROGRAMMING 18

    Connections:

    5V ESP32 -> shield VDD
    GND ESP32-> shield GND
    Pin 25 (MOTORBOARD_ENABLE_PIN_MAIN)-> shield pin D2 and M1PWM
    Pin 36 (MOTORBOARD_CURRENT_SENSE_MAIN)-> shield pin A0
    Pin 19 (DCC_SIGNAL_PIN_OPERATIONS) -> shield pin 7 (M1DIR)
    Pin 23 (MOTORBOARD_ENABLE_PIN_PROG) -> shield pin M2PWM
    Pin 39 (MOTORBOARD_CURRENT_SENSE_PROG) -> shield pin A1
    Pin 18 (DCC_SIGNAL_PIN_PROGRAMMING) -> shield pin 8 (M2DIR)
     
    Atani likes this.
  5. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Thank you for the details! Can you get me a couple up close and in focus pictures showing connections and I'll add it to the wiki?

    Sent from my ONEPLUS A5010 using Tapatalk
     
  6. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9

    Hi Mike. Sure thing - probably tomorrow.

    Whilst I have you....:)-)...

    I will be using this for my test track/smaller layout. My larger layout currently runs a Mega with a Pololu so that I can connect lots of sensor pins for loco detection. The ESP32 doesn't have enough pins for that though. So, is the best option with that to add the ESP8266 to it to make it wireless or is there another way to use the ESP32 and add more pins.......... If it's the ESP8266, any pointers to setting it up would be very helpful. Many Thanks, Andy
     
  7. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    There are a few options... Remote Sensors, I2C IO expanders, S88 bus, LocoNet (soon!), LCC (soon!)

    Since you have an Arduino Mega the easiest likely would be an S88 bus as you have all that you need now :) Take a look at Config_S88.h for the pin assignments and then you can create a bus via the web interface using any free pin for the input pin (you need four pins total: clock, reset, load, data). The data pin would need to be unique per bus or you can have one bus and attach all S88 nodes off of it (likely easiest)

    If you are already looking at an ESP8266 (or similar) you could set it up as a RemoteSensor to report state periodically to the base station using something like this as a payload:
    Code:
    POST /remoteSensors
    {
      'id' : <sensor ID>,
      'value' : <status value>
    }
    
    The value can be any sort of value and will be reported to JMRI as "ON" when value is not zero and "OFF" otherwise.
     
  8. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks Mike. I will open a new topic to discuss this further but post the photos of the ESP32 solution here alter
     
    Atani likes this.
  9. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Hi Mike. I couldn't get a decent photo with the wires in the way so I put together this pdf set up doc. Will this work for you?

    PS: where is the wiki - I have searched and not found!!
     

    Attached Files:

  10. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
  11. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    @Atani

    Hi Mike, I thought I'd pursue this idea further now! I'm completely unfamiliar with S88 but it looks like I need to write a sketch for the Mega and then wire the S88 bus pins I configure on the Mega to the pins configured on the ESP32 - is that right? Were you also suggesting that I could use an ESP8266 attached to the Mega as a wireless way of sending the S88 data to the ESP32. Do you have any more links or info I can learn from? Many Thanks, Andy
     
  12. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Basically yes, the mega can talk to the esp32 directly via an s88 connection (lots of examples for Arduino for this) or you could use the esp8266 as a wifi gateway of sorts to push sensor data to the CS via http.

    Sent from my ONEPLUS A5010 using Tapatalk
     
  13. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    I am still losing connection between JMRI and the ESP32 frequently. I have noticed when if fails it does two things:

    1. Initially the power in JMRI turns off but not on the ESP (according to the OLED) and I can still send some commands
    2. It then goes unresponsive after a while and I see connection error message and the OLED screen is blank

    I thought I would try and test different scenarios.
    1. See if the ESP just drops out without JMRI running but no track power on
    2. See if it drops out without JMRI running but track power on
    3. See if it drops out with JMRI running (just booted up) and nothing ever run

    I can do 1 and 3 but I don't know how to send a power on command outside of JMRI. Can it be done and if so how?

    Many Thanks, Andy
     
  14. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    This can be ignored, it is a bug and will be fixed soon.

    This sounds like the I2C commands are being lost or there may be a power supply issue. How are you powering the OLED screen?
     
  15. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    missed this one, you can do this from the web interface on the CS.
     
  16. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    The OLED is integrated to the board so it’s getting power from the USB port
     
  17. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks, I forgot about that! I will try it out
     
  18. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    If you can capture the serial console output from the esp32 when this happens as well as the jmri logs it would be great. I'm not sure why it might lose connection but there have been a few issues reported with the AsyncTCP code which I'm looking at replacing.
     
  19. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    So, I am really struggling to get any useful debug info! JMRI system console, we can see timeouts:

    2019-03-22 16:23:26,950 util.Log4JUtil INFO - ****** JMRI log ******* [main]
    2019-03-22 16:23:28,268 util.Log4JUtil INFO - This log is appended to file: /Users/Andrew/Library/Preferences/JMRI/log/messages.log [main]
    2019-03-22 16:23:28,269 util.Log4JUtil INFO - This log is stored in file: /Users/Andrew/Library/Preferences/JMRI/log/session.log [main]
    2019-03-22 16:23:28,280 apps.Apps INFO - PanelPro version 4.14+Rd060e0b starts under Java 1.8.0_201 on Mac OS X x86_64 v10.14.3 at Fri Mar 22 16:23:28 GMT 2019 [main]
    2019-03-22 16:23:30,583 apps.Apps INFO - Starting with profile ESP32_Test_Track.3e1739ad [main]
    2019-03-22 16:23:30,879 node.NodeIdentity INFO - Using jmri-jjn1TaCHGhOiaaHfovkidd-3e1739ad as the JMRI Node identity [AWT-EventQueue-0]
    2019-03-22 16:23:31,027 xml.AbstractSerialConnectionConfigXml INFO - Starting to connect for "LocoNet" [main]
    2019-03-22 16:23:40,692 server.WebServer INFO - Starting Web Server on port 12080 [WebServer]
    2019-03-22 16:23:40,751 apps.PerformFileModel INFO - Loading file /Users/Andrew/Library/Preferences/JMRI/ESP32_Test_Track.jmri/Test Track.xml [main]
    2019-03-22 16:23:41,332 server.WebServer INFO - Starting ZeroConfService _http._tcp.local for Web Server with properties {path=/, json=4.1} [WebServer]
    2019-03-22 16:23:42,410 util.FileUtilSupport INFO - File path program: is /Applications/JMRI/ [main]
    2019-03-22 16:23:42,410 util.FileUtilSupport INFO - File path preference: is /Users/Andrew/Library/Preferences/JMRI/Shared/ [main]
    2019-03-22 16:23:42,411 util.FileUtilSupport INFO - File path profile: is /Users/Andrew/Library/Preferences/JMRI/ESP32_Test_Track.jmri/ [main]
    2019-03-22 16:23:42,413 util.FileUtilSupport INFO - File path settings: is /Users/Andrew/Library/Preferences/JMRI/ [main]
    2019-03-22 16:23:42,413 util.FileUtilSupport INFO - File path home: is /Users/Andrew/ [main]
    2019-03-22 16:23:42,414 util.FileUtilSupport INFO - File path scripts: is /Users/Andrew/Library/Preferences/JMRI/Shared/jython/ [main]
    2019-03-22 16:23:43,192 PanelPro.PanelPro INFO - Main initialization done [main]
    2019-03-22 16:23:48,301 withrottle.FacelessServer INFO - Published ZeroConf service for 'test track._withrottle._tcp.local.' on 2a00:23c0:7380:7601:e5bd:1654:8d2b:bd6b%en0:12090 [WiThrottleServer]
    2019-03-22 16:23:50,931 withrottle.FacelessServer INFO - Published ZeroConf service for 'test track._withrottle._tcp.local.' on 192.168.1.185:12090 [WiThrottleServer]
    2019-03-22 16:23:53,649 withrottle.FacelessServer INFO - Published ZeroConf service for 'test track._withrottle._tcp.local.' on 2a00:23c0:7380:7601:90a7:b204:3cd4:badc%en0:12090 [WiThrottleServer]
    2019-03-22 16:23:56,211 withrottle.FacelessServer INFO - Published ZeroConf service for 'test track._withrottle._tcp.local.' on 2a00:23c0:7380:7601:c46:a191:bd0f:379d%en0:12090 [WiThrottleServer]
    2019-03-22 16:23:56,379 withrottle.FacelessServer INFO - Creating new WiThrottle DeviceServer(socket) on port 12090, waiting for incoming connection... [WiThrottleServer]
    2019-03-22 16:27:43,436 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 0 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-03-22 16:28:13,441 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 1 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-03-22 16:28:43,442 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 2 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-03-22 16:29:43,450 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 4 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-03-22 16:30:13,453 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 5 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]

    Nothing showed up in the serial monitor!
     
  20. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    I lef tit running, and there's a couple of new ones:

    2019-03-22 16:54:30,788 dccpp.DCCppReply ERROR - DCCppReply value index too big. idx = 1 msg = e 0 0 0 0 1 [AWT-EventQueue-0]
    2019-03-22 16:54:30,789 dccpp.DCCppReply ERROR - DCCppReply value index too big. idx = 2 msg = e 0 0 0 0 1 [AWT-EventQueue-0]
    2019-03-22 16:54:30,790 dccpp.DCCppReply ERROR - DCCppReply value index too big. idx = 3 msg = e 0 0 0 0 1 [AWT-EventQueue-0]


    and in serial monitor:

    16:54:33.827 -> [W][AsyncTCP.cpp:630] _poll(): rx timeout 4
     

Share This Page