Quick Start of WiFi for Pico

Asset ‘WiFi for Pico’ is an interface asset between a single Windows PC and plural Pico Ws via WiFi using MQTT communication.

A Unity 3D object ‘ vase’ in the Demo scene moves using the generated data in Pico W. The Pico W generates 3D Object position data ‘x, y, z’. The Pico W sends that data from the Pico W to Unity through Windows PC via WiFi using MQTT communication.

When clicking a Unity 3D object ‘Button’ in the Demo scene, Unity sends the numerical data obtained from the Unity 3D object ‘Inputfield’ and Dropdown to the Pico W. Unity works at Windows PC and sends the numerical data to the Pico W using MQTT communication.

The following shows this asset function structure. Workflow is as follows.

  1. Unity with this asset on the Windows PC inputs moving data as Subscriber from Unity topic.
  2. This asset on the Pico W outputs moving data as Publisher to Unity topic.
  3. Unity with this asset on the Windows PC outputs command data as Publisher to Pico W topic.
  4. This asset on the Pico W inputs command data as Subscriber from Pico W topic.
  5. Moving data is for Horizontal or Vertical movement depending on Pico W No.
  6. Command data is for Pico W No and two input field data.

The following shows the capture screen when the Demo scene runs.


This Quick Start explains how to display the Demo scene on Unity using this asset. This Quick Start also includes some steps for downloading and setting up a package in Unity Project, and writing the Pico W code.

Step-1 Download and set up a package in Unity Project
Step-2 Write Pico W code using Arduino IDE
Step-3 Run Demo scene

Step-1 Download and set up a package in Unity Project

  1. Download this asset from the Asset Store, and click on the Import button.
  2. The package is imported under the Assets folder in your Unity project.
  3. Click the Project tab, choose ‘Assets’ > ‘PicoWiFiInterface’ > ‘Scenes’ folder of the left side menu, double click on the Demo scene ‘PicoWiFiSampleScene’ in the Project window.
  4. Set Windows PC IP address into label ’pc_ip_addr’ of ‘Scripts/PicoWiFiSampleCode’ as follows.
  5.    …
    
    public string PC_IP_Addr ;
    
    private string pc_ip_addr ="192.168.10.105";
    private PicoWiFiLib m_PicoWiFiLib;
    
       …
    

Step-2 Write Pico W code using Arduino IDE

  1. Connect the Pico W by Micro USB cable to Windows PC, then build a software development environment for this asset with the Arduino IDE according to ‘Arduino IDE v2 for Pico/Pico W’.
  2. Obtain Pico W code ‘picowifi.ino’ of the folder ‘/Assets / PicoWiFiInterface/ picowifi’and modify the code for adapting your network environment as follows.
    • ‘ssid’: ssid for your WiFi
    • ‘password’: password for your WiFi
    • ‘mqtt_server’: Windows PC IP address
       …
    
    const char* ssid = "xxxxxxxx";
    const char* password = "xxxxxxxx";
    const char* mqtt_server = "xxx.xxx.xxxx.xxx";
    
       …
    
  3. Compile and write the modified Pico W code ‘picowifi.ino’ into the Pico W using the Arduino IDE.

Step-3 Run Demo scene

  1. Click the ‘Play’ button on Unity. The Unity 3D object ‘vase’ moves in sync with the received data from the Pico W. The ‘Accelx, Accely, Accelz’ in the ‘Scripts/PicoWiFiSampleCode’ of the ‘Inspector’ tab displays the received data ‘x, y, z’ from the Pico W as follows.
  2. The ’console’ tab displays the game status as follows.
  3. The ‘Serial Monitor’ of Arduino IDE displays the data “x, y, z” as follows.
  4. Select Dropdown and set No0 / No1 into Inputfield ’No0’ / Inputfield ‘No1’ in the game screen, then click the Button ‘On’ to send to the Pico W. Show Dropdown / Inputfield ’No0’ / Inputfield ‘No1’ as follows.
  5. In the case of the PicoWiFiSampleCode, the Dropdown displays ‘1’ or ’2’ for selecting Pico W No.1 or No.2. When selecting ‘1’, the Unity 3D object ‘ vase’ moves horizontally. When select ’2’, the ‘ vase’ moves vertically.
  6. The ’console’ tab displays the game status at clicking Button ‘On’ as follows.
  7. The ‘Serial Monitor’ in Arduino IDE displays the No0/No1 data as follows.