GithubHelp home page GithubHelp logo

kanagavel7 / experiment--05-soil-moisture-sensor-interface-to-iot-development-board- Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vasanthkumarch/experiment--05-soil-moisture-sensor-interface-to-iot-development-board-

0.0 0.0 0.0 5 KB

experiment--05-soil-moisture-sensor-interface-to-iot-development-board-'s Introduction

EXPERIMENT--05-SOIL-MOISTURE-SENSOR-INTERFACE-TO-IOT-DEVELOPMENT-BOARD-

Aim: To Interface a Analog Input (soil moisture sensor) to ARM IOT development board and write a program to obtain the data on the com port

Components required: STM32 CUBE IDE, ARM IOT development board, STM programmer tool.

Theory

Hardware Overview

A typical soil moisture sensor consists of two parts.

The Probe The sensor includes a fork-shaped probe with two exposed conductors that is inserted into the soil or wherever the moisture content is to be measured.

As previously stated, it acts as a variable resistor, with resistance varying according to soil moisture. image The Module In addition, the sensor includes an electronic module that connects the probe to the Arduino.

The module generates an output voltage based on the resistance of the probe, which is available at an Analog Output (AO) pin.

The same signal is fed to an LM393 High Precision Comparator, which digitizes it and makes it available at a Digital Output (DO) pin.

image The module includes a potentiometer for adjusting the sensitivity of the digital output (DO).

You can use it to set a threshold, so that when the soil moisture level exceeds the threshold, the module outputs LOW otherwise HIGH.

This setup is very useful for triggering an action when a certain threshold is reached. For example, if the moisture level in the soil exceeds a certain threshold, you can activate a relay to start watering the plant.

Soil Moisture Sensor Pinout The soil moisture sensor is extremely simple to use and only requires four pins to connect.

soil moisture sensor pinout AO (Analog Output) generates analog output voltage proportional to the soil moisture level, so a higher level results in a higher voltage and a lower level results in a lower voltage.

DO (Digital Output) indicates whether the soil moisture level is within the limit. D0 becomes LOW when the moisture level exceeds the threshold value (as set by the potentiometer), and HIGH otherwise.

VCC supplies power to the sensor. It is recommended that the sensor be powered from 3.3V to 5V. Please keep in mind that the analog output will vary depending on the voltage supplied to the sensor.

GND is the ground pin.

image

Procedure:

  1. click on STM 32 CUBE IDE, the following screen will appear image

  2. click on FILE, click on new stm 32 project image image

  3. select the target to be programmed as shown below and click on next

image

4.select the program name image

  1. corresponding ioc file will be generated automatically image

6.select the appropriate pins as gipo, in or out, USART or required options and configure image image

7.click on cntrl+S , automaticall C program will be generated image image 8. edit the program and as per required image

  1. use project and build all image

  2. once the project is bulild image

  3. click on debug option image

  4. connect the iot board to power supply and usb

  5. After connecting open the STM cube programmer image

  6. click on UART and click on connect image

  7. once it is connected , click on Erasing and programming option image

  8. flash the bin or hex file as shown below by switching the switch to flash mode

image

  1. check for execution of the output by switching the board to run mode
  2. open serial port utility and select appropritate com port, run and verify the reuslts of moisture content .

STM 32 CUBE PROGRAM :

#include "main.h"
#include "stdio.h"

#if defined (_ICCARM) || defined (_ARMCC_VERSION)
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#elif defined(_GNUC_)
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#endif

PUTCHAR_PROTOTYPE
{
  HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF);
  return ch;
}

while (1)
  {
	  HAL_ADC_Start(&hadc);
	  		HAL_ADC_PollForConversion(&hadc,100);
	  		adc_val = HAL_ADC_GetValue(&hadc);
	  		uint32_t soilmoisture;
	  		soilmoisture=adc_val/10.24;
	  		HAL_ADC_Stop(&hadc);
	  		HAL_Delay(500);
	  		printf("soilmoisture=:%ld\n",soilmoisture);
	  		if(adc_val<500)
	  		{
	  			 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET);;
	  		}
	  		if(adc_val>500)
	  		{
	  			 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);;
	  		}
  }
}

Output screen shots on serial monitor :

circuit setup:

Screenshot 2024-04-25 140223

sensor monitor output:

Screenshot 2024-04-25 140235

Result :

Interfacing a Analog Input (soil moisture sensor) with ARM microcontroller based IOT development is executed and the results visualized on serial monitor

experiment--05-soil-moisture-sensor-interface-to-iot-development-board-'s People

Contributors

kanagavel7 avatar vasanthkumarch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.