Assignment 13 - Input Devices
Assignments
Individual Assignment
- Measure something: add a sensor to a microcontroller board that you have designed and read it
Group Assignment
- Probe an input device's analog levels and digital signals
Assignment
Group Assignment
The Group Assignment for this Week can be found here.
Individual Assignment
For this week I wanted to try out two types of sensors, as I will be using at least one of them in my final project: A moisture/temperature Sensor and a Soil Moisture Sensor. I started with the Moisture/temperature Sensor. For both Sensors i will use my Big Cat Board from Electronics Design Week, which is equipped with an ATtiny1614 and has two freely usable digital pins, as well as two freely usable PWM and a single DAC pin.
Image of DHT 11
For the DHT-11 I went ahead and installed the DHT Sensor Library by Adafruit. This Library makes it easier to communicate with multiple different kinds of DHT sensors, and important for me, it makes it easier to handle the DHT-11. Connection wise, the Sensor is pretty easy to set up. In my case the sensor itself was mounted on a small PCB, like in the Image above to the left, which meant that I did niot have to pull up the signal line with a sepreate resistor, as this was already happening on the small PCB the sensor was mounted on. I went ahead and plugged in VCC, Ground and the Signal line to the IO port of my Big Cat Board. I then began programming to just pull Information from the sensor and give it out through the serial Monitor. After having a look at the example that comes with the Adafruit Sensor Library, I wrote this code:
#include
#include
int sensor = 3;
DHT dht(sensor, DHT11);
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
Serial.print("Temperature: ");
Serial.print(dht.readTemperature());
Serial.print("°C (");
Serial.print(dht.readTemperature(true));
Serial.print("°F); Humidity: ");
Serial.print(dht.readHumidity());
Serial.println("%");
delay(500);
}
Sadly the outcome here was not really interesting at all, since the DHT-11 can only sense the temperature in full degrees, so no fine measurements are possible. Since I only wanted to test this sensor anyway, I quickly moved to my main focus this week: The soil Moisture sensor. This sensor I definetly need for my final project. I took one from the stock of our Lab. Ahemd already warned me, that these guys we had in stock are really not the greatest. They are quite unreliable and tend to give out wrong readings all the time. I wanted to test the sensor out anyway, so I took it and quickly connected it to my Big Cat Board.
The connection of this sensors goes as follows:
- VCC of Soil Sensor to VCC of Big Cat Board
- GND of Soil Sensor to GND of Big Cat Board
- AOUT of Soil Sensor to ADC PIN of Big Cat Board
Once everything was connected, it looked something like this:
Reading the Values this sensor sends is quite simple. I wrote the follwoing Script:
int input = 2;
int sensorValue;
void setup() {
Serial.begin(115200);
pinMode(input, INPUT);
}
void loop() {
sensorValue = analogRead(input);
Serial.print("Ground Moisture: ");
Serial.println(sensorValue);
delay(200);
}
At the end I also made a video watering the plant. You can see the received value chaning after watering:
At the end I must say, Im really not sure about this sensor, I think I am going to have a look around and try to find other alternatives.
Update
I found an alternative thta also is able to directly communicate over I2C. The Adafruit STEMMA Soil Sensor. I will use it in my final project so you can read what I did with this sensor on the final project page!