top of page
Search
Writer's pictureWatchIT Group

Lesson 2 :How to use LDR sensor with Menya IoT Kit.

Updated: Jun 24, 2020

This tutorial is a step-by-step guide that shows how to connect the LDR sensor to Menya Iot Kit to measure light intensity. later we will see how to activate an LED based on light intensity.

1. What is LDR sensor.


What is an LDR (Light Dependent Resistor)? An LDR is a component that has a (variable) resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits.


These resistors are frequently used as light sensors. These resistors are mainly used when there is a need to sense the absence and presence of the light such as burglar alarm circuits, alarm clock, light intensity meters, etc. LDR resistors mainly involves in various electrical and electronic projects.


2. What is Menya IoT Kit.

Menya IoT Kit is a training Kit for Internet of things development skills and embedded technologies it is built with combination of sensors and controllers to facilitate trainees and professionals in STEM to have a direct hands on skills on multiple functions of Internet of Things ecosystem .




The Kit is composed with wireless communications module from Wi-Fi 802 .11 to Bluetooth, and various sensors to enable trainees to easily apply their ideas to real world applications such as controlling Actuators and monitoring status of a given appliance.


3. How to connect LDR to Menya IoT Kit


4. Upload the Sketch to Arduino IDE.


Step 1 : Open the Arduino IDE and put the Sketch.




Step 2 : Select the Type of the board in our case it is Arduino Nano and the Port of the Board.



Step 3 : click on the arrow Upload the Sketch.



After uploading the code , open the Serial Monitor you will able to see values from the sensor LDR.


Result

after opening the Serial Monitor you will see similar values.


this values ranging from 0 -1023 represent or map the presence of light on the sensor , by putting your finger on the sensor (darkness) the resistivity of the sensor will be high and vice versa when you apply light (torch of your mobile phone). do that experiment and observe changes.


you can also view the sensor values with chart line ,go to tools>serial Plotter .




Code to Note


Reads the value from the specified analog pin in this A0. Arduino boards contain a multichannel, 10-bit analog to digital converter (ADC). This means that it will map input voltages between 0 and the operating voltage of 5V into integer values between 0 and 1023.

Syntax

analogRead(pin)


Parameters


pin: the name of the analog input pin to read from (A0 to A7 on Arduino Nano).


analogRead(pinNumber);” pinNumber represents the pins where the analog components is connected on Arduino Nano in our case it is A0.


Note : For any challenge with Menya IoT kit directly post a comment below so that our Team can support you.

If also you are able to Run it Successfully let us know😃.


Thank You guys!!


"You don't need anyone's permission to create something Great"


-Co-Founder of Arduino Massimo Banzi.













300 views6 comments

6 commenti


joenestaishimwe
joenestaishimwe
03 set 2020

there is a small error in the sketch you guys

should correct it.

int analog_pin=A0; void setup() { Serial.begin(9600);// For communicating and access Serial Monitor } void loop() { int Ldr_values=analogRead(analog_pin); // Reading from the analog pin Ao Serial.print("LDR analog Values"); Serial.println(Ldr_values);//print ldr values in the Serial Monitor delay(1000);// one second }

ldr_values that is printed is different with the integer.

Mi piace

evekumutoni
02 giu 2020

can someone help me with this error please. its happening when I'm going to upload the sketch


Arduino: 1.8.12 (Mac OS X), Board: "Arduino Nano, ATmega328P"


Sketch uses 1924 bytes (6%) of program storage space. Maximum is 30720 bytes.

Global variables use 208 bytes (10%) of dynamic memory, leaving 1840 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in…


Mi piace

int analog_pin=A0;

void setup()

{

Serial.begin(9600);

// For communicating and access Serial Monitor

}

void loop()

{

int LDR_values = analogRead(analog_pin);


// Reading from the analog pin Ao


Serial.print("LDR analog Values: ");

Serial.println(LDR_values);


//print ldr values in the Serial Monitor delay(1000);


// one second


}


Mi piace

int analog_pin=A0; void setup() { Serial.begin(9600);

// For communicating and access Serial Monitor } void loop() { int LDR_values = analogRead(analog_pin);

// Reading from the analog pin Ao Serial.print("LDR analog Values: "); Serial.println(LDR_values);

//print ldr values in the Serial Monitor delay(1000);

// one second }

Mi piace

int analog_pin=A0; void setup() { Serial.begin(9600);

// For communicating and access Serial Monitor } void loop() { int LDR_values = analogRead(analog_pin);

// Reading from the analog pin Ao Serial.print("LDR analog Values: "); Serial.println(LDR_values);

//print ldr values in the Serial Monitor delay(1000);

// one second }

Mi piace
Post: Blog2_Post
bottom of page