1. Home
  2. Docs
  3. VSDSquadron Mini DataShee...
  4. Projects
  5. Implementing Moisture Sensor using VSDSquadron Mini

Implementing Moisture Sensor using VSDSquadron Mini

1. LED Connection

  • Positive end (Anode) connected to GPIO Pin 6 of VSDSquadron Mini.

2. Moisture Sensor Connection

  • VCC of the moisture sensor to VCC on VSDSquadron Mini.
  • Output to GPIO Pin 0 of VSDSquadron Mini.
  • GND to ground.

1. Environment Setup

  • Install PlatformIO and VS Code for software development and project compilation.

2. Include Necessary Libraries

#include <ch32v00x.h>

#include <debug.h>

3. GPIO Configuration

void GPIO_Config(void) 
{

GPIO_InitTypeDef GPIO_InitStructure = {0};

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);

// Configure LED pin as output

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOD, &GPIO_InitStructure);

// Add more configurations as needed

}

4. Main Logic

int main(void) {

uint8_t moistureStatus = 0;

// System initialization code here

GPIO_Config();

while(1) {

moistureStatus = GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_0);

if(moistureStatus == 0) {

GPIO_WriteBit(GPIOD, GPIO_Pin_6, RESET);

} else {

GPIO_WriteBit(GPIOD, GPIO_Pin_6, SET);

}

}

}

https://drive.google.com/file/d/1gwNAvKH-pGbndcom8Ff31Zt1fW6il_u4/view

https://github.com/madhavasawa/somaiya-riscv/blob/main/README.md