Smart Plant Care using the VSD_Squadron-MINI-BOARD

Introduction

The “Smart Plant Care” project is an innovative IoT solution aimed at optimizing plant growth by monitoring essential environmental parameters. By leveraging advanced sensors and microcontrollers, our system measures the moisture content of the soil, temperature, and humidity. This information is crucial for maintaining optimal plant health and growth. The project addresses the increasing need for efficient plant care in both residential and agricultural settings, ensuring that plants receive the right amount of water at the right time.

Overview

The Smart Plant Care system operates through a network of interconnected components that work together to provide real-time monitoring and automated watering solutions. The user can remotely monitor the plant’s environment and adjust the soil moisture threshold via a WiFi-connected interface. When the soil moisture level falls below the set threshold, the system automatically activates a water pump to deliver the necessary amount of water to the plant. This process helps in conserving water and ensuring that the plant remains healthy.

User Flow

  1. Data Collection: Sensors measure soil moisture levels, temperature, and humidity.
  2. Data Transmission: The CH32V003F4U6 microcontroller collects data from the sensors and sends it to the ESP-01S ESP8266 WiFi Module.
  3. Remote Monitoring: The ESP8266 transmits the data over WiFi, allowing the user to monitor real-time conditions through a web interface.
  4. Threshold Setting: Users can set and adjust the soil moisture threshold via the web interface.
  5. Automated Watering: When soil moisture falls below the threshold, the system activates the water pump to irrigate the plant.

How It Works

  1. Sensor Data Acquisition:
    • The soil moisture sensor checks the soil’s moisture level.
    • The DHT11 sensor measures ambient temperature and humidity.
  2. Data Processing:
    • The CH32V003F4U6 microcontroller processes the sensor data and determines if the soil moisture is below the user-defined threshold.
    • It also monitors temperature and humidity data.
  3. Data Transmission:
    • Processed data is sent to the ESP-01S ESP8266 WiFi module, which transmits it to the user’s web interface for real-time monitoring.
  4. Automated Response:
    • If the soil moisture is below the threshold, the microcontroller activates the water pump through a switch to irrigate the plant.
  5. User Interaction:
    • The user can monitor real-time data, set moisture thresholds, and control the watering system remotely via the web interface.

Components Required

  • CH32V003F4U6 Microcontroller: Acts as the central processing unit, managing sensor data and system operations.
  • ESP-01S ESP8266 WiFi Module: Facilitates wireless communication, allowing remote data monitoring and control.
  • Soil Moisture Sensor Module: Detects the moisture content in the soil.
  • DHT11 Humidity and Temperature Sensor: Measures ambient temperature and humidity.
  • Water Pump: Provides irrigation to the plant when needed.
  • Relay Module: Helps to control high-power pump with low-power signals.
  • Switch: Manages the on/off states of the water pump.

This project aims to create a reliable and efficient system for plant care, suitable for both residential and agricultural use. By leveraging IoT technology, Smart Plant Care ensures plants receive the optimal amount of water and thrive in their environment.

Circuit Connection Diagram

Table For Pin Configuration

For Soil Moisture senosor

Soil Moisture sensorVSDsquadron
VCC3.3V
GNDGND
SIGPA2

For Relay module

RelayVSDsquadronexternal batteryMotor
VCC3.3V
GNDGND
INPC0
common contact9V
Normally Closed
Normally OpenVCC

For ESP 01S 8266 wifi module

ESP 8266VSDsquadron
VCC3.3V
CH_EN3.3V
GNDGND
U0RXDTX(PD5)
U0TXDRX(PD6)

Working Code

Code for VSD squadron mini for getting the moisture content of the soil and communicating with the wifi module

#include <ch32v00x.h>
#include <debug.h>

/* Macros for ADC Pin and Port */
#define ANALOG1_PIN     GPIO_Pin_4
#define ANALOG1_PORT    GPIOD

#define MOTOR_PIN     GPIO_Pin_2
//#define MOTOR_PORT   GPIOD

/* Global Variables */
volatile uint8_t adcFlag = 0;
#define LED_PIN GPIO_Pin_3 // Assuming the LED is connected to GPIO pin 3 (D3 on port D)

/* Function Prototypes */
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void ADC1_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void Delay_Init(void);
void Delay_Ms(uint32_t n);
void ADCConfig(void);
void USARTx_CFG(void);
void USART_SendString(char* str);

