The soil Moisture sensor is widely used in measuring the water content in the soil. Soil moisture sensors do not measure water in the soil directly. Instead, they measure changes in other soil properties related to water content in a predictable way. Today we will see how it works and how we can use it in our way.
This sensor mainly utilizes capacitance to gauge the water content of the soil (dielectric permittivity). The working of this sensor can be done by inserting this sensor into the earth and the status of the water content in the soil can be reported in the form of a per cent.
The soil moisture sensor consists of two probes which are used to measure the volumetric content of water. The two probes allow the current to pass through the soil and then it gets the resistance value to measure the moisture value.
When there is more water, the soil will conduct more electricity which means that there will be less resistance. Therefore, the moisture level will be higher. Dry soil conducts electricity poorly, so when there will be less water, then the soil will conduct less electricity which means that there will be more resistance. Therefore, the moisture level will be lower.
Specifications
Operating Voltage: 3.3-5V
Current: <20mA
Output: Analog and Digital
The sensor comes with an LM393 comparator chip mounted on a module. This helps to generate a Digital Output as per the threshold setting value. The threshold value can be adjusted from the pot mounted on the module.
In our previous blog, we interfaced Pulse-Oximeter (Max30100) Module to NodeMCU. With a little bit of modification that can be upgraded to a full functioning Pulse-Oximeter. We have interfaced 0.96" I2C OLED display before. Today we made a Pulse-Oximeter using that knowledge.
Connection Diagram: Now follow the diagram below to do the connections.
After the connection is done upload the code below.
Source Code:
Video: Watch the video for a better understanding.
Reference:
[1] Sarkar, S., Ghosh, A., Chakraborty, M., & Mondal, A. (2024). Design, Hardware Implementation of a Domestic Pulse Oximeter Using IOT for COVID – 19 Patient. International Journal of Microsystems and Iot, 2(1), 469–475. https://doi.org/10.5281/zenodo.10629635
This LCD device is mainly used in Arduino but it can be connected with any 3.3V controller. These LCDs are used in Nokia 3110/5110 cell phones. It is a very cheap monochrome LCD module made of 84 x 48 pixels. It can be used to display graphics and text together. This display is based on the PCD8544 driver.
Pin configuration of this device is almost like the 16x2 LCD module only instead of 8 data pins one serial data in (Din) pin and one clock (Clk) are there. The list of the pins and their description are listed below.
RST: Pin type active low, so 0V Resets the LCD
CE: Cheap Enable is used to enable the device before sending anything to the LCD
DC: Data/Command is used to select between Rata Register or Command Register
DIN: Data In is used to send information serially to the display. It could be Data or Command
CLK: Clock is used to synchronize the display with the controller
VCC: To power, the pin 5V or 3.3V is applied here
BL: This pin is used to power the Backlight of the display
In the code below we have displayed text, then we have displayed the same text in inverted mode, after that we have rotated the text finally we displayed the ASCII table. Source Code 1:
Video 1:
Here in the second code, we tested display by displaying an image. To display the image we have to convert the image into code. To do that open the link image2cpp. Link: http://javl.github.io/image2cpp/
Go to "Choose Files" and select the file from your computer.
Select the "Canvas Size" to 84x48 and "Scaling" as Scale to fit. Then check the preview to make sure everything is alright.
Now select the "Code Output Format" to "Arduino code" and click on "Generate code"
Finally copy the code and add that to the code below to display an image of your own.
The MAX30100 has integrated pulse oximetry and heart-rate monitor sensor integrated circuit with I2C interface. NodeMCU is mostly preferred as it is a 3.3V controller.
Components Required:
Pulse Oximeter MAX30100
NodeMCU
Jumper Wires
Bread Board
Soldering Kit (Optional)
Before the connection is done there is slight modification needs to be done. The board shown above has little issue with NodeMCU or any other controller. As the NodeMCU is a 3.3V controller it sends or receives I2C signals at a 3.3V logic level. MAX30100 usually comes with its I2C bus pulled up to 1.8V. This is why if you don't make any modifications, the code might not run. Although without modification, you would be able to check its I2C address but rest of the functions won't work.
Now before we go for the modification let's see the Pinout of MAX30100. It has 14 pins. The I2C bus is at Pin 2 and Pin 3 is SCL and SDA. Pin 13 is for INT (Interrupt), Pin 11 and 12 is for Power and Ground.
If we look at the module we will be able to find that Pin 2(SCL), Pin 3(SDA), Pin 5(IR_DRV), Pin 6(R_DRV), Pin 13(INT) are connected to the header. Pin 9(R_LED+) and Pin 10(IR_LED+) are connected to 3.3V. Pin 11(VDD) is connected to 1.8V. Pin12(GND), Pin4(PGND) are connected to the ground.
Above the red marked 3 pin device is a 1.8V regulator supplying 1.8V to VDD (Pin 11) and also to the three 4.7k Ohms pull-up resistors.
Here we have three 4.7k Ohm resistor pulling up Pin 2(SCL), Pin 3(SDA), Pin 13(INT) up to 1.8V. Here we have to make a change and we have to pull these pins up to 3.3V to connect them with NodeMCU. This could be done in two ways.
Option 1: Remove them and connect 3 external 4.7k Pull up Resistors for 3.3V.
Option 2: Without removing them we will use them by making a slight change in the module. To do that at first with a help of a sharp cutter we will disconnect them from the 1.8V pin of the regulator. Just make a cut at the Red marked position shown in the image below. To make sure the disconnection is complete check continuity using a Multimeter. Do it carefully so that no damage happens at any other part of the device.
Then Connect the points shown below. Make sure during soldering no other points get connected.
If the above step is difficult for you then you can connect these two. Both the pins are 3.3V so they won't make any difference.
For me the first option was easier so after mofification my module looks like this.
Reference: [1] Sarkar, S., Ghosh, A., Chakraborty, M., & Mondal, A. (2024). Design, Hardware Implementation of a Domestic Pulse Oximeter Using IOT for COVID – 19 Patient. International Journal of Microsystems and Iot, 2(1), 469–475. https://doi.org/10.5281/zenodo.10629635
Light Intensity is an important parameter. This could be measured by various components (eg. LDR) with proper calibration. This is why BH1750 is easy to use. It has an I2C interface so data could be extracted easily using the I2C Bus.
Things we need:
BH1750
Arduino
Jumper Wires
Bread Board (Optional)
Connection Diagram:
Connection is very simple, BH1750 has five pins Vcc, Gnd, SCL, SDA, Addr. Connect the pins accordingly.
VCC pin to Arduino 5V
GND pin to Arduino Ground
SCL pin to Arduino A5
SDA pin to Arduino A4
Once the connection is done open Arduino IDE and upload the code below.
In our previous blog, we discussed interfacing of Dot Matrix Display with Arduino and found out that the process consumes lots of Arduino pins. To solve this issue we will use a driver IC. With help of this driver IC, we will control an 8x8 Dot Matrix Display using only 3 I/O pins.
The module has five pins. Their descriptions are given below.
VCC - 5V GND - Ground DIN - Data In
CS - Chip Select CLK - Clock
Materials Required:
Dot Matrix Display Module
Jumper Wires
Arduino
Circuit Diagram:
VCC pin to Arduino 5V pin
GND pin to Arduino GND pin
DIN pin to Arduino Pin 11
CS pin to Arduino Pin 7
CLK pin to Arduino Pin 13
Connect the display module with Arduino as shown above. After the connection is complete then upload the program. You should find the result as shown in the below video.
Source Code:
In this second version, the array is introduced. Using array we can store multiple values in a variable. This allows us to make the code short. If you go through the resulting video you will find that this second version is more complex sill the code size is less.
Dot Matrix displays are categorized upon their number of rows and number of columns and size of pixels. Usually, dot matrix displays come in the square shape of 8x8 LEDs but here we are going to demonstrate a 7x5 LEDs Display. The benefit of a dot matrix display is that you will be able to display characters or images using this. The process shown here is very simple to understand but the drawback is that this process consumes lots of pins. If you look at the Arduino in the video below you will see that 12 digital I/O pins are used to control one display. For come controllers, we might not have 12 I/O pins at all. The process of overcoming this scenario we will discuss in our next blog.
Things we need:
Arduino
7x5 Dot Matrix Display
330 Ohms - 7 Nos
Dot Vero (KS-100) or Bread Board
Jumper Wires
Soldering Kit (Not required for Bread Board)
Connection Diagram:
Connect the pins as described then upload the code below. The first code is about displaying a heart in portrait mode and the second code is about displaying the same heart in landscape mode. Check the results in the video below.
Seven segment displays come in different sizes. Their pin configuration also varies. So after purchasing any Common Cathode (CC) or Common Anode (CA) type display one must find the pin configuration. Usually, the datasheet could be found using the printed model number on the 7-Segment display. Depending upon the type (CC or CA) drivers are available to drive a display. Otherwise, they require an 8bit data line and 1bit control line per display. Drivers also help to drive the current for segments as sometimes for bigger displays the requirement of the current might be more than the controller could supply.
In a 7 Segment Display, the segments are named as a,b,c,...,e,f, and Dot Point. The segments are positioned as below.
To interface 7-Seg display with Arduino, we need
Arduino UNO / NANO
7-Seg Display Common Anode type
330 Ohms Resistor
40x1 Male Berg Strip
Dot Vero or Bread Board
Connecting Wires
Jumper Wires - Male Female Type
Soldering Kit (Not required for Bread Board)
Connection Diagram:
D2 is connected to A
D3 is connected to B
D4 is connected to C
D5 is connected to D
D6 is connected to E
D7 is connected to F
D8 is connected to G
D9 is connected to Common Pin
Once the connection is complete copy the below code to Arduino IDE and upload it to your Arduino.
The code is for displaying 0-9. After uploading you should see the counting started. Please check the video for results.
Troubleshoot:
If you find that all the segments are not glowing at 8 that means there are some wires that are not connected properly.
If you see that display is showing abnormal values please check the connection diagram between Arduino and the Display.
LEDs are the most basic kind of display. But the problem is One LED has only two states, On state and Off state. So it can not give more than two outputs. If we need more than two outputs what option do we have?
We can use multiple LEDs to make a display. So eight LEDs are combined together to make a display that can show 0-9 and Dot point. To display a digit maximum of seven segments consists of seven LEDs are used. Hence the name came Seven Segment Display. Eight LEDs can be connected in two ways either we could common all of their positive together or the negative together. This is why we have two types of seven-segment displays. Common cathode and common anode. A typical structure and connection diagram of the 7-Segment display is shown below. 0-9 is not enough to display right? What if we need to display characters, symbols, or images?
Dot Matrix displays are the solutions. Multiple LEDs are connected together to form an array. They are connected row-wise cathode and column-wise anode or vice-versa. Now with this formation, we can easily display anything we want. If we use RGB LEDs then displaying colored images also possible. A typical connection diagram and image of the dot matrix display are shown below.
LCD Displays comes in different sizes. These displays are popular because they are easy to interface with. We had already interfaced 16x2 LCD with Arduino Microcontroller in our previous blogLCD Display Interface with Arduino.
There was one drawback. LCD Displays require a minimum of six pins. Most of the microcontroller does not have this much pins to bare. What if we need to interface two LCDs, that would cost twelve pins. To solve this issue we need the I2C Module.
With help of this module, we only need only the I2C bus. The advantage is multiple devices could be connected on one bus.
Things we need:
Arduino Uno
IIC Module for LCD Display
16x2 LCD Display
2mm Pitch 1x40 Female Berg Strip
2mm Pitch 1x40 Male Berg Strip
Connection is simple, First using Berg Strip connect LCD Module with the IIC Module. Then using Jumper wire connect Arduino 5V pin to Modules VCC Pin, Arduino Gnd pin to Module Gnd Pin, Arduino A5 Pin to Modules SCL Pin, and Arduinos A4 Pin to I2C Modules SDA Pin as shown below.
LCD Module can be soldered directly with the IIC Module but this would create a problem if any of the two gets damaged. Otherwise, LCD can be brought together pre-soldered with the IIC Module.
Circuit Diagram:
After the connection is complete copy-paste and upload, the I2C scanner code. Then open the Serial Monitor there you will find the I2C address for your device. Note the IIC address.
I2C Scanner:
Now Copy the code below to your Arduino IDE and Replace my IIC address (0x3F) with your IIC address that you noted ago. Then upload the code. And you should see the screen working. If nothing on the screen try to rotate the Potentiometer that you have on the IIC Module. That pot controls the Contrast of your display.
Relay is a switch that can be actuated using an electrical signal. In this blog, we will discuss the operation of a relay and relay board along with the process of interfacing with different microcontrollers. There are many types of relays. We will discuss SPDT type. An SPDT relay has five terminals Normally Open (NO), Normally Close (NC), Common (C), A1 and A2 are used to power the coil. When the coil is powered contact between C and NC switches to NO side, this is called actuated state.
Relays are used when we are using electrically isolated circuits. Like using a 5V DC Relay we can turn on 230V AC load.
Things we need
SPDT Relay 5V (RL1)
NPN Transistor : BC547 (Q1)
Resistor : 1k Ohm (R1)
Diode : 1N4007 (D1)
LED Optional
In our project we can connect any micronontroller's pin at Input. 1k Ohm resistor is used to control the base current of the transistor Q1. D1 is a Freewheeling Diode. RL1 is the relay that is controlling the 12V Load.
That's all you have to do. Now let's check what changes have come.
Now lets program nodeMCU with a basic example program Blink. Go to File > Examples > Basic > Blink
Now Go to Tools > Boards: and select NodeMCU
After selecting the board go to Port and select the right communication port. Hit the Upload button.
The upload may take a few seconds and after that, you will find a screen like this stating that uploading is done. During the upload the led near pin D0 might blink several times but after the uploading is complete the led will keep glowing for 1 sec and staying off for 1 second.
NodeMCU is an open-source IoT platform. It includes firmware that runs on the ESP8266 Wi-Fi system on a chip(SoC) from Espressif Systems and hardware which is based on the ESP-12 module. The term "NodeMCU" by default refers to the firmware rather than the development kits. The firmware uses the Lua scripting language. It is based on the eLua project and built on the Espressif Non-OS SDK for ESP8266.
In simple words, NodeMCU is a WiFi-enabled microcontroller. It has a micro USB connector so it could be connected to any computer using data cable. The only thing that you must remember that it is a 3.3V logic level device. It means you will get a 3.3V digital high signal and giving more than 3.3V signal is not safe for the controller, however, the input voltage can vary from 5 to 12V.
NodeMCU Pinout contains 9 Digital pins, 1 Analog Pins, 1 Reset Pins & 4 Power Pins. Although some pins are very difficult to use sometimes. Let's have a look at the pinout.
D0 - D8 are Digital Pins
A0 is the only analog pin
The Micro USB port makes it very easy to connect with PC. Node MCU can be programmed using Arduino IDE but when we program it with Arduino IDE the original Lua firmware gets overwritten or in other words lost.
a
In our next blog, we will discuss the programming process of the NodeMCU.