Grove AI vision manual object detection - D0nnaz/DET-IoT GitHub Wiki

In this manual, we will guide you through the process of setting up your Arduino and components to identify plants and determine their health status. A green light will illuminate when the plant is healthy, a red light will indicate a sick plant, and an orange light will signify no plant detected. This functionality is achieved using the Grove - Vision AI Module.

Requirements

Hardware

Accounts

  • Roboflow account (optional)

  • Google Account/ Google drive account

  • OpenWeather account

Bronnen:

Setup your board

  1. Download and install the Arduino IDE if you do not have it installed already.
  2. Go to Preferences > Additional Boards Manager URLs and add the following URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json. You can add multiple URLs by separating them with commas.
  3. Click "OK."
  4. Navigate to the menu Tools > Board > Boards Manager.
  5. Look for "esp8266" by ESP8266 Community in the list.
  6. Click on "Install."
  7. Once the installation is complete, click "OK."

Set up the hardware.

NodeMCU Grove - Vision AI module Ledstrip Moisture Sensor
NodeMCU Source image Grove - Vision AI module Source image Ledstrip Source image Moisture Sensor Source

Set up software

Connect to the right board and port.

Scherm­afbeelding 2023-10-09 om 21 33 32

Create a new sketch and paste the following code:

#include "Seeed_Arduino_GroveAI.h"
#include <Wire.h>

GroveAI ai(Wire);
uint8_t state = 0;

// Define LED strip parameters
#define NUM_LEDS 15
#define DATA_PIN D5
#define CLOCK_PIN 13

CRGB leds[NUM_LEDS];

void setup()
{
  Wire.begin();
  Serial.begin(115200);

  // Initialize AI
if (ai.begin(ALGO_OBJECT_DETECTION, MODEL_EXT_INDEX_1))

  {
    // FastLED setup
    FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
    FastLED.show();

    Serial.println("Version: 0x" + String(ai.version(), HEX));
    Serial.println("ID: 0x" + String(ai.id(), HEX));
    Serial.println("Algo: " + String(ai.algo()));
    Serial.println("Model: " + String(ai.model()));
    Serial.println("Confidence: " + String(ai.confidence()));
    state = 1;
  }
  else
  {
    Serial.println("Algo begin failed.");
  }
}

void loop()
{
  if (state == 1)
  {
    uint32_t tick = millis();
    if (ai.invoke())
    {
      while (1)
      {
        CMD_STATE_T ret = ai.state();
        if (ret == CMD_STATE_IDLE)
        {
          break;
        }
        delay(20);
      }

      uint8_t len = ai.get_result_len();
      if (len)
      {
        int time1 = millis() - tick;
        Serial.print("Time consuming: ");
        Serial.println(time1);
        Serial.print("Happy plants: ");
        Serial.println(len);
        object_detection_t data;

        for (int i = 0; i < len; i++)
        {
          Serial.println("result: detected");
          Serial.print("Detecting and calculating: ");
          Serial.println(i + 1);
          ai.get_result(i, (uint8_t *)&data, sizeof(object_detection_t));

          Serial.print("Confidence: ");
          Serial.print(data.confidence);
          Serial.println();

          fill_solid(leds, NUM_LEDS, CRGB::Green);
          FastLED.show();
        }
      }
      else
      {
        Serial.println("No identification");

        fill_solid(leds, NUM_LEDS, CRGB::Red);
        FastLED.show();
      }
    }
    else
    {
      delay(1000);
      Serial.println("Invoke Failed.");
    }
  }
  else
  {
    state == 0;
  }
}

Before you continue, please download the ZIP library from https://github.com/Seeed-Studio/Seeed_Arduino_GroveAI. Once the download is finished, open the Arduino IDE and follow these steps:

Go to Sketch > Include Library > Add .ZIP Library. Locate the recently downloaded ZIP file and install it in the Arduino IDE.


Insert the USB-C cable into both the Grove - Vision AI and your computer. Press the boot button twice. If everything is done correctly, you will see Grove AI (see image).

Boot button Outcome
image Scherm­afbeelding 2023-10-09 om 21 31 35

Download the following file:

image

Upload the .uf2 file to the AI Grove. If done correctly, the Grove AI will disappear within a few seconds.

Upload the code to your arduino. Open the serial monitor and set baud rate as 115200 and the result of plants detection should be showed continuously. To see the result, go to this site: https://vision-ai-demo.seeed.cn/.

ERROR

Error: If the GroveAI doesn't appear when connecting the USB-C cable initially, try pressing the boot button again twice. If that doesn't resolve the issue, reinsert the cable.

If the camera doesn't display an image, attempt the following steps:

  1. Check the hardware connections.
  2. Press the boot button four times.
  3. Reinsert the cable.
  4. Re-upload the code.
  5. As a last resort, consider restarting your computer.
⚠️ **GitHub.com Fallback** ⚠️