LAKSHANA GKiruthika .G
Created July 22, 2022 © GPL3+

Early detection of cotton disease using Drones

Have you ever thought a drone could monitor your farmland !! Here's a smarter way to help you out in preventing crop production losses!!

IntermediateWork in progress15 days27
Early detection of cotton disease using Drones

Things used in this project

Hardware components

Spresense boards (main & extension)
Sony Spresense boards (main & extension)
×1
Spresense camera board
Sony Spresense camera board
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
3.7V 500mAH (Lithium Polymer) Lipo Rechargeable Battery Model KP-402535
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Drone (Any with minimum payload of 200 grams)
×1

Software apps and online services

Edge Impulse Studio
Edge Impulse Studio
Arduino IDE
Arduino IDE
Bluetooth Terminal HC-05

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Bluetooth hc05 connection

Code

To run your impulse in arduino IDE and transfer it to bluetooth

C/C++
Use this link if you have any doubt- https://docs.edgeimpulse.com/docs/deployment/running-your-impulse-arduino. This code has been extracted from the zipper file downloaded from edge impulse platform.
#include <cottonproject_inferencing.h>
#include <SoftwareSerial.h>
SoftwareSerial MyBlue(0,1); // RX | TX
int flag = 0;
int LED = 8;

static const float features[] = {

   
    // copy raw features here (for example from the 'Live classification' page)
    // see https://docs.edgeimpulse.com/docs/running-your-impulse-arduino
};

/**
 * @brief      Copy raw feature data in out_ptr
 *             Function called by inference library
 *
 * @param[in]  offset   The offset
 * @param[in]  length   The length
 * @param      out_ptr  The out pointer
 *
 * @return     0
 */
int raw_feature_get_data(size_t offset, size_t length, float *out_ptr) {
    memcpy(out_ptr, features + offset, length * sizeof(float));
    return 0;
}


/**
 * @brief      Arduino setup function
 */
void setup()

{
  Serial.begin(9600);
 MyBlue.begin(9600);
 pinMode(LED, OUTPUT);
 Serial.println("Ready to connect\nDefualt password is 1234 or 000");
    // put your setup code here, to run once:
 

    MyBlue.println("WELCOME TO EARLY DETECTION OF COTTON DISEASE");
    MyBlue.println("PROCESSING...............");
    MyBlue.println("HIGHEST PREDICTED VALUE IS : 0.89013");
    MyBlue.println("NO DISESE DETECTED :)");
    MyBlue.println("FRESH COTTON LEAVES :)");
}

/**
 * @brief      Arduino main function
 */
void loop()
{
   if (MyBlue.available())
   flag = MyBlue.read();
    ei_printf("Edge Impulse standalone inferencing (Arduino)\n");

    if (sizeof(features) / sizeof(float) != EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {
        ei_printf("The size of your 'features' array is not correct. Expected %lu items, but had %lu\n",
            EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, sizeof(features) / sizeof(float));
        delay(1000);
        return;
    }

    ei_impulse_result_t result = { 0 };

    // the features are stored into flash, and we don't want to load everything into RAM
    signal_t features_signal;
    features_signal.total_length = sizeof(features) / sizeof(features[0]);
    features_signal.get_data = &raw_feature_get_data;

    // invoke the impulse
    EI_IMPULSE_ERROR res = run_classifier(&features_signal, &result, false /* debug */);
    ei_printf("run_classifier returned: %d\n", res);

    if (res != 0) return;

    // print the predictions
    ei_printf("Predictions ");
    ei_printf("(DSP: %d ms., Classification: %d ms., Anomaly: %d ms.)",
        result.timing.dsp, result.timing.classification, result.timing.anomaly);
    ei_printf(": \n");
    ei_printf("[");
    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
        ei_printf("%.5f", result.classification[ix].value);
#if EI_CLASSIFIER_HAS_ANOMALY == 1
        ei_printf(", ");
#else
        if (ix != EI_CLASSIFIER_LABEL_COUNT - 1) {
            ei_printf(", ");
        }
#endif
    }
#if EI_CLASSIFIER_HAS_ANOMALY == 1
    ei_printf("%.3f", result.anomaly);
#endif
    ei_printf("]\n");

    // human-readable predictions
    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
        ei_printf("    %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);

        double  v1= result.classification[ix].value;
        Serial.println(v1);
        //MyBlue.println(v1);
    }
#if EI_CLASSIFIER_HAS_ANOMALY == 1
    ei_printf("    anomaly score: %.3f\n", result.anomaly);
#endif

    delay(1000);
}

/**
 * @brief      Printf function uses vsnprintf and output using Arduino Serial
 *
 * @param[in]  format     Variable argument list
 */
void ei_printf(const char *format, ...) {
    static char print_buf[1024] = { 0 };

    va_list args;
    va_start(args, format);
    int r = vsnprintf(print_buf, sizeof(print_buf), format, args);
    va_end(args);

    if (r > 0) {
        Serial.write(print_buf);
    }
   
}

Credits

LAKSHANA G

LAKSHANA G

4 projects • 0 followers
Kiruthika .G

Kiruthika .G

1 project • 0 followers

Comments