Skip to content

A10 - Input Devices

Brief


Measure something: add a sensor to a microcontroller board that you have designed and read it.

xxx TODO HERO IMAGE

Group assignment link

Measuure something


For my project I would have to measure the moisture content of soil to determine if the plant needed to be watered or not.

Many different soil moisture sensors are available each with their own output methods, some analog, some digital and some used protocols, like I2C.

I opted for the simple analog soil moisture sensor, since the ESP32 has lots of analog inputs (thanks to the bus matrix).

Electrical setup

I used the node PCB I milled previously since I added dedicated header pins for this sensor.

To get the sensor working we needed 3 connections:

  • Power: 3.3V - 5V (Input to sensor)
  • Ground: MCU reference voltage
  • Signal: Outputs a voltage with a max based on the supply voltage

Since the ESP32 has a max pin voltage of 3.3V, I used that as its supply voltage.

Programming

The ESP32 when used with micropython makes everything super easy to develop with, I adapted the provided examples to read the ADC (analog to digital converter) inbuilt on the ESP32.

xxx TODO: Code

output

The sensor and code above provides an analog output based on how much water surrounds the sensor's 'sensing area'. This video shows the sensor moving up and down in some water and the respective signal changing.

xxx TODO: Vid

FILES

xxx TODO: Download link for sensor code