How to reverse the use case?

Hi,

I have connected 5V and GND to the Rain sensor and connected its analog output to the positive end of the LED and connected LEDs GND to Sensor GND. When I supplied Power the LED turned on(Which should not happen until I drop some water on the sensor) and when I put some water on sensor LED turns OFF.

But I want to create like when There is water on the sensor then only LED should glow not reverse. I don't intend to use any microcontroller. Just sensor power supply and LED. Later I will replace LED with 3V Buzzer. Any Help.

Sorry, it wasn't showing in preview so just pasted the Link and also attached some images.

Below is the image link:

and this:

the Rain sensor

Which rain sensor ?

Please post a schematic of your circuit

Try swapping the + and - wires if it is reversed. For an accurate answer more information is needed, send a schematic, possibly a picture and a parts list. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

connected its analog output to the positive end of the LED and connected LEDs GND to Sensor GND.

You connect the positive end of the LED to 5V and connect the other end of the LED to the sensor's output.

Please ignore what gilshultz said. Normally he supplies just useless advice but this time he has supplied some advice that might damage your sensor, depending on what it is inside. In this case, rather than get you started, his advice might just get your sensor finished for good.

Grumpy_Mike:
You connect the positive end of the LED to 5V and connect the other end of the LED to the sensor's output.

Please ignore what gilshultz said. Normally he supplies just useless advice but this time he has supplied some advice that might damage your sensor, depending on what it is inside. In this case, rather than get you started, his advice might just get your sensor finished for good.

I have edited the post and provided the link to the images. Also attached one. Please see and guide.
I also thought of using the transistor(NPN) as a switch. But it isn't working. I had connected the Analog signal from the Raindrop sensor to the Base of Transistor and Emitter to the GND and collector to the positive of LED.

You have no resistor in series with the LED, this is not optional.

So are you saying what I suggest in reply #3 did not work? If so you either did not implement it correctly or you are missing telling us something vital.

Yes you could use a NPN transistor instead but you still need to implement it correctly. With a transistor you will need a resistor in the base as well as in series with the LED in the collector.

You should measure voltages on the output of your mysterious sensor, that is being kept a big secret. You need at least 0.7V to turn it on and less than this to turn it off.

Please post a schematic of what you tried that didn’t work, along with a photograph so we can see how you wired it.

Grumpy_Mike:
You have no resistor in series with the LED, this is not optional.

Maybe it's one of these?

Edit: if one did use one of those leds-with-resistors-built-in, what would be the best way to show that in a schematic? I'd be inclined to show discrete led and resistor with their normal symbols, then just put a box round them both to show they're in one package.

Grumpy_Mike:
You have no resistor in series with the LED, this is not optional.

So are you saying what I suggest in reply #3 did not work? If so you either did not implement it correctly or you are missing telling us something vital.

Yes, you could use an NPN transistor instead but you still need to implement it correctly. With a transistor, you will need a resistor in the base as well as in series with the LED in the collector.

You should measure voltages on the output of your mysterious sensor, that is being kept a big secret. You need at least 0.7V to turn it on and less than this to turn it off.

Please post a schematic of what you tried that didn’t work, along with a photograph so we can see how you wired it.

I had connected a 100-ohm resistor in series with LED to 5V and the other end of the LED was connected to the Raindrop sensors Analog out. Here is the raindrop sensor: Rain drop Sensor Module Pinout, Datasheet & How to Use it in a Circuit

Then also the LED was continuously on. I am using an RGB 4 PIN LED: https://www.cytron.io/image/cache/catalog/products/DS-LED/RGB%20Defused-0-1-1-800x800.jpg

When I used a BC547B transistor, I connected Analog out of Raindrop sensor with the base of the transistor, connected emitter to the GND and connected LED with 100ohm resistor in series from 5V to collector. Still LED kept glowing continuously but what was happening in the first case like on dropping water it turns off it didn't happen with the transistor.

This is the schematic diagram:https://i.stack.imgur.com/xpD5P.png of my circuit with the transistor.