void ADCConfig(void) {
    ADC_InitTypeDef ADC_InitStructure = {0};
    GPIO_InitTypeDef GPIO_InitStructure = {0};
    NVIC_InitTypeDef NVIC_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
    RCC_ADCCLKConfig(RCC_PCLK2_Div8);

    GPIO_InitStructure.GPIO_Pin = ANALOG1_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
    GPIO_Init(ANALOG1_PORT, &GPIO_InitStructure);

    ADC_DeInit(ADC1);
    ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
    ADC_InitStructure.ADC_ScanConvMode = DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigInjecConv_None;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfChannel = 1;
    ADC_Init(ADC1, &ADC_InitStructure);

    ADC_InjectedSequencerLengthConfig(ADC1, 1);
    ADC_InjectedChannelConfig(ADC1, ADC_Channel_7, 1, ADC_SampleTime_241Cycles);  // Increased sample time for stability
    ADC_ExternalTrigInjectedConvCmd(ADC1, DISABLE);

    NVIC_InitStructure.NVIC_IRQChannel = ADC_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    ADC_Calibration_Vol(ADC1, ADC_CALVOL_50PERCENT);
    ADC_ITConfig(ADC1, ADC_IT_JEOC, ENABLE);
    ADC_Cmd(ADC1, ENABLE);

    ADC_ResetCalibration(ADC1);
    while (ADC_GetResetCalibrationStatus(ADC1));

    ADC_StartCalibration(ADC1);
    while (ADC_GetCalibrationStatus(ADC1));
}

void USARTx_CFG(void) {
    GPIO_InitTypeDef GPIO_InitStructure = {0};
    USART_InitTypeDef USART_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_USART1, ENABLE);

    /* USART1 TX-->D.5   RX-->D.6 */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOD, &GPIO_InitStructure);

    USART_InitStructure.USART_BaudRate = 115200;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

    USART_Init(USART1, &USART_InitStructure);
    USART_Cmd(USART1, ENABLE);
}

void USART_SendString(char* str) {
    while (*str) {
        USART_SendData(USART1, *str++);
        while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET) {
            /* waiting for sending finish */
        }
    }
}

void ADC1_IRQHandler() {
    if (ADC_GetITStatus(ADC1, ADC_IT_JEOC) == SET) {
        adcFlag = 1;
        ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
    }
}

void LED_Config(void) {
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);

    GPIO_InitStructure.GPIO_Pin = LED_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // Output push-pull
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOD, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = MOTOR_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // Output push-pull
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOD, &GPIO_InitStructure);

}



int main(void) {
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    SystemCoreClockUpdate();
    Delay_Init();
    USART_Printf_Init(115200);
    Delay_Ms(100); // give serial monitor time to open

    USARTx_CFG();
    ADCConfig();
    LED_Config();
    int accumulatedValue   = 0;

    while (1) {
        ADC_SoftwareStartInjectedConvCmd(ADC1, ENABLE);
        uint16_t adcAverage = 0;
        if (adcFlag == 1) {
            static uint32_t adcAccumulated = 0;
            static uint8_t sampleCount = 0;
            const uint8_t maxSamples = 100;
            while(sampleCount <= maxSamples)
            {
                uint16_t adcReading = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_1);

                // Optional: Apply averaging filter to stabilize the readings
                // Adjust number of samples for averaging
                adcAccumulated += adcReading;
                sampleCount++;
            }
            

            if (sampleCount >= maxSamples) {
                adcAverage = adcAccumulated / maxSamples;
                adcAccumulated = 0;
                sampleCount = 0;

                printf("%d\n", adcAverage);
            }

            adcFlag = 0;

            accumulatedValue   = 0;
            int i = 0;
            while(1)
            {
                while (USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET) {
               
                }
                
                char receivedChar = USART_ReceiveData(USART1);
                
                if (receivedChar !='a' ) {
                    
                    accumulatedValue = accumulatedValue * 10 + (receivedChar - '0');
                } else {
                    
                    break;
                }
                i++;
            }
           
            if (accumulatedValue > adcAverage) {   // less water 
                GPIO_SetBits(GPIOD, LED_PIN); // Turn on LED
                GPIO_SetBits(GPIOD, MOTOR_PIN);
            } else {
                GPIO_ResetBits(GPIOD, LED_PIN); // Turn off LED  // water ok 
                GPIO_ResetBits(GPIOD, MOTOR_PIN);
            }
            Delay_Ms(10);
        }
        
        
    }
}

