User Tools

Site Tools


users:dagnall53:description

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
users:dagnall53:description [2019/02/14 13:35] dagnall53users:dagnall53:description [2019/05/06 12:12] dagnall53
Line 1: Line 1:
 ====== WiRocs DESCRIPTION ====== ====== WiRocs DESCRIPTION ======
- 
-**'WiRocS'  a new name for 'ESPMQTTRocNetSound' shorter name, more capability and ESP32 compatibility** 
- 
 Index   Index  
   * [[:users:Dagnall53:Description|WiRocs Description]]    * [[:users:Dagnall53:Description|WiRocs Description]] 
-  * [[:users:Dagnall53:Node_Setup|Node_Setup]] +  *  [[:users:Dagnall53:RocClientThrottle|RocClientThrottle]] 
-  * [[:users:Dagnall53:OLED |Oled Usage]]  +  *  [[:users:Dagnall53:RocDisplayTop|Roc-Display Lite]] 
 +      * [[users:dagnall53:RDTextAlign|WiRocS 'RocDisplay' Formatting / Syntax]]:  
 + 
 +====== WiRocS ====== 
 +WiRocS is the name for a very inexpensive way to control your RocRail railway. It is not intended to replace more professional equipment, but it does provide a simple, inexpensive, Wireless, solution for small railways. 
 +WiRocS is actually 'just' some code that runs on ESP8266 (and ESP32) computers. These are readily available, and have massive capability. A single ESP8266 forms a single "WiRocS" Node and forms part of a standard RocNet Protocol Network. 
 +Each Node can have 8 fully programmable I/O (input/output/PWM/Servo), see also [[users:dagnall53:esp32differences|ESP32 setup]]. It can produce sounds from an internal sound file system, and can have a OLED display that is RocDisplay Compatible.  See [[users:dagnall53:oled|OLED display information]]  
   * [[:users:Dagnall53:Hardware|Hardware]]    * [[:users:Dagnall53:Hardware|Hardware]] 