if one did use one of those leds-with-resistors-built-in, what would be the best way to show that in a schematic? I'd be inclined to show discrete led and resistor with their normal symbols, then just put a box round them both to show they're in one package.

Yes but make it a dotted line. The resistors in those LEDs are a bit low though and as a result the LED takes too much current.

Thanks for the sensor link.

I had connected a 100-ohm resistor in series with LED to 5V and the other end of the LED was connected to the Raindrop sensors Analog out.

A resistor value of 100R is too low, you need something in the 240 to 1K range.
Why are you using the analogue output when the sensor has a digital output?

When I used a BC547B transistor, I connected Analog out of Raindrop sensor with the base of the transistor,

Why? Because as I said:-

"With a transistor you will need a resistor in the base as well as in series with the LED in the collector."

If you are getting more than 0.7V from the analogue output when it is dry then the LED will stay permanently on. If you want to use the analogue output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V.

Then also the LED was continuously on. I am using an RGB 4 PIN LED

If you are using a RGB LED then why was this not shown in the diagram? When you draw a schematic it is supposed to represent what you have, if you start showing what you don't have then how on earth is anybody supposed to give you accurate advice?
So how its this wired up? If you want a white output you need three resistors on that LED. A picture of an LED is about as useful as a chocolate tea pot. You can't tell by looking if it is common anode or common cathode?

I don't know why you are not using the digital output? If you have tried it and it didn't work did you add the pull up resistor shown as R5 on the schematic in the data sheet you linked to? Note the resistor values in that data sheet, they use 1K for the LED's current limiting resistor. If you wire the digital output like the schematic in the data sheet it should work the right way round.

Grumpy_Mike:
Yes but make it a dotted line. The resistors in those LEDs are a bit low though and as a result the LED takes too much current.

Thanks for the sensor link. A resistor value of 100R is too low, you need something in the 240 to 1K range.
Why are you using the analogue output when the sensor has a digital output? Why? Because as I said:-

"With a transistor, you will need a resistor in the base as well as in series with the LED in the collector."

If you are getting more than 0.7V from the analogue output when it is dry then the LED will stay permanently on. If you want to use the analogue output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V.

If you are using an RGB LED then why was this not shown in the diagram? When you draw a schematic it is supposed to represent what you have, if you start showing what you don't have then how on earth is anybody supposed to give you accurate advice?
So how its this wired up? If you want a white output you need three resistors on that LED. A picture of an LED is about as useful as a chocolate teapot. You can't tell by looking if it is the common anode or common cathode?

I don't know why you are not using the digital output? If you have tried it and it didn't work did you add the pull-up resistor shown as R5 on the schematic in the datasheet you linked to? Note the resistor values in that datasheet, they use 1K for the LED's current limiting resistor. If you wire the digital output like the schematic in the datasheet it should work the right way round.

It's my fault I know and I am sorry. And also the circuit diagram you are saying this:


Is the circuit of the module which comes with the sensor as you can see in the link the blue module. I am right now going to measure the output response with a multimeter and check its behaviour. If I am getting a response in digital output I will try something to make it usable. As I have tried using it but there was no activity in LED. So I didn't use it. As you said I am going to use a 1K resistor to check the working.

Grumpy_Mike:
Yes but make it a dotted line. The resistors in those LEDs are a bit low though and as a result, the LED takes too much current.

Thanks for the sensor link. A resistor value of 100R is too low, you need something in the 240 to 1K range.
Why are you using the analogue output when the sensor has a digital output? Why? Because as I said:-

"With a transistor, you will need a resistor in the base as well as in series with the LED in the collector."

If you are getting more than 0.7V from the analogue output when it is dry then the LED will stay permanently on. If you want to use the analogue output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V.

If you are using an RGB LED then why was this not shown in the diagram? When you draw a schematic it is supposed to represent what you have, if you start showing what you don't have then how on earth is anybody supposed to give you accurate advice?
So how its this wired up? If you want a white output you need three resistors on that LED. A picture of an LED is about as useful as a chocolate teapot. You can't tell by looking if it is the common anode or common cathode?