void NMI_Handler(void) {}
void HardFault_Handler(void) {
    while (1) {
    }
}

Code for ESP01-8266 wifi module for coummunation between the VSD squadron mini and the backend server

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>

const char* ssid = "Redmi";
const char* password = "kafil1234";
const char* serverUrlPost = "http://13.234.21.117:8000/api/receive/"; // URL for POST requests
const char* serverUrlGet = "http://13.234.21.117:8000/api/send/"; // URL for GET requests

WiFiClient wifiClient;
HTTPClient http;

unsigned long lastSendTime = 0;
const unsigned long sendInterval = 1000;  // 5 seconds
unsigned long lastGetTime = 0;
const unsigned long getInterval = 1000;   // 5 seconds

void setup() {
  Serial.begin(115200); // Initialize serial communication at 115200 baud rate
  delay(1000); // Small delay to stabilize the Serial connection
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void loop() {
  // Check if there's data available from the Arduino
  if (Serial.available() > 0) {
    String sensorData = Serial.readStringUntil('\n');
    sensorData.trim();

    while (millis() - lastSendTime < sendInterval) {
      delay(10); // small delay to avoid blocking other tasks
    }

    if (millis() - lastSendTime >= sendInterval) {
      if (WiFi.status() == WL_CONNECTED) {
        http.begin(wifiClient, serverUrlPost);
        http.addHeader("Content-Type", "application/json");

        // Create the JSON payload with the received string
        String postData = "{\"sensor_data\": \"" + sensorData + "\"}";

        int httpResponseCode = http.POST(postData);
        if (httpResponseCode > 0) {
          // Successfully sent
        } else {
          // Error on sending POST
        }
        http.end();
      } else {
        WiFi.begin(ssid, password);
        while (WiFi.status() != WL_CONNECTED) {
          delay(500);
        }
      }

      lastSendTime = millis();
    }
  }

  // Periodically send a GET request to the server to check for new data
  if (millis() - lastGetTime >= getInterval) {
    if (WiFi.status() == WL_CONNECTED) {
      http.begin(wifiClient, serverUrlGet);
      int httpResponseCode = http.GET();

      if (httpResponseCode > 0) {
        String response = http.getString();
        StaticJsonDocument<200> doc;
        DeserializationError error = deserializeJson(doc, response);

        if (!error) {
          if (doc.containsKey("value")) {
            int value = doc["value"];
            String output = String(value) + "a";  
            Serial.print(output);
            //delay(10);
          }
        }
      }
      http.end();
    } else {
      WiFi.begin(ssid, password);
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
      }
    }

    lastGetTime = millis();
  }
}

Demo Video

Conclusion

The Smart Plant Care project integrates advanced IoT technology to provide an efficient and automated plant care system. By ensuring that plants receive the optimal amount of water based on real-time environmental data, this system enhances plant health and growth while conserving resources. With remote monitoring and control capabilities, users can manage their plants effortlessly, making Smart Plant Care a valuable tool for both hobbyists and professional growers.

https://github.com/1kushagra2/Newbees

Registration for Ethical RISC-V IoT Workshop

Welcome to Ethical RISC-V IoT Workshop

The “Ethical RISC-V IoT Workshop” at IIIT Bangalore, organized in collaboration with VSD, is a structured, educational competition aimed at exploring real-world challenges in IoT and embedded systems. Participants progress through three stages: building an application, injecting and managing faults, and enhancing application security. The event spans from May 9 to June 15, 2024, culminating in a showcase of top innovations and an award ceremony. This hands-on hackathon emphasizes learning, testing, and securing applications in a collaborative and competitive environment.

Rules :
  1. Only for Indian Student whose college is registered under VTU
  2. Only team of 2 members can Register
  3. Use only VSDSquadron Mini resources for product development
Awards :
  1. Prize money for final 10 Team
  2. 3 Winner team’s Product will be evaluated for Incubation
  3. 7 consolation prizes
  4. Completion Certificate to final round qualifier
  5. Chance to build a Proud Secured RISC-V Platform for India

