Input Devices

Assignment to be done:

1.Group Assignment:
.Probe an input device(s)'s analog and digital signals
.Document your work on the group work page and reflect on your individual page what you learned

To be found here

What I learned from interfacing input devices to Microcontroller

There two types of input devices which are analog and digital devices. This means that when you are going to connect these devices on microcontroller first you have to know whether the device is analog or digital sothat you will know on which pin of microcontroller will be connected as microcontroller has both digital and analog pins.

2. Individual Assignment:

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

As individual assignment is to measure something,I measured the moisture content in different materials and displayed its level on OLED.
As I designed an ESP32 microcontroller board previously, I added the moisture sensor on its GPIO12 (pin 23) which is analog pin to read data from the siganal pin of moisture sensor.

Moisture Sensor
The moisture sensor a kind of sensor which used to gauge the volumetric content of water within different materials such as soil, wood, etc.

Design and Fabrication Process
The schematic circuit of designed board:


PCB layout for the development board:

3D view of PCB layout for the development board.

Milling process of the board




connecting input and output files and setting the X,Y,Z origins:

After connecting, upload the designed PCB file by clicking on select svg file, set the dpi you want to operate on(here I chose 1000) and invert the uploaded design to see where the milling machine will trace.

Then down here is the view of the board to be millled

PCB after Milling and cutting

For more about the design and fabrication process of my board, refer to here from what I have designed and produced before

The following image is of the overall of the implemented system




After making sure that it operates as expected, I took different sample of materials where to measure the level of moisture content into them as shown in the following photos:






After measuring the dry soil, I also measure the wet soil that I knew that there is much water into it to see whether the level of moisture changes down, and it decreased as expected.
The image down here shows the measured level:



After, I also took any other sample of material, and measure its moisture content to see if it differ from the previous and got different measurement as shown by the following image:



Below video is of my work uploaded on youtube.




The following are the source codes used:
                    
                        #include< SPI.>
                            #include< Wire.h>
                            #include< Adafruit_GFX.h>
                            #include< Adafruit_SSD1306.h>
                             
                            #define SCREEN_WIDTH 128 // OLED display width, in pixels
                            #define SCREEN_HEIGHT 64 // OLED display height, in pixels
                            #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
                            Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
                             
                            const int AirValue = 3620;   //you need to replace this value with Value_1
                            const int WaterValue = 1680;  //you need to replace this value with Value_2
                            const int SensorPin = 15;
                            int soilMoistureValue = 0;
                            int soilmoisturepercent=0;
                             
                             
                            void setup() {
                              Serial.begin(115200); // open serial port, set the baud rate to 9600 bps
                              display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
                              display.clearDisplay();
                            }
                             
                             
                            void loop() 
                            {
                            soilMoistureValue = analogRead(SensorPin);  //put Sensor insert into soil
                            Serial.println(soilMoistureValue);
                            soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
                            if(soilmoisturepercent > 100)
                            {
                              Serial.println("100 %");
                              
                              display.setCursor(45,0);  //oled display
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Soil");
                              display.setCursor(20,15);  
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Moisture is");
                              
                              display.setCursor(30,40);  //oled display
                              display.setTextSize(3);
                              display.setTextColor(WHITE);
                              display.println("100 %");
                              display.display();
                              
                              delay(250);
                              display.clearDisplay();
                            }
                            else if(soilmoisturepercent <0)
                            {
                              Serial.println("0 %");
                              
                              display.setCursor(45,0);  //oled display
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Soil");
                              display.setCursor(20,15);  
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Moisture is ");
                              
                              display.setCursor(30,40);  //oled display
                              display.setTextSize(3);
                              display.setTextColor(WHITE);
                              display.println("0 %");
                              display.display();
                             
                              delay(250);
                              display.clearDisplay();
                            }
                            else if(soilmoisturepercent >=0 && soilmoisturepercent <= 100)
                            {
                              Serial.print(soilmoisturepercent);
                              Serial.println("%");
                              
                              display.setCursor(45,0);  //oled display
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Soil");
                              display.setCursor(20,15);  
                              display.setTextSize(2);
                              display.setTextColor(WHITE);
                              display.println("Moisture is");
                              
                              display.setCursor(30,40);  //oled display
                              display.setTextSize(3);
                              display.setTextColor(WHITE);
                              display.println(soilmoisturepercent);
                              display.setCursor(70,40);
                              display.setTextSize(3);
                              display.println(" %");
                              display.display();
                             
                              delay(250);
                              display.clearDisplay();
                            }  
                            }
                    
                   

Problems I ecountered and how resolved

As my board consists of a lot of wiring, when connecting the signal pin of the moisture sensor on the input analog of ESP32 and supply it, I didn't get the result, and it wasn't easy to troubleshoot due to many wires.I kept troubleshooting by using multimeter and finally realised that the voltage is not reaching on the pin of the sensor!! To resolve this I desoldered it from the board and solder it again by making sure that its pis are well connected to the vcc and GND and after the issue is resolved.

All those works(designs) done have been saved as files and they can be accessed and downloaded as a whole zipped folder via here