Esp8266 + lj18a3

Hi,

I'am using an ESP8266 with a LJ18A3 sensor.
The goal is to integrate it in Home Assistant to get water usage.

It's my first time with ESP. I Connect the LJ18A3 sensor to PIN D6, 3V and G (actually the LED works on 5V but if i connect to 5V, no LED).

So with D6, 3V and G i have a Red led but nothing happens if I approch a magnet or metal near from sensor.
Do you have any idea ?

THanks,

Can't get what you mean with "nothing happens" so please post here the full sketch you used to test the sensor, and if possible a picture of your hardware and wirings including how you're powering everything.

You posted in the section that was only for the Arduino Nano ESP32.
Therefore I have moved it here
All alternative versions of the ESP processor belong here.

Please be more careful where you post in future.

Ok sorry,

For me, when I approch a magnet or metal near from sensor, I expect that the "led flash" but here the LED still red "no flash".

Here some pictures, sorry if that's not you expected...



You totally right, sorry for the inconvenience

Nobody expects the Spanish Inquisit... Uh, no, sorry, that was a Monty Python skit...

Jokes aside, I don't know that sensor, but I think you don't need to connect it to any board to test it, you just need to use a voltage source. As far as I can see, the problem is you're powering it with 3.3V coming from ESP8266 and the label I can see on your picture says 5V, and if it isn't properly powered it can't work good.
Use an external 5V power supply and see if it lights correctly.

When it's ok, you can go on connecting it to the ESP (signal cable to any GPIO, and GND in common with the sensor power supply) and run any test or example sketch available for your sensor.

I meant this label, clearly saying "5V", not 3V:
image

(anyway, always read the datasheets of the devices you want use, if you gave us the direct link to the sensor you have -could you post it here now?- it'd be much easier for you and us...)

PS: not to mention your weird cable colors:
image

You here used a red on the link D6, orange to GND and brown to 3V! YIKES!

It isn't a matter of aestethics, using a good color cable coding helps avoid (often fatal for the devices) mistakes in the future.
Use red for Vcc, black for GND and any other for signals (anyway, common color for signals is yellow).

I'am using : NodeMCU ESP8266 V3
I know, it's write 5V, but when i connect the cable with weird color :wink: the led is not lighting.

Thank you for the advices for cable color.

"Use an external 5V power supply and see if it lights correctly." But how ? I have to strip a power supply to connect it to the sensor ?

It's OK :slight_smile:
Actually i'am usb my usb port from my laptop so, i use Ground and VV GPIO and here we go.

THank you :slight_smile:

Good.
So you can now go on testing it with the ESP, but be always careful about levels (aka always read the datasheet before connecting a new device).

1 Like

PS: to protect the ESP I'd first try adding a 470 Ohm resistor in series and a 3V Zener from the pin and GND, but google around a bit to see what others did with same or similar sensors.

While the sensor says 5V, it also says 300mA.

There is no way you can get a current of 300mA from any arduino pin. You need a driver.

The way sensors like this normally work is that when it is supplied with the correct voltage, on detecting what the sensor is designed to sense then the current from the sensor will change.

You were asked for a schematic and code. You provided some photographs. So you are just feeding us scraps. Some would say you don't want to cooperate, but maybe your skill level needs to be greatly increased before you have the skills needed for you to cooperate.

Hi Grumpy,

I'm a total beginner at this so sorry if you think I don't want to cooperate, that's not the case.
Thank you for your intervention.
The goal is to automate my water consumption, I followed a project on the internet which uses exactly the same components as me. Just the way the ESP was powered changed.
So you are totally right, I have no skills in this area, sorry if it was difficult to deal with me. But the main thing is that it works: my water consumption goes back to my Home Assistant.

So you have code that you are keeping secret, and a tutorial that you are keeping secrete.
So post the links to them at least. Better still post your code and the way you have wired it up.

We can only know what you tell us, and at the moment you are telling us precious little.

Keeping secret, It's a little exaggerated, I'm trying to be concise, excuse me.

Here the link

It is what it feels like from my side of the keyboard.

Thank you for the link to your sensor.

Now how about the code?

Also according to that link you have got your wiring wrong.
This is how it should be:-

Notice on the picture you posted you show you connected the sensor's power to 3V3 and ground, where as you should have used Vin and ground, with D6 being on the other side of the board. Not the same side that your photograph shows.

If I plug it in as in the photo it doesn't work.
I power my ESP via USB, so I connected D6, VUSB and G. And it works perfectly. see picture

If you plan to power it with USB and it works perfectly for your target, we're happy and you can now mark this topic as "closed".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.