Date for Registration : 9th May - 22nd May, 2024
Hackathon Inauguration : 23rd May 2024

VSDSquadron (Educational Board)

VSDSquadron, a cutting-edge development board based on the RISC-V architecture that is fully open-source. This board presents an exceptional opportunity for individuals to learn about RISC-V and VLSI chip design utilizing only open-source tools, starting from the RTL and extending all the way to the GDSII. The possibilities for learning and advancement with this technology are limitless.

Furthermore, the RISC-V chips on these boards should be open for VLSI chip design learning, allowing you to explore PNR, standard cells, and layout design. And guess what? vsdsquadron is the perfect solution for all your needs! With its comprehensive documentation and scalable labs, thousands of students can learn and grow together.

VSD HDP (Hardware Design Program) Duration-10 Week

With VSD Hardware Design Program (VSD-HDP),  you have the opportunity to push the boundaries of what exist in open source and establish the new benchmark for tomorrow.

It will leverage your degree in Electrical or Computer Engineering to work with

  • Programmable logic
  • Analog/ digital IP
  • RISC-V
  • Architecture & microprocessors
  • ASICs and SoCs on high-density digital or RF circuit cards
  • Gain hands-on knowledge during design validation and system integration.

Sounds exciting to just get started with expert mentors, doesn’t it? But we are looking for the next generation of learners, inventors, rebels, risk takers, and pioneers.

“Spend your summer working in the future !!”

Outcomes of VSD Online Research IP Design Internship Program

  1. Job opportunities in Semiconductor Industry
  2. Research work can be submitted to VLSI International journals
  3. Participate in Semiconductor International Conference with Internship Research Work
  4. Paper Publications in IEEE Conference and SIG groups
  5. Tape out opportunity and IP Royalty
  6. Interact with world class Semiconductor designer and researchers
  7. Academic professions where more research projects are encouraged.
  8. All the above research and publication work will help colleges and institutes to improve accreditation levels.

Know More Information

VSD – Intelligent Assessment Technology (VSD-IAT)

VSD – Intelligent Assessment Technology (VSD-IAT) is expertly built training platform and is suited for designer requirements. Semiconductor companies understand the value of training automation and Engineer performance enhancement, and do not need to be convinced of the impact of a virtual platform for learning. VSD trainings are quick, relevant, and easy to access from any device at any time zone.

VSD Intern Webinars

VSD Interns made it happen !!

VSD is working towards creating innovative talent pool who are ready to develop design and products for the new tech world. VSD believes in “Learning by doing principle” , and always prepare the student to apply the knowledge learned in the workshops, webinars and courses. We always push our students to work on new designs, test it and work continuously till it becomes the best performing design. Any student who enrolls to VSD community starts working with small design and grows with us and develops a tapeout level design with complete honesty and dedication towards the Work !!

Check out VSD Interns Achievement!

VSDOpen Online Conference

Welcome to the World’s only online conference in Semiconductor Industry VSDOpen Conference. With enormous support and global presence of audience from different segments of industrial lobby and academia made a highly successful event. Evolution is change in the genetic makeup of a population over time, online conference is one kind evaluation everyone adapt soon. 

  • VSDOpen 2022 is an online conference to share open-source research with the community and promote  hardware design mostly done by the student community.
  • VSDOpen 2022 is based on the theme “How to lower the cost to learn, build, and tapeout chips ?”  , which will provide a platform to community to build stronger designs and strengthen the future of Chip design.
  • VSDOpen is envisioned to create a community based revolution in semiconductor hardware technology.
  • The open source attitude is required to bring out the talent and innovation from the community who are in remote part of world and have least access to the technologies.  And now Google support will help to bring the vision to execution by VSD team

VSD Online Course by Kunal Ghosh

VSD offers online course in complete spectrum of vlsi backend flow from RTL design, synthesis and Verification, SoC planning and design, Sign-off analysis, IP Design, CAD/EDA automation and basic UNIX/IT, Introduction to latest technology – RISC-V, Machine intelligence in EDA/CAD, VLSI Interview FAQ’s.

Current Reach – As of 2021, VSD and its partners have released 41 online VLSI courses and was successfully able to teach  ~35900 Unique students around 151 countries in 47 different languages, through its unique info-graphical and technology mediated learning methods.

Enquiry Form