Introduction: WIFI JOYSTICK

About: PLC, Arduino - Do it yourself project

Today I will share how to make a WIFI JOYSTICK from an ESP8266 and 4 ways industrial joystick. It can be integrated into the factory's automation system or be used for smart home control. The mentioned control systems are PLCs and the specific case that I am applying is SIEMENS PLC S7-300..... Let's start and firstly please watch the video below:



Firstly, I assembled the circuit following below diagram. It includes MPU-6050 and one RGB LED to display the joystick status.

It looks like that for 1st version:

And then I did another circuit that only includes: NodeMCU, Joystick and Neopixel Ring 16. I removed MPU-6050 and RGB led is replaced by Neopixel Ring 16. NodeMCU pins were also changed for easy soldering:


  • Connecting 4 NO contacts and Vcc from Joystick to 5P header wire.

  • Making an acrylic sheet in round shape, drilling a hole with diameter 32mm and glued this round plate to top of acrylic tube

  • Installing Joystick and Neopixel Ring

  • Making one more round acrylic sheet at the bottom of acrylic tube then install NodeMCU circuit on it.

  • Installing DC jack and make some decorations.

  • Test the Joystick with Neopixel Ring:


For the PLC hardware configuration, please check at my topic:


To test the WIFI JOYSTICK, I did wiring to 4 relays as explanation below:

Picture after connected:


I. NODEMCU program:

WIFI JOYSTICK code is posted at my GitHub: https://github.com/tuenhidiy/WIFI_JOYSTICK

In the NODEMCU program, two data arrays are created for communicating:

byte WritetoPLC[64]={0};      // Data Array to be written to PLC

byte ReadfromPLC[64]={0};     // Data Array to be read from PLC

    After communication between NodeMCU and PLC are established, NodeMCU will read joystick commands, stored them in "WritetoPLC" array:

    // Read Joystick
       if (digitalRead(UP) == 1)
          WritetoPLC[0] = 1;  // UP position is stored in WritetoPLC Array and written to PLC at DB1.DBX0.0
      else if (digitalRead(DOWN) == 1)
          WritetoPLC[0] = 2;  // DOWN position is stored in WritetoPLC Array and written to PLC at DB1.DBX0.1 
      else if (digitalRead(LEFT) == 1)
          WritetoPLC[0] = 4;  // LEFT position is stored in WritetoPLC Array and written to PLC at DB1.DBX0.2 
      else if (digitalRead(RIGHT) == 1)
          WritetoPLC[0] = 8;  // RIGHT position is stored in WritetoPLC Array and written to PLC at DB1.DBX0.3
          WritetoPLC[0] = 0;  // Joystick ZERO position   

    Then this "WritetoPLC" array is written to PLC at "DB1, Byte 0". See PLC program below.

      // Write commands from WIFI JOYSTICK to "DB1 - Byte 0" of PLC
      // And PLC will carry out the commands as follows
      // UP      -    DB1.DBX0.0  - CONTROL RELAY 0 AT PLC OUTPUT Q124.0
      // DOWN    -    DB1.DBX0.1  - CONTROL RELAY 1 AT PLC OUTPUT Q124.1
      // RIGHT   -    DB1.DBX0.2  - CONTROL RELAY 2 AT PLC OUTPUT Q124.2
      // LEFT    -    DB1.DBX0.3  - CONTROL RELAY 3 AT PLC OUTPUT Q124.3  
    Client.WriteArea( S7AreaDB,       // We are requesting DB access
                        DBNum,          // DB Number - DB1
                        0,              // Start from byte N.0
                        Size,           // We need "Size" bytes - Size = 1
                        &WritetoPLC);   // Put them into our target (Buffer or PDU)

    PLC will carry out the commands by controlling 4 relays (ON/OFF). Then relays will feedback the statuses of coil to PLC inputs. And these statuses are stored in "DB1, Byte 1". See PLC program below.

    Finally, NodeMCU read the feedback signal from PLC ("DB1, Byte 1") and light up the Neopixel Ring corresponding to the joystick postion. It's like confirming that the commands from the joystick has been properly executed by PLC.

      // Read the feedback signals from "DB1 - Byte 1" of PLC 
      // The feedback signals are Normal Open (NO) aux. contact from RELAYS and they are connected to PLC INPUTS as follows
      // FEEDBACK UP POSTION      - PLC INPUT I124.0  -    DB1.DBX1.0
      // FEEDBACK DOWN POSTION    - PLC INPUT I124.1  -    DB1.DBX1.1
      // FEEDBACK RIGHT POSTION   - PLC INPUT I124.2  -    DB1.DBX1.2
      // FEEDBACK LEFT POSTION    - PLC INPUT I124.3  -    DB1.DBX1.3
      Result=Client.ReadArea(S7AreaDB, // We are requesting DB access
                             DBNum,    // DB Number
                             1,        // Start from byte N.1
                             Size,     // We need "Size" bytes
                             &ReadfromPLC);  // Put them into our target (Buffer or PDU)

    II. PLC program:

    Step 6: FINISH

    With this WIFI JOYSTICK, we can customize it to become a tool for the project's cold test, hot test, or control the equipment at home.

    Thank for your reading.

    Be the First to Share


      • Battery Powered Contest

        Battery Powered Contest
      • Plywood Challenge

        Plywood Challenge
      • Plastic Contest

        Plastic Contest