Raunak Singh
Published © CC BY-NC

ReFound

A novel idea to efficiently improve the process of retaining lost items in campuses and schools

IntermediateFull instructions provided7 hours346

Things used in this project

Hardware components

Hackster EEDU Kit - Getting started with IoT
DFRobot Hackster EEDU Kit - Getting started with IoT
×1
HUSKYLENS AI Camera
DFRobot HUSKYLENS AI Camera
×1

Software apps and online services

Arduino Web Editor
Arduino Web Editor
Arduino IoT Cloud
Arduino IoT Cloud

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Soldering Iron Holder, With Sponge
Soldering Iron Holder, With Sponge

Story

Read more

Schematics

ReFound Schematic

Code

Main

Arduino
used as sketch for thing in Arduino IoT Cloud
#include "thingProperties.h"
#include "HUSKYLENS.h"
HUSKYLENS huskylens;
//HUSKYLENS green line >> SDA; blue line >> SCL
void printResult(HUSKYLENSResult result);

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  Wire.begin();
  while (!huskylens.begin(Wire))
  {
    Serial.println(F("Begin failed!"));
    Serial.println(F("1.Please recheck the \"Protocol Type\" in HUSKYLENS (General Settings>>Protocol Type>>I2C)"));
    Serial.println(F("2.Please recheck the connection."));
    delay(100);
  }
  pinMode(D6, OUTPUT);
}

void loop() {
  ArduinoCloud.update();
  // Your code here
  if (!huskylens.request()) Serial.println(F("Fail to request data from HUSKYLENS, recheck the connection!"));
  else if (!huskylens.isLearned()) Serial.println(F("Nothing learned, press learn button on HUSKYLENS to learn one!"));
  else if (!huskylens.available()) Serial.println(F("No block or arrow appears on the screen!"));
  else
  {
    // Serial.println(F("###########"));
    while (huskylens.available())
    {
      HUSKYLENSResult result = huskylens.read();
      printResult(result);
    }
  }
}

void printResult(HUSKYLENSResult result) {
  if (result.command == COMMAND_RETURN_BLOCK) {
    object_ID = result.ID;
    if (object_ID == 2) {
      message = "mobile phone";
    } else if (object_ID == 1) {
      message = "water bottle";
    } else if (object_ID == 3) {
      message = "bracelet";
    } else if (object_ID == 4) {
      message = "jewel";
    } else if (object_ID == 5) {
      message = "mouse";
    } else {
      message = "pencil case";
    }
  }
}

/*
  Since ObjectID is READ_WRITE variable, onObjectIDChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onObjectIDChange()  {
  // Add your code here to act upon ObjectID change
}

/*
  Since ObjectType is READ_WRITE variable, onObjectTypeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onObjectTypeChange()  {
  // Add your code here to act upon ObjectType change
}

/*
  Since Message is READ_WRITE variable, onMessageChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onMessageChange()  {
  // Add your code here to act upon Message change
}

Credits

Raunak Singh

Raunak Singh

8 projects • 43 followers
I have a passion for tinkering, coding, and hardware. OPEN-SOURCE Rules!!!

Comments