-  * [[:users:Dagnall53:RocClientThrottle|RocClientThrottle]]+  * [[:users:Dagnall53:Node_Setup|Node_Setup]] 
 +  * [[:users:Dagnall53:Sound|Sound]] 
 +  * [[:users:Dagnall53:OLED |Oled Display]]   
 +      * [[users:dagnall53:RDTextAlign|RocDisplay Formatting / Syntax]]:  
 +  * [[https://github.com/dagnall53/WiRocS|Source Code]] 
 +  * [[:users:Dagnall53:Node_programming|Programming the Hardware (Arduino)]]   
   * [[:users:Dagnall53:Troubleshooting|Troubleshooting]]   * [[:users:Dagnall53:Troubleshooting|Troubleshooting]]
-  * [[https://github.com/dagnall53/ESPMQTTRocnetSound|ESP8266 Code]] +  * [[:users:dagnall53:description#setting_the_router_ssid_password_and_mqtt_broker_address_using_the_serial_interface|Setting WiFi SSID and Password]]
-  * [[:users:Dagnall53:Node_programming|Node_Programming]] +
  
 +----
  
-=====  Network overview ===== +======  Network overview ======
-The WiRocS / ESPMQTTROCNETSOUND code expects to work in a network where Rocrail is running and has a "ROCNET controller" using MQTT. (set Sub-Library to "MQTT"+
- +
-{{:users:dagnall53:rocnetmqtt1.jpg?400|}}+
  
 +{{:users:dagnall53:rocnetmqtt1.jpg?400 |}}The WiRocS code expects to work in a network where Rocrail is running and has a "ROCNET controller" using MQTT.(set Sub-Library to "MQTT").
 A MQTT broker, such as Mosquitto must be running somewhere on the on the network. (It can run on either the same PC as Rocrail or a different PC). A MQTT broker, such as Mosquitto must be running somewhere on the on the network. (It can run on either the same PC as Rocrail or a different PC).
 Rocrail needs to know the IP address of this MQTT broker, and this should be set in the Rocrail Rocnet Controller "Address" options with Port set to 1883 if using Mosquitto. (see illustration, where I use 192.168.0.11 for my Broker). Rocrail needs to know the IP address of this MQTT broker, and this should be set in the Rocrail Rocnet Controller "Address" options with Port set to 1883 if using Mosquitto. (see illustration, where I use 192.168.0.11 for my Broker).
Line 30: Line 37:
 ===== Operation ===== ===== Operation =====
  
-On power up the WiRocS nodes reads its internal EEPROM, and from this extract the WiFi Router name, password, and where they last connected to the Mosquitto broker. The code then waits for approximately 3 seconds during which you can intervene with a Serial Terminal like PuTTY, to allow easy interface for changes to the Router,password etc. If the node cannot connect to the MQTT broker, it will sequentially search IP sub addresses 3-127 in sequence to find the MQTT Broker This allows for the situation where the Broker is not reserved a DHCP address, but does delay the node's startup.+On power up the WiRocS node reads its internal EEPROM, and from this extracts the WiFi Router name, Password, and where it last connected to the Mosquitto broker. The code then waits for approximately 3 seconds during which you can intervene with a Serial Terminal like PuTTY, to allow easy interface for changes to the Router,password etc. If the node cannot connect to the MQTT broker, it will sequentially search IP sub addresses 3-127 in sequence to find the MQTT Broker This allows for the situation where the Broker is not reserved a DHCP address, but does delay the node's startup.
  
-Once the node finds the router it saves the MQTT Broker sub address and uses this on its next start up to save time.  +{{:users:dagnall53:esp_network.jpg?400 |}}Once the node finds the router it saves the MQTT Broker sub address and uses this on its next start up to save time.\\ 
 +The Nodes do not "know" where Rocrail is, nor do they need to. All communications are set via the MQTT broker.\\   
 +Rocrail addresses each Node by its ROCNET ID, which is usually initially set to the nodes subIP for simplicity.\\  
 +The system is therefore theoretically limited to about 250 WiRocS nodes, depending on what else the WiFI router is connecting, but the system is really designed for use with small layouts with dispersed stations, such as a Garden Railway.
  
-The Nodes do not "know" where Rocrail is, nor do they need to. All communications are set via the MQTT broker.   
  
-Rocrail addresses each Node by its ROCNET ID, which is usually initially set to the nodes subIP for simplicity.  
  
-The system is therefore theoretically limited to about 250 WiRocS nodes, depending on what else the WiFI router is connecting+---- 
 +===I/O Pin Capabilities=== 
 +Once connected to the MQTT broker, each node can be individually seen and modified by RocView.\\ 
 +Every ESP8266 node provides 8 universal i/o pins. "D1-D8". Every ESP32 node has 16 I/O\\ 
 +Each I/O is effectively a virtual  Pi02 channel with added Pi03 capabilities.\\ 
 +Rocview programming is used to set the functionality of each port.
  
-{{:users:dagnall53:wirocs_network.jpg?400|}}+{{:users:dagnall53:wirocs_esp8266.jpg?200 |}}{{:users:dagnall53:wirocs_esp32.jpg?200 |}}\\
  
-Each node can now be individually seen and modified by RocView. 
-Every ESP8266 node provides 8 universal i/o pins. "D1-D8". Every ESP32 node has 16 I/O 
-Each I/O is effectively a virtual  Pi02 channel with added Pi03 capabilities. Rocview programming is used to set the functionality of each port. 
  
-{{:users:dagnall53:wirocs_esp8266.jpg?400|}} 
-{{:users:dagnall53:wirocs_esp32.jpg?400|}} 
- 
-===I/O Pin Capabilities=== 
 PROVIDED that the Pin is not being used for an OLED display, Motor drive, Loco Front or Rear Light or other pre-defined function such as Loco Motor PWM drive, each I/O can be set by Rocrail as an input or output, using the "PI02 Port Setup" PROVIDED that the Pin is not being used for an OLED display, Motor drive, Loco Front or Rear Light or other pre-defined function such as Loco Motor PWM drive, each I/O can be set by Rocrail as an input or output, using the "PI02 Port Setup"
 This allows blinking, and inversion.  This allows blinking, and inversion. 
 +
 +----
 +
   * If the Pin is set as an OUTPUT, __and__ if the PI03 channel is set to SERVO, the pin becomes a Servo drive output.   * If the Pin is set as an OUTPUT, __and__ if the PI03 channel is set to SERVO, the pin becomes a Servo drive output.
-  * If the Pin is set as an OUTPUT, __and__ if the PI03 channel is set to "Blink", the output becomes a PWM output.+  * If the Pin is set as an OUTPUT, __and__ if the PI03 channel is set to "Blink", the pin becomes a PWM output.
   * For both Servo and PWM outputs, the code uses the "left" and "right" PI03 values for the PWM/Servo settings.    * For both Servo and PWM outputs, the code uses the "left" and "right" PI03 values for the PWM/Servo settings. 
   * "Left Steps" and "Right Steps" and "delay" settings all work to slow down and control the left - right transitions.   * "Left Steps" and "Right Steps" and "delay" settings all work to slow down and control the left - right transitions.
  
-the ESP32 code is identical, except that it has 16 programmable I/O, and the OLED I2C display uses a further two pins, so does not take up the 16  "programmable" pins+The ESP32 functionality is nearly identical, except that it has 16 programmable I/O\\ 
-  * There are some limitations on the ESP32 Pins. +  * On the ESP32 the OLED I2C display uses two pins that are not part of the 16 I/O
-  * Two pins (#34 and #35) can only be used as Inputs, and do not have the internal pull-up resistors that the other ports have. +  * There are some limitations on the four of the defined '16' I/O ESP32 Pins. 
-  * Two pins (#25, #26) are permanently DAC outputs, so send out 0-3.3v (as selected by their PI03 settings). +  * Two pins (#34 and #35) can only be used as Inputs, and do not have the internal pull-up resistors that the other ports have. 
 +  * Two pins (#25, #26) are permanently DAC outputs, so send out 0-3.3v (as selected by their PI03 settings). 
  
-On the ESP8266, the Sound output is driven by the Serial {Rx} Input. This needs a 1-10K ohm resistor that is connected to the base of an NPN transistor, whose collector is connected to the loudspeaker. The other Speaker connection is to 5V. This arrangement "squeaks" when the board is programmed, but gives remarkably good sounds, and does not use up any of the 8/16 I/O. On the ESP32 version, the Transistor base is connected to pin #22.  
 ---- ----
-  
  
-====  "STANDARD" Port usage summary ==== +===== First Time Programming =====
-----+
  
-The Code to compile the Node includes a lot of #Define statements that allow the code to be modified for various uses. This allows the node to be set up as a Static / or Mobile(LOCO) Node, and with or without Audio.  +[[users:dagnall53:node_programming|Programming the Hardware]] 
- +===== Setting the Router SSID,  Password and MQTT Broker Address using the Serial interface =====
-To select "Mobile" settings, use the "#define _LOCO_SERVO_Driven_Port 1". (This example sets D1 as the RC Servo drive, and also sets D2 and D5 as front and back light drivers). +
- +
-To use a Mobile (LOCO) node with a "PWM" drive rather than Servo drive, use "#define _LocoPWMDirPort  3 " (If you do this then D3 (and D1 set above) are used to drive the PWM drive device). Currently the code assumes use of a NodeMCU motor board, but there is an option to use other drivers.  +
- +
-Other pins are then "used up" by the various audio output options.  +
-The Table below refers to the ESP8266 NodeMCU "D" pin numbering.  +
- +
-{{:users:dagnall53:node_options3.jpg?1000}} +
- +
-User : Port is available for user to specify as Input or Output. +
-  * Port D4 is used for the onboad LED.  +
-  * with "AudioNoDAC", port D4 is LRC (set as output with LRC square wave sent by DAC) , but it can be reused (but is complicated)  +
- +
-Port usage shown above is considered "standard", but all port numbers/use can be modified in the code "directives.h" file if required. +
- +
- +
-(Some additional #defines are set or ignored depending on the defines noted above) +
-e.g: +
- +
-  #ifdef _LOCO_SERVO_Driven_Port +
-   #define BACKLight 2  // NodeMCU D2 +
-   #define FRONTLight 5 // NodeMCU D5 +
-   //  #define SteamOutputPin 6 +
-  #endif+
  
 ---- ----
 +The code now has a simple method to allow changing the WiFi SSID,Password etc. 
 +When the code starts up, it waits for about three seconds and looks at the Serial Input and at the boot/Flash pin\\. 
 +IF the program sees "xxx{cr}" OR you press the Boot/Flash pin, it will enter a dialog with the user that allows the Wifi SSID, password and MQTT address to be changed.\\
 + 
 +If you are using the Arduino Serial Monitor, you need to enter "xxx" in the send box, and make sure that the line end is set to Carriage return or LineFeed. It can be simpler to use PuTTY, as I have made the code send ^E, which allows PuTTY to send back the "xxx^m" automatically to start the serial interaction.\\In my setup, starting PuTTY with an ESP32 node connected seems to always immediately reset the node, enter the setup dialog. The ESP8266 needs to be reset manually to achieve the same objective.\\ If you have a Flash/Boot button, like the NodeMCU boards, this is a simpler way to enter the dialog. 
  
-===== First Time Programming =====+{{:users:dagnall53:putty.jpg?400|}}\\ 
 +Note how the port tests for I2C ports as it wakes up, and here sees #61, so will set the (second) display settings on.\\ (#60 is always display 1, #61 is always display 2)    
 +To do this PuTTY must be set up like this (but select the correct Com port for your system!) :\\  
 +{{:users:dagnall53:puttysetup.jpg?400|}}
  
-[[users:dagnall53:node_programming|Programming the Hardware]] +If the MQTT broker address is incorrect, the code will try to search for brokerBUT this takes quite a long time as it takes 15 seconds for each address to be "searched". This is limitation of some of the libraries and I cannot overcome this- But it does mean that -eventually- your node should find the broker even if it has moved address.
-===== Setting the Router SSID and Password using the Serial interface ===== +
- +
----- +
-The code now has simple method to allow changing the WiFi SSID and Password.  +
-When the code starts up, it waits for about three seconds and looks at the Serial Input. IF the program sees "xxx{cr}", it will enter dialog with the user that allows the Wifi SSID, password and MQTT address to be changed +
-If you are using the Arduino Serial Monitor, you need to enter "xxx" in the send box, make sure that the line end is set to Carriage return or LineFeed. +
-When the node starts up you should see something like this:+