Search Results
81 items found for ""
- Measuring Humidity and temperature using DHT11 sensor with Arduino. | TechKnowSkola
Back Measuring Humidity and temperature using DHT11 sensor with Arduino. What is a Digital Humidity Temperature Sensor? DHT11 is a Humidity and Temperature Sensor, which generates calibrated digital output. DHT11 can be interface with any microcontroller like Arduino, Raspberry Pi, etc. and get instantaneous results. DHT11 is a low-cost humidity and temperature sensor which provides high reliability and long-term stability. Material Required: Material Quantity Arduino Uno 1 DHT11 Sensor 1 Jumper cables 3 Pinout Diagram: Working: Ok now let’s see how these sensors work. They consist of a humidity sensing component, an NTC temperature sensor (or thermistor) and an IC on the back side of the sensor. For measuring humidity they use the humidity sensing component which has two electrodes with moisture holding substrate between them. So as the humidity changes, the conductivity of the substrate changes or the resistance between these electrodes changes. This change in resistance is measured and processed by the IC which makes it ready to be read by a microcontroller. On the other hand, for measuring temperature these sensors use an NTC temperature sensor or a thermistor. A thermistor is a variable resistor that changes its resistance with the temperature change. These sensors are made by sintering semiconductive materials such as ceramics or polymers to provide larger changes in the resistance with just small temperature changes. The term “NTC” means “Negative Temperature Coefficient”, which means that the resistance decreases with an increase in the temperature. Circuit Diagram: The DHTxx sensors have four pins, VCC, GND, data pin and a not connected pin which has no usage. A pull-up resistor from 5K to 10K Ohms is required to keep the data line high and to enable the communication between the sensor and the Arduino Board. There are some versions of these sensors that come with a breakout board with a built-in pull-up resistor and they have just 3 pins. The DHTXX sensors have their single wire protocol used for transferring the data. This protocol requires precise timing and the timing diagrams for getting the data from the sensors can be found in the datasheets of the sensors. However, we don’t have to worry much about these timing diagrams because we will use the DHT library which takes care of everything. Tested Programming Code: First, we need to include the DHT library which can be found from the Arduino official website or can be downloaded from the following link https://github.com/adidax/dht11 then define the PIN to which our sensor is connected and create a DHT object. In the setup section, we need to initiate the serial communication because we will use the serial monitor to print the results. Using the read22() function we will read the data from the sensor and put the values of the temperature and the humidity into the t and h variables. If you use the DHT11 sensor you will need to you the read11() function. In the end, we will print the temperature and the humidity values on the serial monitor. #include "DHT.h" #define DHTPIN 2 DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("DHTxx test!"); dht.begin(); } void loop() { measurements. delay(2000); float h = dht.readHumidity(); float t = dht.readTemperature(); float f =dht.readTemperature(true); if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } float hi = dht.computeHeatIndex(f, h); Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hi); Serial.println(" *F"); } After we will upload this code to the Arduino board, the temperature and humidity results from the sensor can be seen on the Serial monitor. Precautions: Double-check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether the proper board is selected from Arduino IDE. Ensure proper placement of sensor for correct working. Don’t put the sensor in any fluid or water, this is meant for taking ambient readings only. Conclusion: You can successfully measure temperature and humidity using the DHT11 sensor. Many more other applications can be made and triggered using the DHT11 sensor. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38) | TechKnowSkola
Back Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38) What is a Soil Moisture Sensor? This sensor measures the volumetric content of water inside the soil and gives us the moisture level as output. The sensor is equipped with both analog and digital output, so it can be used in both analog and digital mode. So let’s begin our tutorial on interfacing Arduino and Soil moisture sensor. Specifications: Input Voltage : 3.3– 5V Output Voltage : 4.2V Input Current : 35mA Output Signal : Both Analog and Digital Material Required: Material Quantity Arduino Uno 1 Soil Moisture Sensor 1 Jumper cables 5 Pinout Diagram: The soil Moisture sensor YL-38has four pins VCC: For power A0: Analog output D0: Digital output GND: Ground The Module also contains a potentiometer which will set the threshold value and then this threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value. Working: 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. This sensor can be connected in two modes; Analog mode and digital mode. First, we will connect it in Analog mode, and then we will use it in Digital mode. Analog Mode – Interfacing Soil Moisture Sensor and Arduino' To connect the sensor in the analog mode, we will need to use the analog output of the sensor. When taking the analog output from the soil moisture sensor FC-28, the sensor gives us the value from 0-1023. The moisture is measured in percentage, so we will map these values from 0 -to 100, and then we will show these values on the serial monitor. You can further set different ranges of the moisture values and turn on or off the water pump according to it. Circuit Diagram: The connections for connecting the soil moisture sensoYL-38 to the Arduino are as follows. VCC of YL-38 to 5V of Arduino GND of YL-38 to GND of Arduino A0 of YL-38 to A0 of Arduino Tested Programming Code: const int soil_sensor = A0; sensor is attached to int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(soil_sensor); serial monitor: Serial.print("Moisture Value = " ); Serial.println(sensorValue); delay(1000); } Digital Mode – Interfacing Arduino and Soil Moisture Sensor To connect the soil moisture sensor YL-38 in the digital mode, we will connect the digital output of the sensor to the digital pin of the Arduino. The Sensor module contains a potentiometer with it, which is used to set the threshold value. This threshold value is then compared with the sensor output value using the LM393 comparator which is placed on the sensor module. The LM393 comparator will compare the sensor output value and the threshold value and then gives us the output through the digital pin. When the sensor value will be greater than the threshold value, then the digital pin will give us 5V and the LED on the sensor will light up and when the sensor value will be less than this threshold value, then the digital pin will give us 0V and the light will go down. Circuit Diagram: The connections for connecting the soil moisture sensor YL-38 to the Arduino in digital mode are as follows. · VCC of YL-38 to 5V of Arduino · GND of YL-38 to GND of Arduino · D0 of YL-38 to pin 12 of Arduino · LED positive to pin 13 of Arduino · LED negative to GND of Arduino Tested Programming Code int led_pin =13; int sensor_pin =8; void setup() { pinMode(led_pin, OUTPUT); pinMode(sensor_pin, INPUT); } void loop() { if(digitalRead(sensor_pin) == HIGH) { digitalWrite(led_pin, HIGH); } else { digitalWrite(led_pin, LOW); delay(1000); } } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Please keep your hardware away from water except, the sensing probe. Conclusion: You can successfully measure the moisture percentage in the soil and control the appropriate flow of water. This sensor can be deployed in many ways like auto irrigation systems, automatic plant watering systems etc. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of MQ2 (gas) sensor with Arduino Uno. | TechKnowSkola
Back Interfacing of MQ2 (gas) sensor with Arduino Uno. What is a MQ2 (gas) Sensor? The Gas Sensor (MQ2) module is useful for gas leakage detection (home and industry). It is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke or Propane. Due to its high sensitivity and fast response time, measurement can be taken as soon as possible. The sensitivity of the sensor can be adjusted by potentiometer. Material Required: Material Quantity Arduino Uno 1 MQ2 (gas) Sensor 1 Jumper cables 6 LED 1 Pinout Diagram: Circuit Diagram: Connect the pulse sensor with Arduino as follows: GND pin of MQ2 (gas) sensor to GND of Arduino VCC of MQ2 (gas) sensor to 5V of Arduino A0 of MQ2 (gas) sensor to A0 of Arduino D0 of MQ2 (gas) sensor to D2 of Arduino. If needed. After that, connect the LED to pin 13 and GND of Arduino as shown in the figure below. The LED will blink according to the MQ2 (gas) sensor. Tested Programming Code: Const int gaspin = A0; float sensorValue ; //variable to store sensor value void setup () { pinMode(gaspin,INPUT); Serial . begin ( 9600 ); // sets the serial port to 9600 Serial . println ( "Gas sensor warming up!" ); delay ( 20000 ); // allow the MQ-6 to warm up } void loop () { sensorValue = analogRead ( gaspin ); // read analog input pin 0 Serial . print ( "Sensor Value: " ); Serial . print ( sensorValue ); if ( sensorValue > 300 ) { Serial . print ( " | Smoke detected!" ); } Serial . println ( "" ); delay ( 2000 ); // wait 2s for next reading } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of MQ2 (gas) Sensor for correct working. 5. Don’t lose hope if Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor. There you can see the value of gas present in air by the sensor. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of Pulse Rate Sensor with Arduino Uno. | TechKnowSkola
Back Interfacing of Pulse Rate Sensor with Arduino Uno. What is a Pulse Rate Sensor? The pulse sensor we are going to use is a plug and play heart rate sensor. This sensor is quite easy to use and operate. Place your finger on top of the sensor and it will sense the heartbeat by measuring the change in light from the expansion of capillary blood vessels. The pulse sensor module has a light which helps in measuring the pulse rate. When we place the finger on the pulse sensor, the light reflected will change based on the volume of blood inside the capillary blood vessels. Material Required: Material Quantity Arduino Uno 1 Pulse Rate Sensor 1 Jumper cables 6 LED 1 Pinout Diagram: Circuit Diagram: Connect the pulse sensor with Arduino as follows: GND pin of pulse sensor to GND of Arduino VCC of pulse sensor to 5V of Arduino A0 of pulse sensor to A0 of Arduino After that, connect the LED to pin 13 and GND of Arduino as shown in the figure below. Tested Programming Code: int PulseSensorPurplePin = 0; int LED13 = 13; int Signal; int Threshold = 550; void setup() { pinMode(LED13,OUTPUT); Serial.begin(9600); } void loop() { Signal = analogRead(PulseSensorPurplePin); Serial.println(Signal); if(Signal > Threshold){ digitalWrite(LED13,HIGH); } else { digitalWrite(LED13,LOW); } delay(10); } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether proper board is selected from Arduino IDE. Ensure proper placement of pulse rate Sensor for correct working. Don’t lose hope if pulse rate Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor. There you can see the Pulse Rate (BPM) on the sensor. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno | TechKnowSkola
Back Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno What is a Matrix Display? Dot-matrix LED display contains the group of LEDs as a two-dimensional array. They can display different types of characters or a group of characters. Dot-matrix LED display contains the group of LEDs as a two-dimensional array. They can display different types of characters or a group of characters. Dot-matrix display is manufactured in various dimensions. The arrangement of LEDs in the matrix pattern is made in either of the two ways: Row anode-column cathode or Row cathode-column anode. By using this dot matrix display we can reduce the number of pins required for controlling all the LEDs. Material Required: Material Quantity Arduino Uno 1 MAX 7219 Display Module 1 Jumper cables 5 Pinout Diagram: Circuit Diagram: Working: An LED dot matrix consists of an array of LEDs that are connected such that the anode of each LED is connected in the same column and the cathode of each LED is connected in the same row or vice versa . Here each dot represents circular lenses in front of LEDs. This is done to minimize the number of pins required to drive them. For example, an 8X8 matrix of LEDs would need 64 I/O pins, one for each LED pixel. By connecting all the anodes of LEDs in a column and all the cathodes together in a row, the required number of input and output pins is reduced to 16. Each LED will be addressed by its row and column number. Controlling the LED Matrix: Since all the LEDs in a matrix share their positive and negative terminals in each row and column, it is not possible controlling of each LED at the same time. The matrix controlled through each row very quickly by triggering the correct column pins to light the desired LED for that particular row. If the switching is done with a fixed rate, humans can’t see the displaying message, because the human eye can’t detect the images within the milliseconds. Thus the displaying of a message on an LED matrix must be controlled, with the rows being scanned sequentially at a rate greater than 40 MHz while sending out the column data at the same rate. This kind of control can be done by interfacing the LED matrix display with the microcontroller. Interfacing the LED Matrix Display with Microcontroller: Choosing a microcontroller for interfacing with the LED matrix display which is to be controlled is depends on the number of input and output pins needed for controlling all the LEDs in the given matrix display, the amount of current that each pin can source and sink, and the speed at which the microcontroller can send out control signals. With all these specifications, interfacing can be done for LED matrix display with a microcontroller. Tested Programming Code: A library needs to be downloaded and then to be installed. Go to Disk drive where your Arduino IDE is installed and then go to > Program Files>Arduino> Libraries> then Ctrl+V (Paste). https://github.com/riyas-org/max7219/tree/master/MaxMatrix https://github.com/riyas-org/max7219 : Main Link #include int DIN = 7; // DIN pin of MAX7219 module int CLK = 6; // CLK pin of MAX7219 module int CS = 5; // CS pin of MAX7219 module int maxInUse = 1; MaxMatrix m(DIN, CS, CLK, maxInUse); char A[] = {4, 8, B01111110, B00010001, B00010001, B01111110, }; char B[] = {4, 8, B01111111, B01001001, B01001001, B00110110, }; char smile01[] = {8, 8, B00111100, B01000010, B10010101, B10100001, B10100001, B10010101, B01000010, B00111100 }; char smile02[] = {8, 8, B00111100, B01000010, B10010101, B10010001, B10010001, B10010101, B01000010, B00111100 }; char smile03[] = {8, 8, B00111100, B01000010, B10100101, B10010001, B10010001, B10100101, B01000010, B00111100 }; void setup() { m.init(); // MAX7219 initialization m.setIntensity(8); // initial led matrix intensity, 0-15 } void loop() { // Seting the LEDs On or Off at x,y or row,column position m.setDot(6,2,true); delay(1000); m.setDot(6,3,true); delay(1000); m.clear(); // Clears the display for (int i=0; i<8; i++){ m.setDot(i,i,true); delay(300); } m.clear(); // Displaying the character at x,y (upper left corner of the character) m.writeSprite(2, 0, A); delay(1000); m.writeSprite(2, 0, B); delay(1000); m.writeSprite(0, 0, smile01); delay(1000); m.writeSprite(0, 0, smile02); delay(1000); m.writeSprite(0, 0, smile03); delay(1000); for (int i=0; i<8; i++){ m.shiftLeft(false,false); delay(300); } m.clear(); } Program Description: So first we need to include the MaxMatrix.h library, define the pins to which the module is connected, set how many modules we use and define the MaxMatrix object. For displaying characters, we need to define them in an array of characters or bytes, and here I have several examples. We can notice how the bits are forming the characters which are zeros and ones. In this case, they are rotated 90 degrees but the library example suggests using them in such a way so that would be easier later to implement the shift left custom function for scrolling a text. Precautions: 1. Double Check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check Whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. Conclusion: You can successfully program different characters on a matrix display, this display can be combined with many more displays to get a larger display area. Output:: Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Measuring Distance using Ultrasonic Sensor with Arduino | TechKnowSkola
Back Measuring Distance using Ultrasonic Sensor with Arduino What is an Ultrasonic Sensor? An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object. Since it is known that sound travels through air at about 344 m/s (1129 ft/s), you can take the time for the sound wave to return and multiply it by 344 meters (or 1129 feet) to find the total round-trip distance of the sound wave. Round-trip means that the sound wave traveled 2 times the distance to the object before it was detected by the sensor; it includes the 'trip' from the sonar sensor to the object AND the 'trip' from the object to the Ultrasonic sensor (after the sound wave bounced off the object). To find the distance to the object, simply divide the round-trip distance in half. Pinout diagram: Material Required: Material Quantity Arduino Uno 1 Ultrasonic Sensor 1 Jumper cables 4 Circuit Diagram: Working: It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. In order to generate the ultrasound, you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound waves traveled. For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound waves needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2. Tested Programming Code: // defines pins numbers const int trigPin = 9; const int echoPin = 10; // defines variables long duration; int distance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); } Precautions: 1. Double Check the connections before powering on thecircuit. 2. Don’t use loose jumper cables. 3. Check Whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. Conclusion: You can Measure distance using this ultrasonic sensor, without use of any measuring tape or high priced instrument. Many more other applications can be made using ultrasonic sensor as it has many possibilities to work with. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Projects (All) | TechKnowSkola
PROJECTS 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth Read More Interfacing GPS with Arduino (Neo-6M-001) In this tutorial we will learn how to use a GPS Module with Arduino. Neo 6M (Ublox NEO6MV2) is a I2C compliant GPS module. This post discusses details on wiring Ublox Neo 6M with Arduino or an USB to Serial/TTL adapter, basic interactions with module using serial communication, using u -center GUI in visualizations, as well as using TinyGPS library to extract fine grained results from the module output. Read More Analog Joystick Interfacing with Arduino UNO. In this tutorial we will learn how to interface an Analog Joystick with the Arduino Uno and checking the values on the Serial Monitor. Read More Interfacing of MQ2 (gas) sensor with Arduino Uno. In this tutorial we will learn how to interface a MQ2 (gas) Sensor with the Arduino Uno Read More Interfacing of LDR Sensor Module with Arduino Uno. In this tutorial we will learn how to interface a LDR sensor Module with the Arduino Uno. Read More Interfacing of RFID Module with Arduino Uno. In this tutorial we will learn how to interface a RFID module with the Arduino Uno. Read More Measuring Distance using Ultrasonic Sensor with Arduino In this project we will learn the basics of how to measure distance using an ultrasonic sensor with an Arduino, which further can be used for controlling other parameters of a robot or many other applications. Read More Measuring Humidity and temperature using DHT11 sensor with Arduino. In this tutorial, we will learn how to use a DHT (DHT11 version) Temperature and Humidity Sensor. It’s accurate enough for most projects that need to keep track of humidity and temperature readings. We will be using a Library specifically designed for these sensors that will make our code short and easy to write. Read More 4*4 Keypad Interfacing with Arduino UNO. In this tutorial, we will learn how to interface a 4*4 Keypad with the Arduino Uno and check the values on the Serial Monitor. Read More Interfacing of Touch Sensor with Arduino Uno. In this tutorial, we will learn how to interface a Touch Sensor with the Arduino Uno. Read More Interfacing of Pulse Rate Sensor with Arduino Uno. In this tutorial we will learn how to interface a Pulse Rate Sensor with the Arduino Uno. Read More Finding an obstacle using IR Sensor with Arduino In this project we will learn the basics of how to find for an obstacle using an Infrared sensor with an Arduino, which further can be used for controlling other parameters of a robot and many other applications too. Read More Interfacing of Force Pressure Sensor with Arduino Uno. In this tutorial we will learn how to interface a Force Pressure Sensor with the Arduino Uno. Read More Displaying a text message on LCD Display using 16X2 Segment Display with Arduino. : In this tutorial we will learn how to interface a 16×2 LCD (liquid crystal display) with the Arduino Uno. Read More Interfacing of Metal Touch Sensor with Arduino. In this tutorial we will learn how to interface a Metal Touch Sensor with the Arduino Read More Interfacing with MQ-3 Alcohol Sensor Module Read More Interfacing of 28BYJ Stepper Driver with Arduino. In this tutorial we will learn how to interface a Flex Sensor with the Arduino Uno. Read More Interfacing of Buzzer with Arduino Uno. In this tutorial, we will learn how to interface a Buzzer with the Arduino Uno. Read More Interfacing of 4 Digit Segment Display with Arduino Uno. In this tutorial, we will learn how to interface a 4-digit segment display with the Arduino Uno. Read More Interfacing 2 Channel Relay Module with Arduino and control High Voltage AC (current). In this tutorial, we will learn how to interface a 2 channel relay module with the Arduino Uno. Read More Measuring water flow rate and calculating quantity using Flow Sensor with Arduino. In this tutorial, we will learn how to use a water flow sensor with Arduino. We will use the serial monitor for printing the water flow rate in liters per hour and the total of liters flowing since starting. So, let's get started! Read More Interfacing of GSM 800 L Modules with Arduino. In this tutorial we will learn how to interface GSM 800L Module with the Arduino Uno. Read More Bluetooth Controlled Car Using Arduino Uno. This project shows how you can build a car which can be controlled by your Smartphone using an android application via Bluetooth. Read More Interfacing of Laser Diode with Arduino Uno. In this tutorial we will learn how to interface a Laser Diode with the Arduino Uno. Read More Interfacing of Temperature Sensor (LM35) with Arduino Uno. In this tutorial we will learn how to interface a Temperature Sensor with the Arduino Uno. Read More Motion Detection using PIR Sensor with Arduino In this Arduino Tutorial we will learn how a PIR Sensor works and how to use it with the Arduino Board for detecting motion. Read More Interfacing of Sound sensor with Arduino Uno. In this tutorial we will learn how to interface a Sound Sensor with the Arduino Uno. Read More Interfacing Colour Sensor with Arduino (TCS3200) : In this tutorial, we will learn how to use a colour sensor with Arduino. We will use the serial monitor for printing the colour values. So let's get started! This sensor is used for detecting primary colours (red, green and blue, or RGB)—colours that are physically available in LEDs in one package; for example, common cathode or common-cathode RGB LED. We can display primary colours and also generate specific colours by modifying the Arduino code. Read More Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno In this Arduino project we will learn how to control 8×8 LED Matrix using the MAX7219 driver and the Arduino board. Read More Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38) In this tutorial, we will learn how to read soil moisture data using Analog Soil Moisture Sensor on the Arduino Platform. We are reading data from Analog Moisture Sensor, so we will get readings in the range 0 to 1023. Lesser the value means lesser the moisture in the soil. Read More Interfacing of Rain Drop Sensor with Arduino Uno. In this tutorial we will learn how to interface a Rain Drop Sensor with the Arduino Uno. Read More
- 500 | TechKnowSkola
Time Out This page isn’t available right now. But we’re working on a fix, ASAP. Try again soon. Go Back
- 500 | TechKnowSkola
Time Out This page isn’t available right now. But we’re working on a fix, ASAP. Try again soon. Go Back
- Projects
PROJECTS 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth Read More Interfacing GPS with Arduino (Neo-6M-001) In this tutorial we will learn how to use a GPS Module with Arduino. Neo 6M (Ublox NEO6MV2) is a I2C compliant GPS module. This post discusses details on wiring Ublox Neo 6M with Arduino or an USB to Serial/TTL adapter, basic interactions with module using serial communication, using u -center GUI in visualizations, as well as using TinyGPS library to extract fine grained results from the module output. Read More Analog Joystick Interfacing with Arduino UNO. In this tutorial we will learn how to interface an Analog Joystick with the Arduino Uno and checking the values on the Serial Monitor. Read More Interfacing of MQ2 (gas) sensor with Arduino Uno. In this tutorial we will learn how to interface a MQ2 (gas) Sensor with the Arduino Uno Read More Interfacing of LDR Sensor Module with Arduino Uno. In this tutorial we will learn how to interface a LDR sensor Module with the Arduino Uno. Read More Interfacing of RFID Module with Arduino Uno. In this tutorial we will learn how to interface a RFID module with the Arduino Uno. Read More Measuring Distance using Ultrasonic Sensor with Arduino In this project we will learn the basics of how to measure distance using an ultrasonic sensor with an Arduino, which further can be used for controlling other parameters of a robot or many other applications. Read More Measuring Humidity and temperature using DHT11 sensor with Arduino. In this tutorial, we will learn how to use a DHT (DHT11 version) Temperature and Humidity Sensor. It’s accurate enough for most projects that need to keep track of humidity and temperature readings. We will be using a Library specifically designed for these sensors that will make our code short and easy to write. Read More 4*4 Keypad Interfacing with Arduino UNO. In this tutorial, we will learn how to interface a 4*4 Keypad with the Arduino Uno and check the values on the Serial Monitor. Read More Interfacing of Touch Sensor with Arduino Uno. In this tutorial, we will learn how to interface a Touch Sensor with the Arduino Uno. Read More Interfacing of Pulse Rate Sensor with Arduino Uno. In this tutorial we will learn how to interface a Pulse Rate Sensor with the Arduino Uno. Read More Finding an obstacle using IR Sensor with Arduino In this project we will learn the basics of how to find for an obstacle using an Infrared sensor with an Arduino, which further can be used for controlling other parameters of a robot and many other applications too. Read More Interfacing of Force Pressure Sensor with Arduino Uno. In this tutorial we will learn how to interface a Force Pressure Sensor with the Arduino Uno. Read More Displaying a text message on LCD Display using 16X2 Segment Display with Arduino. : In this tutorial we will learn how to interface a 16×2 LCD (liquid crystal display) with the Arduino Uno. Read More Interfacing of Metal Touch Sensor with Arduino. In this tutorial we will learn how to interface a Metal Touch Sensor with the Arduino Read More Interfacing with MQ-3 Alcohol Sensor Module Read More Interfacing of 28BYJ Stepper Driver with Arduino. In this tutorial we will learn how to interface a Flex Sensor with the Arduino Uno. Read More Interfacing of Buzzer with Arduino Uno. In this tutorial, we will learn how to interface a Buzzer with the Arduino Uno. Read More Interfacing of 4 Digit Segment Display with Arduino Uno. In this tutorial, we will learn how to interface a 4-digit segment display with the Arduino Uno. Read More Interfacing 2 Channel Relay Module with Arduino and control High Voltage AC (current). In this tutorial, we will learn how to interface a 2 channel relay module with the Arduino Uno. Read More Measuring water flow rate and calculating quantity using Flow Sensor with Arduino. In this tutorial, we will learn how to use a water flow sensor with Arduino. We will use the serial monitor for printing the water flow rate in liters per hour and the total of liters flowing since starting. So, let's get started! Read More Interfacing of GSM 800 L Modules with Arduino. In this tutorial we will learn how to interface GSM 800L Module with the Arduino Uno. Read More Bluetooth Controlled Car Using Arduino Uno. This project shows how you can build a car which can be controlled by your Smartphone using an android application via Bluetooth. Read More Interfacing of Laser Diode with Arduino Uno. In this tutorial we will learn how to interface a Laser Diode with the Arduino Uno. Read More Interfacing of Temperature Sensor (LM35) with Arduino Uno. In this tutorial we will learn how to interface a Temperature Sensor with the Arduino Uno. Read More Motion Detection using PIR Sensor with Arduino In this Arduino Tutorial we will learn how a PIR Sensor works and how to use it with the Arduino Board for detecting motion. Read More Interfacing of Sound sensor with Arduino Uno. In this tutorial we will learn how to interface a Sound Sensor with the Arduino Uno. Read More Interfacing Colour Sensor with Arduino (TCS3200) : In this tutorial, we will learn how to use a colour sensor with Arduino. We will use the serial monitor for printing the colour values. So let's get started! This sensor is used for detecting primary colours (red, green and blue, or RGB)—colours that are physically available in LEDs in one package; for example, common cathode or common-cathode RGB LED. We can display primary colours and also generate specific colours by modifying the Arduino code. Read More Character Displaying using 8X8 LED Matrix MAX7219 with Arduino Uno In this Arduino project we will learn how to control 8×8 LED Matrix using the MAX7219 driver and the Arduino board. Read More Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38) In this tutorial, we will learn how to read soil moisture data using Analog Soil Moisture Sensor on the Arduino Platform. We are reading data from Analog Moisture Sensor, so we will get readings in the range 0 to 1023. Lesser the value means lesser the moisture in the soil. Read More Interfacing of Rain Drop Sensor with Arduino Uno. In this tutorial we will learn how to interface a Rain Drop Sensor with the Arduino Uno. Read More
- Bluetooth Controlled Car Using Arduino Uno.
Back Bluetooth Controlled Car Using Arduino Uno. Material Required: Material Quantity Arduino Uno 1 12V DC Motor /BO motor 2 Jumper cables 15 HC-05 Bluetooth Module 1 Breadboard 1 Breadboard 1 This tutorial will teach you how to create your own Bluetooth controlled car. So let’s get started. This will be a Bluetooth controlled car so for this project we will be using HC-05 Bluetooth module to receive the controlling data packets. We will also need an android app which will be sending the controlling data packets to the Bluetooth module. We will use a third party application ( https://play.google.com/store/apps/details?id=com.broxcode.arduinobluetoothfree&hl=en to download) for this purpose. Let's build the hardware (Body of the car) The car which we are building for this project will be a dual motor car. Two 12 v 200 rpm DC or BO motors. You can use a readymade chassis. Circuit Now let us build the circuit. CODE : Here we will use the direction of rotation of motors to control the direction of the car. Forward - Both motors move in forward direction. Backward - Both motors move in backward direction. Left - Left motor moves backwards and right motor moves forward. Right - Left motor moves forwards and right motor moves backward. Stop - Both motors stop Tested Programming Code: #include AF_DCMotor motor1(1); //motor1 is the left motor AF_DCMotor motor2(2); //motor2 is the right motor int val; void setup() { Serial.begin(9600); motor1.setSpeed(255); //motor speed is set motor2.setSpeed(255); Stop(); } void loop() { bt=Serial.read(); if(val=='1') //when the bluetooth module recieves 1 the car moves forward { forward(); } if(val=='2') //when the bluetooth module recieves 2 the car moves backward { backward(); } if(val=='3') //when the bluetooth module recieves 3 the car moves left { left(); } if(val=='4') //when the bluetooth module recieves 4 the car moves right { right(); } if(val=='5') //when the bluetooth module recieves 5 the car stops { Stop(); } } void forward() { motor1.run(FORWARD); motor2.run(FORWARD); } void backward() { motor1.run(BACKWARD); motor2.run(BACKWARD); } void left() { motor1.run(BACKWARD); motor2.run(FORWARD); } void right() { motor1.run(FORWARD); motor2.run(BACKWARD); } void Stop() { motor1.run(RELEASE); motor2.run(RELEASE); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of Bluetooth and Motor driver for correct working. 5. Don’t lose hope if it does not run properly for the first time, try again. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of Pulse Rate Sensor with Arduino Uno.
Back Interfacing of Pulse Rate Sensor with Arduino Uno. What is a Pulse Rate Sensor? The pulse sensor we are going to use is a plug and play heart rate sensor. This sensor is quite easy to use and operate. Place your finger on top of the sensor and it will sense the heartbeat by measuring the change in light from the expansion of capillary blood vessels. The pulse sensor module has a light which helps in measuring the pulse rate. When we place the finger on the pulse sensor, the light reflected will change based on the volume of blood inside the capillary blood vessels. Material Required: Material Quantity Arduino Uno 1 Pulse Rate Sensor 1 Jumper cables 6 LED 1 Pinout Diagram: Circuit Diagram: Connect the pulse sensor with Arduino as follows: GND pin of pulse sensor to GND of Arduino VCC of pulse sensor to 5V of Arduino A0 of pulse sensor to A0 of Arduino After that, connect the LED to pin 13 and GND of Arduino as shown in the figure below. Tested Programming Code: int PulseSensorPurplePin = 0; int LED13 = 13; int Signal; int Threshold = 550; void setup() { pinMode(LED13,OUTPUT); Serial.begin(9600); } void loop() { Signal = analogRead(PulseSensorPurplePin); Serial.println(Signal); if(Signal > Threshold){ digitalWrite(LED13,HIGH); } else { digitalWrite(LED13,LOW); } delay(10); } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether proper board is selected from Arduino IDE. Ensure proper placement of pulse rate Sensor for correct working. Don’t lose hope if pulse rate Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor. There you can see the Pulse Rate (BPM) on the sensor. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing Colour Sensor with Arduino (TCS3200)
Back Interfacing Colour Sensor with Arduino (TCS3200) What is a Color Sensor? A colour sensor can determine different colours. They will utilize a means of emitting light and then look at the reflected light to determine an object’s colour. This will give the machine the actual colour of that object. These sensors are in use in quite a few different applications today. You can find them in quality control systems, packaging systems, and more. Specifications: · Power: 2.7V to 5.5V · Size: 28.4 x 28.4mm (1.12 x 1.12″) · Interface: digital TTL · High-resolution conversion of light intensity to frequency · Programmable colour and full-scale output frequency · Communicates directly to the microcontroller Material Required: Material Quantity Arduino Uno 1 Colour Sensor 1 Jumper cables 10 Pinout Diagram: Working: The TCS230 senses colour light with the help of an 8 x 8 array of photodiodes. Then using a Current-to-Frequency Converter the readings from the photodiodes are converted into a square wave with a frequency directly proportional to the light intensity. Finally, using the Arduino Board we can read the square wave output and get the results for the colour. If we take a closer look at the sensor we can see how it detects various colours. The photodiodes have three different colour filters. Sixteen of them have red filters, another 16 have green filters, another 16 have blue filters and the other 16 photodiodes are clear with no filters. Every 16 photodiodes are connected in parallel, so using the two control pins S2 and S3 we can select which of them will be read. So for example, if we want to detect red colour, we can just use the 16 red filtered photodiodes by setting the two pins to a low logic level according to the table. The sensor has two more control pins, S0 and S1 which are used for scaling the output frequency. The frequency can be scaled to three different preset values of 100 %, 20 % or 2%. This frequency-scaling function allows the output of the sensor to be optimized for various frequency counters or microcontrollers. Circuit Diagram: Tested Programming Code: First, we need to define the pins to which the sensor is connected and define a variable for reading the frequency. In the setup section, we need to define the four control pins as outputs and the sensor output as an Arduino input. Here we also need to set the frequency scaling, for this example, I will set it to 20%, and start the serial communication for displaying the results in the Serial Monitor. In the loop section, we will start with reading the red filtered photodiodes. For that purpose, we will set the two control pins S2 and S3 to low logic level. Then using the “pulseIn()” function we will read the output frequency and put it into the variable “frequency”. Using the Serial.print() function we will print the result on the serial monitor. The same procedure goes for the two other colours, we just need to adjust the control pins for the appropriate colour. Code: #define S0 4 #define S1 5 #define S2 6 #define S3 7 #define sensorOut 8 int frequency = 0; void setup() { pinMode(S0, OUTPUT); pinMode(S1, OUTPUT); pinMode(S2, OUTPUT); pinMode(S3, OUTPUT); pinMode(sensorOut, INPUT); digitalWrite(S0,HIGH); digitalWrite(S1,LOW); Serial.begin(9600);} void loop() { digitalWrite(S2,LOW); digitalWrite(S3,LOW); frequency = pulseIn(sensorOut, LOW); Serial.print("R= ");//printing name Serial.print(frequency);//printing RED color frequency Serial.print(" "); delay(100); digitalWrite(S2,HIGH); digitalWrite(S3,HIGH); frequency = pulseIn(sensorOut, LOW); Serial.print("G= "); Serial.print(frequency);Serial.print(" "); delay(100); digitalWrite(S2,LOW); digitalWrite(S3,HIGH);frequency pulseIn(sensorOut, LOW); Serial.print("B= ");//printing name Serial.print(frequency);//printing RED color frequency Serial.println(" "); delay(100); } Precautions: 1. Double-check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Try it with different colours and see the change in values. Conclusion: You can successfully identify different colours using this sensor and can be deployed for many other purposes like item sorting, Rubiks cube solving etc. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) BLUE : GREEN : RED Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth
Back 8×8 LED Matrix MAX7219 Tutorial with Scrolling Text & Android Control via Bluetooth Students now you know everything about how a matrix works, let’s move to some advanced part of it. 8×8 LED Matrix Scrolling Arduino Code Next let’s take a look at the scrolling text example and see what’s different. Below the code you will find its description. #include #include PROGMEM const unsigned char CH[] = { 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // # 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, //* 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // - 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ; 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, //A 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, //O 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, //h 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, //v 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // { 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ }; int DIN = 7; // DIN pin of MAX7219 module int CLK = 6; // CLK pin of MAX7219 module int CS = 5; // CS pin of MAX7219 module int maxInUse = 2; MaxMatrix m(DIN, CS, CLK, maxInUse); byte buffer[10]; char text[]= "TechKnowSkola"; // Scrolling text void setup() { m.init(); // module initialize m.setIntensity(15); // dot matix intensity 0-15 } void loop() { printStringWithShift(text, 100); // (text, scrolling speed) } // Display=the extracted characters with scrolling void printCharWithShift(char c, int shift_speed) { if (c < 32) return; c -= 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(32, 0, buffer); m.setColumn(32 + buffer[0], 0); for (int i = 0; i < buffer[0] + 1; i++) { delay(shift_speed); m.shiftLeft(false, false); } } // Extract the characters from the text string void printStringWithShift(char* s, int shift_speed) { while (*s != 0) { printCharWithShift(*s, shift_speed); s++; } } Now let’s move to the functioning of Bluetooth HC-05 Description: Here we have to include an additional library for the PROGMEN which is variable modifier and it’s used for storing data in the flash memory instead of SRAM. When we have a larger database of variables which are static, like in this case defining letters and characters, it’s better to store them in the flash memory because it’s much bigger, 32K bytes, compared to the 2K bytes of the SRAM. Next with a character array we define the scrolling text and in the loop section the custom function printStringWithShift, prints the scrolling text on the LED matrix with a scrolling speed defined in milliseconds with the second argument. The first thing that this custom function do is that it extracts the characters from the text string and then display these scrolling characters on the led matrix. The particular module that I have can be powered from 3.6 to 6 volts, because it comes on breakout board which contains a voltage regulator. However, the logic voltage level of the data pins is 3.3V. So, the line between the Arduino TX (Transmit Pin, which has 5V output) and the Bluetooth module RX (Receive Pin, which supports only 3.3V) needs to be connected through a voltage divider in order not to burn the module. On the other hand, the line between the Bluetooth module TX pin and the Arduino RX pin can be connected directly because the 3.3V signal from the Bluetooth module is enough to beaccepted as a high logic at the Arduino Board. Circuit Schematics: Here’s how we need to connect the module to the Arduino Board. Connecting the Smartphone to the HC-05 Bluetooth Module and the Arduino Now we are ready to connect the smartphone to the Bluetooth module and the Arduino. What we need to do here is to activate the Bluetooth and the smartphone will find the HC-05 Bluetooth module. Then we need to pair the devices and the default password of the HC-05 module is 1234. After we have paired the devices we need an application for controlling the Arduino. There are many application in the Play Store for this purpose which will work with the Arduino code that we wrote. However, I made my own custom application for this tutorial using the MIT App Inventor online application. This is a great and easy to use application for building Android application and in my next tutorial you can find a detailed step by step guide how to build your own custom Android application for your Arduino Project. Android App for Controlling 8×8 LED Matrix via Bluetooth Once we learned how the MAX7219 works, now we can make the third example which is a practical Arduino project where we will build a custom Android app to control the LED matrix via Bluetooth communication. Before we continue I would suggest you to check detailed tutorials on how to use the HC-05 Bluetooth module and how to build a custom Android app using the MIT App Inventor online application . Here’s the Arduino code and now let’s see the modifications compared to the previous example. /* 8x8 LED Matrix MAX7219 Scrolling Text Android Control via Bluetooth by Dejan Nedelkovsk i, www.HowToMechatronics.com Based on the following library: GitHub | riyas-org/max7219 https://github.com/riyas-org/max7219 */ #include #include #include PROGMEM const unsigned char CH[] = { 3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space 1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // ! 3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // " 5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, //# 4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $ 5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // % 5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // & 1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // ' 3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // ( 3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // ) 5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // * 5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // + 2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // , 4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, //- 2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // . 4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // / 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0 3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1 4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2 4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3 4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4 4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5 4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6 4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7 4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8 4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9 2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // : 2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, //; 3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // < 3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // = 3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // > 4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ? 5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @ 4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A 4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B 4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C 4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D 4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E 4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F 4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G 4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H 3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I 4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J 4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K 4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L 5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M 5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N 4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O 4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P 4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q 4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R 4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S 5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, //T 4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U 5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V 5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W 5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X 5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y 4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z 2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [ 4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash 2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ] 3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat 4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _ 2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // ` 4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a 4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, //b 4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c 4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d 4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e 3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f 4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g 4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h 3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i 4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j 4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k 3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l 5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m 4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n 4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o 4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p 4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q 4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r 4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s 3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t 4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u 5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v 5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w 5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x 4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y 3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z 3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, //{ 1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // | 3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // } 4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~ }; int dIn = 7; // DIN pin of MAX7219 module int clk = 6; // CLK pin of MAX7219 module int cs = 5; // CS pin of MAX7219 module int maxInUse = 2; // Number of MAX7219's connected MaxMatrix m(dIn, cs, clk, maxInUse); SoftwareSerial Bluetooth(8, 7); // Bluetooth byte buffer[10]; char incomebyte; int scrollSpeed = 100; char text[100] = "TechKnowSkola "; // Initial text message int brightness = 15; int count = 0; char indicator; void setup() { m.init(); // MAX7219 initialization m.setIntensity(brightness); // initial led matrix intensity, 0-15 Bluetooth.begin(38400); // Default communication rate of the Bluetooth module } void loop() { // Printing the text printStringWithShift(text, scrollSpeed); if (Bluetooth.available()) { // Checks whether data is comming from the serial port indicator = Bluetooth.read(); // Starts reading the serial port, the first byte from the incoming data // If we have pressed the "Send" button from the Android App, clear the previous text if (indicator == '1') { for (int i = 0; i < 100; i++) { text[i] = 0; m.clear(); } // Read the whole data/string comming from the phone and put it into text[] array. while (Bluetooth.available()) { incomebyte = Bluetooth.read(); text[count] = incomebyte; count++; } count = 0; } // Adjusting the Scrolling Speed else if (indicator == '2') { String sS = Bluetooth.readString(); scrollSpeed = 150 - sS.toInt(); // Milliseconds, subtraction because lower value means higher scrolling speed } // Adjusting the brightness else if (indicator == '3') { String sB = Bluetooth.readString(); brightness = sB.toInt(); m.setIntensity(brightness); } } } void printCharWithShift(char c, int shift_speed) { if (c < 32) return; c -= 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(32, 0, buffer); m.setColumn(32 + buffer[0], 0); for (int i = 0; i < buffer[0] + 1; i++) { delay(shift_speed); m.shiftLeft(false, false); } } void printStringWithShift(char* s, int shift_speed) { while (*s != 0) { printCharWithShift(*s, shift_speed); s++; } } void printString(char* s) { int col = 0; while (*s != 0) { if (*s < 32) continue; char c = *s - 32; memcpy_P(buffer, CH + 7 * c, 7); m.writeSprite(col, 0, buffer); m.setColumn(col + buffer[0], 0); col += buffer[0] + 1; s++; } } Description: First we need to include the SoftwareSerial.h library which will enable the Bluetooth communication and define some variables needed for the program. In the setup section we need to initialize the Bluetooth at its default baud rate of 38400 bits per second. I set the initial text message to be “TechKnowSkola” with 100 milliseconds delay scrolling speed. Next, in the loop section, using the Bluetooth.available() function we check whether there is incoming data from the serial port and if that’s true using the Bluetooth.read function we start reading the serial port, one byte each iteration. So the first incoming byte will be always stored into the “indicator” variable and according to it choose whether we will change the text message, the scrolling speed or the brightness of the LED matrix. If we take a look at the Android app code blocks we can notice that when the “Send” button is clicked, first we send the indication byte, in this case “1”, which means we want the change the text message. In order to do that, at the Arduino side, we will clear the whole character array and also clear the LED matrix display. Then in the “while” loop we will read the rest of the data in the serial port, and that’s the messaged typed in the text box of the Android app. In case the indication variable is “2”, that means we have changed the position of the scrolling speed slider, so we will read its new value using the Bluetooth.readString() function and adjust the scrolling speed. In the same way we adjust the brightness of the LEDs. You can download the app from the following link: https://drive.google.com/open?id=1xvR_tyTF-zzdrqc6RrdHlcD5FRICIbs5 Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of Sound sensor with Arduino Uno.
Back Interfacing of Sound sensor with Arduino Uno. What is a Sound Sensor? The Sound Sensor Module provides an easy way to detect sound and is generally used for detecting sound Intensity. This Module can be used Security, Switch and Monitoring applications. Its accuracy can be easily Adjusted for the convenience of the usage. It uses a Microphone which supplies the input to an amplifier, peak detector and buffer. When a Sensor detects a sound , it processes an output signal voltage which is sent to microprocessor , and performs further processing. Material Required: Material Quantity Arduino Uno 1 Sound Sensor 1 Jumper cables 5 Resistor 1(1k ohm) Pinout Diagram: Circuit Diagram: Parameter Value VCC 5 V DC from your Arduino Ground GND from your Arduino Out Connect to Digital Input Pin Tested Programming Code: //Arduino Sound Detection Sensor Module int soundDetectedPin = 10; // Use Pin 10 as our Input int soundDetectedVal = HIGH; // This is where we record our Sound Measurement boolean bAlarm = false; unsigned long lastSoundDetectTime; // Record the time that we measured a sound int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high void setup () { Serial.begin(9600); pinMode (soundDetectedPin, INPUT) ; // input from the Sound Detection Module } void loop () { soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time if (soundDetectedVal == LOW) // If we hear a sound { lastSoundDetectTime = millis(); // record the time of the sound alarm // The following is so you don't scroll on the output screen if (!bAlarm){ Serial.println("LOUD, LOUD"); bAlarm = true; } } else { if( (millis()-lastSoundDetectTime) > soundAlarmTime && bAlarm){ Serial.println("quiet"); bAlarm = false; } } } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of Sound Sensor for correctworking. 5. Don’t lose hope if Sound Sensor does not run properly for the first time, try again. Conclusion: Once your sketch is running, you will want to open your serial monitor. Make some loud noises and and view the results Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of RFID Module with Arduino Uno.
Back Interfacing of RFID Module with Arduino Uno. What is RFID? Radio-Frequency Identification ( RFID ) is the use of radio waves to read and capture information stored on a tag attached to an object. A tag can be read from up to several feet away and does not need to be within direct line-of-sight of the reader to be tracked. Material Required: Material Quantity Arduino Uno 1 Rfid module 1 Jumper cables 8 Pinout Diagram: Circuit Diagram: Connect the RFID module with Arduino as follows: GND pin of RFID module to GND of Arduino VCC pin of RFID module to 5V of Arduino SDA pin of RFID module to digital pin 10 of Arduino SCK pin of RFID module to digital pin 13 of Arduino. MOSI pin of RFID module to digital pin 11 of Arduino. MISO pin of RFID module to digital pin 12 of Arduino. RST pin of RFID module to digital pin 9 of Arduino. IRQ pin of RFID module is not connected Download RFID Library We need to download the library for RFID. Go to sketch >> include library >> window open >> go to search bar and type <> you see a link >> click on that link and install. Tested Programming Code: #include #include #define RST_PIN 9 #define SS_PIN 10 MFRC522 rfid(SS_PIN, RST_PIN); MFRC522::MIFARE_Key key; void setup() { Serial.begin(9600); SPI.begin(); rfid.PCD_Init(); } void loop() { if( ! rfid.PICC_IsNewCardPresent()||! rfid.PICC_ReadCardSerial()) { return; } MFRC522::PICC_TypepiccType = rfid.PICC_GetType(rfid.uid.sak); String sd = ""; for (byte i = 0; i < 4; i++) { sd += (rfid.uid.uidByte[i] < 0x10 ? "0" : "") + String(rfid.uid.uidByte[i], HEX) + (i!=3 ? ":" : ""); } sd.toUpperCase(); Serial.print("Tap card key: "); Serial.println(sd); rfid.PICC_HaltA (); rfid.PCD_StopCrypto1 (); } Precautions: Double check the connections before powering on the circuit. Don’t use loose jumper cables. Check whether proper board is selected from Arduino IDE. Ensure proper placement of RFID module Sensor for correct working. Conclusion: Once your sketch is running, you have open serial monitor and then put your RFID tag on RFID module. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of LDR Sensor Module with Arduino Uno.
Back Interfacing of LDR Sensor Module with Arduino Uno. What is a LDR Sensor Module ? LDR sensor module is used to detect the intensity of light. It is associated with both analog output pin and digital output pin labelled as AO and DO respectively on the board. When there is light, the resistance of LDR will become low according to the intensity of light. The greater the intensity of light, the lower the resistance of LDR. The sensor has a potentiometer knob that can be adjusted to change the sensitivity of LDR towards light. Material Required: Material Quantity Arduino Uno 1 LDR Sensor Module 1 Jumper cables 4 Pinout Diagram: Circuit Diagram: Parameter Value VCC 5 V DC from your Arduino Ground GND from your Arduino A0 Connect to Analog Pin A0 Tested Programming Code: int sensorPin = A0; // select the input pin for LDR int sensorValue = 0; // variable to store the value coming from the sensor void setup() { Serial.begin(9600); //sets serial port for communication } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor Serial.println(sensorValue); //prints the values coming from the sensor on the screen delay(100); } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of LDR Sensor Module for correct working. 5. Don’t lose hope if LDR Sensor Module does not run properly for the first time, try again. Conclusion: Once your sketch is running, you have to open your serial monitor to check the readings. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Interfacing of Buzzer with Arduino Uno.
Back Interfacing of Buzzer with Arduino Uno. What is a Buzzer? Buzzers are used for making beep alarms and tones. They can be used in alarm systems, for keypad feedback, or some games. Lightweight, simple construction and low price make it usable in various applications like car/truck reversing indicators, computers, call bells etc. Material Required: Material Quantity Arduino Uno 1 Buzzer 1 Jumper cables 5 Resistor 1(100 ohms) Pinout Diagram: Circuit Diagram: The Connections are pretty simple: Connect the Supply wire (RED) of the buzzer to the Digital Pin 9 of the Arduino through a 100-ohm resistor. Connect the Ground wire (BLACK) of the buzzer to any Ground Pin on the Arduino. Tested Programming Code: This code is to generate an alarm type of sound. The tone is an Arduino Library to produce a square wave of the specified frequency (and 50% duty cycle) on any Arduino pin. const int buzzerPin = 9; void setup() { Serial.begin(8600); pinMode(buzzerPin, OUTPUT); void loop() { tone(buzzerPin, 50); delay(50); noTone(buzzerPin); delay(100); } } Precautions: 1. Double-check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of Buzzer for correct working. 5. Don’t lose hope if Buzzer does not run properly for the first time, try again. Conclusion: You can Use Buzzer as an Alarm and many Other Alerting Devices . Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Analog Joystick Interfacing with Arduino UNO.
Back Analog Joystick Interfacing with Arduino UNO. What is an Analog Joystick ? Analog joystick produces two voltages; one corresponding to position with respect to X-axis and another corresponding to the position with respect to Y-axis. The voltages produced depend on the position of the joystick. The Analog Joystick is similar to two potentiometers connected together, one for the vertical movement (Y-axis) and other for the horizontal movement (X-axis). The joystick also comes with a Select switch . It can be very handy for retro gaming, robot control or RC cars. Material Required: Material Quantity Arduino Uno 1 Analog Joystick 1 Jumper cables 5 Pinout Diagram: We need 5 connections to the joystick. The connection are : SW( Switch), Y, X, Voltage and Ground. “Y and X” are Analog and “Switch” is Digital. If you don’t need the switch then you can use only 4 pins. Circuit Diagram: This is circuit diagram of Analog Joystick module in Arduino. There five pins in analog Joystick Module VCC, GND, SW, X, and Y. X and Y are Analog pins and SW is digital. Key will be used when Joystick is pressed. Connect VCC of the module to +5v of Arduino and GND of the module to Arduino Ground. Now, connect X to Analog pin A0 and Y to Analog pin A1 of Arduino.. Tested Programming Code: This is code for interfacing analog Joystick Module in Arduino. First initialized the pin numbers of Joystick Module. In setup, the Serial Monitor is started at 9600 Baud and initialized Joystick pins as input. In the loop, read the button state and stored in a variable. Print the values to the Serial Monitor. const int joystick_x_pin = A2; const int joystick_y_pin = A1; void setup() { Serial.begin(9600); /* Define baud rate for serial communication */ } void loop() { int x_adc_val, y_adc_val; float x_volt, y_volt; x_adc_val = analogRead(joystick_x_pin); y_adc_val = analogRead(joystick_y_pin); x_volt = ( ( x_adc_val * 5.0 ) / 1023 ); /*Convert digital value to voltage */ y_volt = ( ( y_adc_val * 5.0 ) / 1023 ); /*Convert digital value to voltage */ Serial.print("X_Voltage = "); Serial.print(x_volt); Serial.print("\t"); Serial.print("Y_Voltage = "); Serial.println(y_volt); delay(100); } Checking Values on Serial Monitor: After Uploading The program Successfully into the Arduino Board , we Can Check the Values of X and Y Serial Monitor The Image of the Serial monitor Is shown Below : Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Connect the Wiper pin of potentiometer correctly. 6. Don’t lose hope if Joystick does not runs properly for the first time, try again. Conclusion: You can successfully display data on a the Serial Monitor of the Joystick in simplest way using Arduino. Many forms of data can be displayed on this display, whether it can be a data from sensor or anything else. Reference URL GET IN TOUCH We'd love to hear from you Contact Us
- Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38)
Back Measuring soil moisture using Soil Moisture Sensor with Arduino (Y-38) What is a Soil Moisture Sensor? This sensor measures the volumetric content of water inside the soil and gives us the moisture level as output. The sensor is equipped with both analog and digital output, so it can be used in both analog and digital mode. So let’s begin our tutorial on interfacing Arduino and Soil moisture sensor. Specifications: Input Voltage : 3.3– 5V Output Voltage : 4.2V Input Current : 35mA Output Signal : Both Analog and Digital Material Required: Material Quantity Arduino Uno 1 Soil Moisture Sensor 1 Jumper cables 5 Pinout Diagram: The soil Moisture sensor YL-38has four pins VCC: For power A0: Analog output D0: Digital output GND: Ground The Module also contains a potentiometer which will set the threshold value and then this threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value. Working: 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. This sensor can be connected in two modes; Analog mode and digital mode. First, we will connect it in Analog mode, and then we will use it in Digital mode. Analog Mode – Interfacing Soil Moisture Sensor and Arduino' To connect the sensor in the analog mode, we will need to use the analog output of the sensor. When taking the analog output from the soil moisture sensor FC-28, the sensor gives us the value from 0-1023. The moisture is measured in percentage, so we will map these values from 0 -to 100, and then we will show these values on the serial monitor. You can further set different ranges of the moisture values and turn on or off the water pump according to it. Circuit Diagram: The connections for connecting the soil moisture sensoYL-38 to the Arduino are as follows. VCC of YL-38 to 5V of Arduino GND of YL-38 to GND of Arduino A0 of YL-38 to A0 of Arduino Tested Programming Code: const int soil_sensor = A0; sensor is attached to int sensorValue = 0; void setup() { Serial.begin(9600); } void loop() { sensorValue = analogRead(soil_sensor); serial monitor: Serial.print("Moisture Value = " ); Serial.println(sensorValue); delay(1000); } Digital Mode – Interfacing Arduino and Soil Moisture Sensor To connect the soil moisture sensor YL-38 in the digital mode, we will connect the digital output of the sensor to the digital pin of the Arduino. The Sensor module contains a potentiometer with it, which is used to set the threshold value. This threshold value is then compared with the sensor output value using the LM393 comparator which is placed on the sensor module. The LM393 comparator will compare the sensor output value and the threshold value and then gives us the output through the digital pin. When the sensor value will be greater than the threshold value, then the digital pin will give us 5V and the LED on the sensor will light up and when the sensor value will be less than this threshold value, then the digital pin will give us 0V and the light will go down. Circuit Diagram: The connections for connecting the soil moisture sensor YL-38 to the Arduino in digital mode are as follows. · VCC of YL-38 to 5V of Arduino · GND of YL-38 to GND of Arduino · D0 of YL-38 to pin 12 of Arduino · LED positive to pin 13 of Arduino · LED negative to GND of Arduino Tested Programming Code int led_pin =13; int sensor_pin =8; void setup() { pinMode(led_pin, OUTPUT); pinMode(sensor_pin, INPUT); } void loop() { if(digitalRead(sensor_pin) == HIGH) { digitalWrite(led_pin, HIGH); } else { digitalWrite(led_pin, LOW); delay(1000); } } Precautions: 1. Double check the connections before powering on the circuit. 2. Don’t use loose jumper cables. 3. Check whether the proper board is selected from Arduino IDE. 4. Ensure proper placement of sensor for correct working. 5. Please keep your hardware away from water except, the sensing probe. Conclusion: You can successfully measure the moisture percentage in the soil and control the appropriate flow of water. This sensor can be deployed in many ways like auto irrigation systems, automatic plant watering systems etc. Output: Situation Screenshot: Serial Monitor (Ctrl+Shift+M) Reference URL GET IN TOUCH We'd love to hear from you Contact Us