====== IP switch 0.4c ======
Previous version 0.2 [[https://remoteqth.com/wiki/index.php?page=IP+Switch+with+ESP32-GATEWAY|here]]
{{https://remoteqth.com/img/slide-ip-sw-rev4-01.jpg?600}}\\
----
{{ https://remoteqth.com/img/wiki-ip-switch-04c.png?350}}
===== Key features =====
* **16** ethernet controlled outputs with optional expandable board
* Based on Olimex [[https://www.olimex.com/Products/IoT/ESP32/ESP32-GATEWAY/open-source-hardware|ESP32-GATEWAY rev.F or later]] ethernet module
* Configure open emitter or open colector outputs
* Simple "Wago" like terminal output connection
* **12-14V power** (step down included)
* Optional color ** [[https://www.olimex.com/Products/Modules/LCD/MOD-LCD2-8RTP/open-source-hardware|LCD display]]** with touch screen support - not implemented
* Connect optional **relay board** with one flat cable
* Analog input optional connector
* **DIN rail** mount
----
===== Hardware =====
{{https://remoteqth.com/img/wiki-ip-sw-rev4-03.png}}\\
- **Power** supply (**12-14V DC**)
- **Ethernet** RJ45 connector on ESP32-GATEWAY (need rev.F or later)
- Optional **expand board** connector
- **Output driver** with open collector or emiter
- **LED light** shown enabled output
- Two **jumper** for select output driver are used
- Connector for **16 relay board** connected wth flat cable
- **16 output** (50V/500mA MAX)
- **COMMON** connect dependency to use driver
- if use **open colector ULN** driver, connect COMMON to relay **+DC power**
- if use **open emiter MIC** driver, connect COMMON to relay **GND**
==== Sources ====
* [[https://remoteqth.com/hw/ip-switch-04c.pdf|.PDF schematics]]
* [[https://remoteqth.com/hw/ip-switch-04c-ibom.html|Interactive BOM]]
* [[https://remoteqth.com/hw/ip-switch-04c.step|.STEP 3D model]]
* [[https://remoteqth.com/hw/ip-sw-04c.zip|.zip KiCad source code]]
----
===== Firmware upload =====
- Install [[https://www.arduino.cc/en/Main/Software|Arduino IDE]]
- Install ESP32 support from [[https://github.com/espressif/arduino-esp32|GitHub]]
- prefered via **[[https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md|board manager]]**
- Download firmware from [[https://github.com/ok1hra/IP_switch|GitGub]]
- Select menu Tools/Board:"OLIMEX ESP32-GATEWAY"
- Select menu Tools/Board revision:"Revision F"
- Connect micro USB between ESP32-GATEWAY and PC
- Select menu Tools/Port/YOUR-CONNECTED-PORT
- Upload firmware
- After firmware upload you can upload next version of the firmware via IP, if you computer in same network. In Arduino IDE shows another choice Network ports \\ {{https://remoteqth.com/img/3d-wx-station-10.png?200}}
- password for OTA upload is //remoteqth//
----
===== Configure CLI =====
==== First step need get IP addres and telnet acces key ====
- After first upload firmware via USB, open serial monitor in Arduino IDE (Ctrl+Shift+M) and set
- baudrate to 115200
- No Line ending
- write **?** and press enter show settings Command line interface \\ {{https://remoteqth.com/img/3d-wx-station-07.png?200}} \\
- copy and save
- IP address
- Key for telnet access (100 characters)
==== Second step connect remotely via IP ====
* Download and install [[https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html|PuTTY]]
* In menu Terminal preset CR/LF and line discipline by picture \\ {{https://remoteqth.com/img/wiki-ip-switch-esp32gateway-22.png?200}} \\
* In main menu Session select or set the following values \\ {{https://remoteqth.com/img/wiki-ip-switch-esp32gateway-23.png?200}} \\
* select **Telnet**
* port **23**
* write **IP address** (saved from first step acces)
* Sessions may be saved for next time
* for connect press **Open**
* Login confirm with press y
* Now answer four times the question of what character is on random selected position, **in your key** (key saved from first step acces). Key formated in groups of ten - FOR EXAMPLEPosition KEY
1-10 pP75tf8qrF
11-20 y4SK57dpnC
21-30 fpag8x9eZ4
31-40 IsueSv4jCY
41-50 pX3lpK4UPD
51-60 ij1bbLEQRu
61-70 XRr9dfoJje
71-80 44u5MYQdcm
81-90 B68NpG7F0t
91-100 5mD04pAE6s
* if you **enter wrong three times,** login will be **blocked for next ten minutes**
* After login your IP address store to EEPROM and next key will be required **only if change your IP** address
* Now logged in to CLI (command line interface) via telnet \\ {{https://remoteqth.com/img/wiki-ip-switch-esp32gateway-25.png?200}}
* for **Logout** press **q** \\
==== CLI commands ====
CLI contains some commands for set or show information. \\
**Commands for set source device** \\
* **m** - Manual IP switch <- THIS USED
* r - Band decoder MK2
* o - Open Interface III
**Other commands,** UPERCASE is important \\
* **?** - show status and help
* **w** - set inactivity time in minutes, after them IP switch will be restarted (watchdog)
* before reboot store current output setting and restore after start
* zero value disable this watchdog
* **W** - set inactivity time in minutes, after them IP switch will set all outputs to OFF
* if you need OFF all outputs after reboot watchdog, set smaller value than it
* zero value disable this watchdog
* **/** - set ENCODER RANGE (2-g) for switching one from range
* **%** - enable/disable group buttons
* **!** - set group for each button separately
* **:** - List group buttons
* in one group may be activate only one output
* groups are free configurable
* the group can be any size 2-8 buttons
* there may be any buttons in the group, for example 1 and 8
* the number of groups is not limited
* ** * ** - enable/disable serial debugging
* **+** - select get Network ID sufix from eeprom or hardware BCD switch
* **#** - set NETWORK ID
* **Prefix** (four high bit) in hexadecimal format (0-f)
* in standart mode prefix expanded range of network ID
* if enable Multi control, prefix disable, and use only on master device for his idetifications
* **Sufix** (four low bit) in hexadecimal format (0-f)
* settings available if sufix get from eeprom
* in standart mode sufix use for identification
* in Multi control mode define group ID (id for all shared devices)
* **$** - enable/DISABLE MULTI CONTROL function (sharing up to 16 master device)
* **&** - send broadcast packet for find control devices in local network
* **.** - if enable Multi control, show list detected IP switch by ID prefix
* **@** - restart IP switch
----
==== For controlled from Manual IP switch ====
- Upload firmware by previous steps
- Set encoder range via CLI with command **n**
- Set source via CLI or web interface to **m**
- Set network ID prefix same on both devices via CLI in range **0-7**
- Select Network ID sufix same on both devices via CLI in range ID **0-7**
- Connect to same local network with DHCP as **Manual IP switch**
- After power up both devices, is automaticaly **pair**
==== Web status page ====
**How IP addres got the device from the DHCP server?**\\
* show in serial terminal after reboot, or send ? character
* or find some [[https://play.google.com/store/apps/details?id=com.overlook.android.fing&hl=en_GB|network scanner]]
**Show all outputs status**\\
- \\ {{https://remoteqth.com/img/wiki-ip-switch-esp32gateway-19.png}}
- Parameter of WiFi or ethrnet IP connect
- Firmware version
- Device uptime
- How source controled his
- Notice - show this page can extend reaction latency IP switch
----
==== Strong secure remote manage ====
Configuration available via serial CLI (command line interface). This interface can be safely accessed to the Internet and encrypted connections to manage all features \\
{{https://remoteqth.com/img/wiki-ip-sw-rev4-02.png?1000}}\\
What you need
* any version Raspberry PI
* microSD card with [[https://www.raspberrypi.org/downloads/raspbian/|Raspbian Lite]]
* micro USB cable
* 5V power adapter with micro usb cable
* ethernet connection
* for first start HDMI monitor and USB keyboard
How to start
* after first boot login to serial console with default login **pi** and password **raspberry**
* run command and **enable [[https://www.raspberrypi.org/documentation/remote-access/ssh/|SSH]]** sudo raspi-config
* run command and write down the shown **IP address** ip a
* you can disconnect HDMI monitor and USB keyboard
* connect to Raspberry PI from any other PC
* [[https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md|windows]]
* [[https://www.raspberrypi.org/documentation/remote-access/ssh/unix.md|Linux]]
* [[https://www.raspberrypi.org/documentation/remote-access/ssh/ios.md|iOS]]
* update system with run command sudo apt-get update && sudo apt-get upgrade
* install screen fith command sudo apt-get install screen
* run **screen** screen /dev/ttyUSB0 115200
* now after pres **?** key show status information and you can **configure via CLI** \\ {{https://remoteqth.com/img/wiki-ip-sw-rev4-16.png?200}}\\
* close screen with **CTRL+A K** and confirm **y**
* disconnect from Raspberry PI use command exit
----
===== How to assembly =====
{{https://remoteqth.com/img/wiki-ip-sw-rev4-04.jpg?1000}}\\
** What tools do you need to build**
* Tin
* Solder
* Pliers
* Splitters
* + 2,5mm imbus (packed in KIT)
==== Steps of assembly ====
- Check all parts{{https://remoteqth.com/img/wiki-ip-sw-rev4-05.jpg?1000}} \\ \\
- Open [[https://remoteqth.com/hw/ip-switch-04c-ibom.html|Interactive BOM]] for find components \\ and solder **U5 U6** DIP-18 socket with key to right{{https://remoteqth.com/img/wiki-ip-sw-rev4-06.jpg?1000}} \\ \\
- Solder pinsocket **P17** to front side and pinheader **P4 P14 P22**{{https://remoteqth.com/img/wiki-ip-sw-rev4-07.jpg?1000}} \\ \\
- Solder **20pin header** to Olimex ESP32-GATEWAY front side{{https://remoteqth.com/img/wiki-ip-sw-rev4-08.jpg?1000}} \\ \\
- Solder output terminal **P6 P10 P11 P3**{{https://remoteqth.com/img/wiki-ip-sw-rev4-09.jpg?1000}} \\ \\
- Solder **P2** input terminal \\ {{https://remoteqth.com/img/wiki-ip-sw-rev4-10.jpg?600}} \\ \\
- Screw two **M3x12mm spacers** with lock nuts{{https://remoteqth.com/img/wiki-ip-sw-rev4-11.jpg?1000}} \\ \\
- Insert **four lock nuts, and two slim nuts** to 3D printed DIN rail mount{{https://remoteqth.com/img/wiki-ip-sw-rev4-12.jpg?1000}} \\ \\
- Screw with **four screws M3x10mm** {{https://remoteqth.com/img/wiki-ip-sw-rev4-13.jpg?1000}} \\ \\
- Plug **ESP32-GATEWAY** to main board and screw with two screws M3x4mm{{https://remoteqth.com/img/wiki-ip-sw-rev4-14.jpg?1000}} \\ \\
- Insert **two output drivers** and plug **two jumpers** in position dependency to used driver. Horizontal for ULN open colector, vertical for MIC open emiter{{https://remoteqth.com/img/wiki-ip-sw-rev4-15.jpg?1000}} \\ \\