I don't know why you are not using the digital output? If you have tried it and it didn't work did you add the pull-up resistor shown as R5 on the schematic in the datasheet you linked to? Note the resistor values in that datasheet, they use 1K for the LED's current limiting resistor. If you wire the digital output like the schematic in the datasheet it should work the right way round.

I checked the voltage output from the Analog pin of the sensor and it is 4.99~5V and when I drop water on the sensor the voltage drops to 0.10-0.12V. I then checked the voltage on the digital pin it was 0.10-0.12V with and without water on the sensor. I was not able to check current because my multimeter is broken and it just checks voltage, resistance, and connectivity. I tried using a 200ohm resistor at the base and the LED side still not effective and I tried using the resistor of 1K still same for analog output pin.

As you said, "f you want to use the analog output then you will have to measure the range of voltages you get out, and arrange a potential divider to cut down the output produces a voltage between zero and 1.4V giving you a threshold of 0.7V."

I have to create this and it will add more components to the application and I wanted to create with a limited component as possible.

Can you please explain to me how can I get that Digital output to turn on and off at least an LED?

I have connected the digital output pin to the cathode of LED(Now I am using a simple LED) and connected LEDs anode to the ground and I used a 200-ohm resistor and also replaced it will 1K. And supplied 5V and GND to the sensor. There was no changes in LED it was turned off. I even dropped water on the sensor still turned off. I tried the same with the transistor.

Grumpy_Mike:
Yes but make it a dotted line. The resistors in those LEDs are a bit low though and as a result the LED takes too much current.

Willco, and noted; thanks.

I then checked the voltage on the digital pin it was 0.10-0.12V with and without water on the sensor.

That is because you did not have a pull up resistor. The comparators used on that sensor have, what is called, an open collector output. That means it will not source current only sink it. In other words it pulls down only. That is it acts like a switch to ground.

You can connect an LED and series resistor direct to this output providing you connect the anode end of the LED to 5V. I believe if you do this it will work the way round you want it to.

Grumpy_Mike:
That is because you did not have a pull up resistor. The comparators used on that sensor have, what is called, an open collector output. That means it will not source current only sink it. In other words it pulls down only. That is it acts like a switch to ground.

You can connect an LED and series resistor direct to this output providing you connect the anode end of the LED to 5V. I believe if you do this it will work the way round you want it to.

Okay, you said I connected positive pin of LED to 5V and its GND to a 200-ohm resistor to Digital pin of sensor. It's again like before LED is ON and doesn't do anything with or without water on the sensor.

Here is the links to the image of circuits:

Lucifer22334:
I was not able to check current because my multimeter is broken and it just checks voltage, resistance, and connectivity.

You may want to fix your multimeter: it's usually only a blown fuse...
:slight_smile:

Okay, you said I connected positive pin of LED to 5V and its GND to a 200-ohm resistor to Digital pin of sensor.

Yes.

It's again like before LED is ON and doesn't do anything with or without water on the sensor

Then you have broken the sensor.

Grumpy_Mike:
Yes.
Then you have broken the sensor.

Okay...I will order another one and it will take time to get delivered. In meantime do you have any interesting project ideas that I can work on which will help me improve Arduino coding skills (I am currently at no level)?

When you get the new one remember to use at least a 470R resistor with the LED, I think the small values you were using were the cause of your problems.

ideas that I can work on which will help me improve Arduino coding skills

You can go through the basic examples in the IDE, or get one of many project books like this one
Earth Shine project book PDF

Grumpy_Mike:
When you get the new one to remember to use at least a 470R resistor with the LED, I think the small values you were using were the cause of your problems.
You can go through the basic examples in the IDE, or get one of many project books like this one
Earth Shine project book PDF

will do and let you know. Okay in the mean time I will go through the book and after completion go for another one.

You might want to look at:-
http://www.ladyada.net/learn/arduino/
and

And the official Arduino book
Arduino CC pdf