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 revision Previous revision
Next revision
Previous revision
users:dagnall53:description [2019/02/14 12:51]
dagnall53 [First Time Programming]
users:dagnall53:description [2019/02/22 18:38] (current)
dagnall53 [WiRocs DESCRIPTION]
Line 1: Line 1:
 ====== WiRocs DESCRIPTION ====== ====== WiRocs DESCRIPTION ======
  
-**'​WiRocS' ​ a new name for '​ESPMQTTRocNetSound'​ shorter name, more capability and ESP32 compatibility**+**'​WiRocS' ​ a new name for '​ESPMQTTRocNetSound'​-- A 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:​Node_Setup|Node_Setup]] 
 +  * [[:​users:​Dagnall53:​OLED |Oled Usage]]  ​
   * [[:​users:​Dagnall53:​Hardware|Hardware]] ​   * [[:​users:​Dagnall53:​Hardware|Hardware]] ​
-  * [[:​users:​Dagnall53:​RocClientThrottle|RocClientThrottle]] 
   * [[:​users:​Dagnall53:​Troubleshooting|Troubleshooting]]   * [[:​users:​Dagnall53:​Troubleshooting|Troubleshooting]]
-  * [[https://​github.com/​dagnall53/​ESPMQTTRocnetSound|ESP8266 ​Code]] +  * [[https://​github.com/​dagnall53/​WiRocS|Source ​Code]] 
-  * [[:​users:​Dagnall53:​Node_programming|Node_Programming]] +  * [[:​users:​Dagnall53:​Node_programming|Programming the Hardware (Arduino)]]   ​
  
 +  *  [[:​users:​Dagnall53:​RocClientThrottle|RocClientThrottle]]
 +  *  [[:​users:​Dagnall53:​RocDisplayTop|Roc-Display Lite]]
  
-=====  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|}}+=====  Network overview =====
  
 +{{:​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 29: Line 30:
 ===== 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 ==== ====  "​STANDARD"​ Port usage summary ====
 ---- ----
 +For details see [[users:​dagnall53:​Port_Setup|Port Setup]] and [[users:​dagnall53:​esp32differences|ESP32 setup]]
  
-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. ​ 
  
-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).+---- 
 +======Sound======
  
-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.  +==Loco Sounds== 
-The Table below refers ​to the ESP8266 NodeMCU ​"D" pin numbering+The code plays synchronised steam chuffs sounds in speed with the loco speed
 +The data directory also contains Eight sound effects ("​F1.wav ​to F8.wav"that can be played by pressing the loco '​F'​ buttons.
  
-{{:​users:​dagnall53:​node_options3.jpg?1000}}+==Station Sounds== 
 +You can access the F1- F8 sound effects via an interface with "​Bus"​=RocNodeID Address=100 - address= 109 Address 101 plays sound "F1.wav"​. ​    
  
-User Port is available for user to specify as Input or Output. +For more details see [[:users:​Dagnall53:​Sound_System|The Sound System]] ​ 
-  * 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) +==== OLED Display ==== 
-e.g:+The WiRocS code can interface with a standard OLED displaySee [[users:dagnall53:​oled|OLED display information]]
  
-  #ifdef _LOCO_SERVO_Driven_Port 
-   #​define BACKLight 2  // NodeMCU D2 
-   #​define FRONTLight 5 // NodeMCU D5 
-   // ​ #define SteamOutputPin 6 
-  #endif 
  
 ---- ----
Line 100: Line 96:
  
 [[users:​dagnall53:​node_programming|Programming the Hardware]] [[users:​dagnall53:​node_programming|Programming the Hardware]]
-===== Setting the Router SSID and Password using the Serial interface =====+===== Setting the Router SSID,  ​Password ​and MQTT Broker Address ​using the Serial interface =====
  
 ---- ----
-The code now has a simple method to allow changing the WiFi SSID and Password.  +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. IF the program sees "​xxx{cr}",​ it will enter a dialog with the user that allows the Wifi SSID, password and MQTT address to be changed.  +When the code starts up, it waits for about three seconds and looks at the Serial Input and at the boot/Flash pin\\ 
-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. +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.\\ 
-When the node starts up you should see something ​like this:+  
 +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.  
 + 
 +{{: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|}} 
 + 
 +If the MQTT broker address is incorrect, the code will try to search for a broker, BUT this takes quite a long time as it takes 15 seconds for each address to be "​searched"​. This is a 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.
  
  
  
users/dagnall53/description.1550145065.txt.gz · Last modified: 2019/02/14 12:51 by dagnall53