Simple Test program using Husky V2
williampretty 2026-04-16 06:47:53 293 Views3 Replies I found the following simple program. All it is supposed to do is send the target coordinates to the serial monitor.
The protocol is set to I2C and the blue LED is on indication I2C.
To the best of my knowledge I am using the latest version of the HuskyLens V2 library.
The software compiles without any errors.
When I download and run the software it prints “Hello World” on the serial monitor and nothing else.
------------ code -------------
#include "DFRobot_HuskylensV2.h"
#include "Wire.h"
// Create object
HuskylensV2 huskylens;
void setup() {
Serial.begin(9600);
Wire.begin();
Serial.print("Hello World ");
// Wait for connection
while (!huskylens.begin(Wire)) {
Serial.println("Waiting ... ");
Serial.println("Huskylens not found! Check wiring.");
delay(100);
}
Serial.print("Switching to tracking mode");
// Switch to Object Tracking mode
huskylens.switchAlgorithm(ALGORITHM_OBJECT_TRACKING);
}
void loop() {
// Request results from the sensor
huskylens.getResult(ALGORITHM_OBJECT_TRACKING);
// Check if a target is currently detected
if (huskylens.available(ALGORITHM_OBJECT_TRACKING)) {
// Get the object closest to the center crosshair
auto target = huskylens.getCachedCenterResult(ALGORITHM_OBJECT_TRACKING);
Serial.print("Target ID: ");
Serial.println(RET_ITEM_NUM(target, Result, ID));
Serial.print("Position (X, Y): ");
Serial.print(RET_ITEM_NUM(target, Result, xCenter));
Serial.print(", ");
Serial.println(RET_ITEM_NUM(target, Result, yCenter));
Serial.print("Size (W x H): ");
Serial.print(RET_ITEM_NUM(target, Result, width));
Serial.print("x");
Serial.println(RET_ITEM_NUM(target, Result, height));
}
delay(500);
}

Hello, I used the code above on my UNIHIKER K10, and it worked perfectly.
Could you tell me the firmware version of your HUSKYLENS and which dev board you're using?
Yeez_B Hello Thanks for the reply.
I am using the latest revision of the firmware 1.2.2
My dev board is an Romeo BLE control board from DF Robot (DFR305).
I am using the Arduino IDE to compile and upload the code.
I used the SDA , SDC and GND pins on the I2C interface.
The camera is powered via the USB connector.
Hi
It turns out that newping and the HuskyLens use the same two analog pins A4 and A5.
Someone would have to modify newping so that it does not use A4 and A5.
As it stands you can have either ultrasonic control or video control.

