Wireless Control and Communication

Last revision 2026/08/03

Preparation

Taking UNIHIKER K10 as an example, this method only supports platforms equipped with an ESP32 main controller.

Connect HUSKYLENS 2 to a WiFi network. After the connection is successful, the current IP address will be displayed on the screen. Please record this IP address.

HUSKYLENS 2 IP

Example Code

Connect UNIHIKER K10 to the same WiFi network as HUSKYLENS 2. The UNIHIKER K10 can then wirelessly initialize and control HUSKYLENS 2, as well as retrieve its recognition data.

Mind+ Graphical Programming

  • In Extension - Board, select and load the UNIHIKER K10 board.

Extension - Board

  • In Extension - Module, select and load HUSKYLENS 2.

Extension - Module

  • Example Code

HUSKYLENS 2 Wireless Control and Communication Example Code

Arduino C Programming

  • Download the library file: DFRobot_HuskylensV2_MQTT.This library requires ArduinoJson v5.13.5 for compatibility.

  • Example Code

#include <DFRobot_HuskylensV2_MQTT.h>
#include <WiFi.h>

const char *ssid = "********";
const char *pass = "********";
const char *huskylens_ip = "192.168.9.185";

HuskylensV2_MQTT huskylens;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  huskylens.begin(huskylens_ip, 1883, "huskylens", "dfrobot");
  huskylens.switchAlgorithm(ALGORITHM_HAND_RECOGNITION);
  delay(5000);
}
void loop() {
  while (!huskylens.getResult(ALGORITHM_HAND_RECOGNITION)) {
    delay(100);
  }

  while (huskylens.available(ALGORITHM_HAND_RECOGNITION)) {
    HandResult *result = static_cast<HandResult *>(
    huskylens.popCachedResult(ALGORITHM_HAND_RECOGNITION));

    Serial.print("result->ID=");
    Serial.println(result->ID);
    Serial.print("result->xCenter=");
    Serial.println(result->xCenter);
    Serial.print("result->yCenter=");
    Serial.println(result->yCenter);
    Serial.print("result->width=");
    Serial.println(result->width);
    Serial.print("result->height=");
    Serial.println(result->height);
    Serial.print("result->name=");
    Serial.println(result->name);
    Serial.println("-----");
  }
}

More Applications

For more features (such as Wireless Video Streaming and MCP Service), please click the corresponding tutorial links for detailed instructions.

Was this article helpful?

TOP