INPUT DEVICES

Measuring and analyzing analog and digital signals from input devices

Project Overview

This week, I worked on probing the analog levels and digital signals of an input device. During the process, I used a multimeter and an oscilloscope to measure and analyze the different signals that the device generates.

Soil moisture sensor

Soil Moisture Sensor

The sensor I chose to work with, which measures plant moisture levels through electrical resistance changes in the soil.

First, I focused on the analog signals, observing how changes in the input affect the output of the device and identifying patterns in the waves that I measured. This helped me understand better how continuous signals behave and their importance in data processing.

Next, I moved on to the digital signals, where I noticed that the variations were more discrete and easier to interpret. I learned to differentiate between high and low levels and how these translate into useful information for the system.

Assignment Checklist

Status Task Evidence
Linked to the group assignment page View
Documented what you learned from interfacing input device(s) View
Documented design and fabrication process View
Explained the programming process View
Explained problems encountered and solutions View
Included original design files and source code View
Included a 'hero shot' of your board View

Circuit Design

Schematic Diagram

Schematic diagram

The circuit uses an ATtiny45 microcontroller, with an LED that lights up via PB0 and a moisture sensor that sends data to PB4. It also includes programming pins and power connections.

ATtiny45 Microcontroller

  • The core of the circuit is an ATtiny45, connected to 5V at the power pin (VCC) and ground (GND)
  • The digital input/output pins are labeled PB0 to PB5
  • In the schematic, PB0, PB1, PB2, and PB3 are being used

Programming Interface

  • The pins MOSI (PB0), MISO (PB1), and SCK (PB2) are connected to a connector (J3)
  • Used to program the ATtiny45 via the SPI protocol
  • The RESET (PB5) pin is also connected to the connector

LED Indicator

  • An LED (D1) is connected to PB0 through a current-limiting resistor (R1)
  • Serves as a visual indicator when the moisture level is low

Moisture Sensor Connection

At the bottom, there is a connector labeled J1 with the following connections:

  • PB4: Pin of the ATtiny45 configured to read data from the moisture sensor
  • PWR_5V: Provides 5V power to the sensor
  • GND: Ground connection

PCB Design

PCB design

Now that we have the circuit ready, we proceeded to cut our PCB using the appropriate tool. The next step was cutting the board using the Roland Monofab. Once cut, I soldered the components in their proper places on the circuit.

Finished PCB

The final result of the PCB assembly process, with the board assembled and ready for testing.

Signal Types Analysis

Analog Input

An analog input can capture a wide range of values within a defined interval. It generally measures continuous signals, such as voltage variations, and is used to read sensors that produce variable data.

  • Measures continuous signals
  • Captures a range of values
  • Used for sensors like temperature, light, or potentiometers
  • Allows for more detailed and complex measurements

Digital Input

A digital input recognizes only two states: high or low, represented by the binary values 1 and 0. It is designed to detect the presence or absence of voltage.

  • Recognizes only two states (high/low)
  • Detects presence or absence of voltage
  • Ideal for simple devices like buttons and switches
  • Provides clear and precise binary readings

Application in Plant Monitoring

For the analog input, a soil moisture sensor was used to capture environmental data. The sensor measures humidity levels, and based on the values received, it triggers an LED. If the sensor detects low humidity, indicating the plant is dry, the LED lights up as a warning signal.

PCB with other components

Programming Process

Code example

With the code completed, I proceeded to make the connections on my Week 4 PCB to supply the necessary voltage. By connecting the corresponding pins, they acted as bridges, ensuring the system worked properly.

The programming involved reading analog values from the moisture sensor and triggering the LED when the moisture level fell below a certain threshold.

Key Code Snippets

1
// Initialize pins
2
void setup() {
3
  pinMode(LED_PIN, OUTPUT); // Set LED pin as output
4
  pinMode(SENSOR_PIN, INPUT); // Set sensor pin as input
5
}
6
7
// Main loop reading sensor
8
void loop() {
9
  int sensorValue = analogRead(SENSOR_PIN);
10
  if (sensorValue < THRESHOLD) {
11
    digitalWrite(LED_PIN, HIGH); // Turn on LED
12
  } else {
13
    digitalWrite(LED_PIN, LOW); // Turn off LED
14
  }
15
  delay(1000); // Wait 1 second between readings
16
}
Code Explanation

This code initializes the LED pin as an output and the sensor pin as an input. In the main loop, it continuously reads the analog value from the moisture sensor. If the reading falls below a predefined threshold (indicating dry soil), it turns on the LED as a warning. Otherwise, the LED remains off.

Testing & Results

Connected PCB

The PCB connected to the moisture sensor and power supply, ready for testing.

Once everything was finished, I tested my input circuit to analyze its operation in detail and observe how the data changes in response to humidity.

Video showing the system in operation, with the LED responding to moisture level changes.

Problems & Solutions

Challenges Faced
  • Initial incorrect sensor readings due to improper voltage levels
  • LED not triggering at the expected moisture threshold
  • Signal noise affecting analog readings
  • Programming interface connection issues
Solutions Implemented
  • Verified and corrected power supply to the sensor
  • Adjusted the threshold value through testing
  • Added a small capacitor to filter noise
  • Double-checked all programming connections
  • Used oscilloscope to verify signal integrity

Final Reflections

As final reflections, this project allowed me to better understand the integration between hardware and software, from creating the PCB to programming it to read sensor data and activate the LED. It was an opportunity to deepen my knowledge of handling analog inputs and the importance of precise design to ensure proper circuit operation.

Key Learnings

  • How analog sensors translate physical properties into electrical signals
  • The importance of proper signal conditioning
  • Programming techniques for reading analog inputs
  • Troubleshooting sensor interfaces
  • Design considerations for reliable input devices

Applications

Testing helped me visualize how environmental conditions affect the readings, reinforcing the usefulness of such systems in monitoring applications. This project could be extended to:

  • Automated plant watering systems
  • Environmental monitoring stations
  • Smart agriculture solutions
  • Home automation projects

Resources & Files