SR-04 problem - Distance: 0

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mkotek
Normal user
Posts: 116
Joined: 15 Dec 2015, 10:58
Location: Lomianki, Poland
Contact:

SR-04 problem - Distance: 0

#1 Post by mkotek » 27 Dec 2015, 21:19

I am still trying to put together SR04 and ESP Easy. I have decided to open a new topic, because I have not received any response while posting on the other one, yet I have no idea what to try.

I have SR04 working fine with Arduino, but trying to put it to work with ESP (R39, R48, R52, R57) is a total failure.

I have created the setup involving the following connections: SR04 VCC and GND on a separate power of 5V, with GND connected to my ESP-12E (via level shifter). Trig is connected to GPIO 16, while Echo to GPIO 14. Both, and GND (both from +5 and from ESP) is connected via level shifter. VCC is not connected to level shifter of course. I have also tried alternative connection I have found, via 1K resistor (on Echo pin only) and tried a second SR04 I have purchased, to make sure, this is not a coincidence. No matter what I configure, I am getting Distance 0. I have tried to change GPIOs, no difference.

Levelshifter I am using: http://www.aliexpress.com/item/Logic-Le ... eb201560_4

On the side, I have a question regarding details: http://www.esp8266.nu/index.php/DistanceSensor - shall it be set to State as Mode (not Value) and is Threshold the max distance measured (it appears only after State is selected)?

Can you please help me troubleshoot and find the problem? What log level shall I put, to see the actual communication from the module (if any)?

UPDATE: I might be not connecting VCC to my level shifter, so this might be a reason why it is not working, but why it is not working when connected with resistor on Echo, just like here: https://github.com/loiphin/ESP8266?
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.

Miki
New user
Posts: 9
Joined: 21 Dec 2015, 13:22

Re: SR-04 problem - Distance: 0

#2 Post by Miki » 28 Dec 2015, 21:28

Hi,

if the mode is set to "State" the SR-04 will only Show 0 or 1.
If the mode ist set to "Value" it will show Centimeters.

But if the "Sensor Delay" ist set to 60, it will update the Centimeters every 60 Seconds.

I´m using a 10k resistor connected on Echo, on my nodemcu Board 1.0

mkotek
Normal user
Posts: 116
Joined: 15 Dec 2015, 10:58
Location: Lomianki, Poland
Contact:

Re: SR-04 problem - Distance: 0

#3 Post by mkotek » 28 Dec 2015, 21:30

The problem is - in Value, I am getting absolutely nothing - 0, no matter how long I wait.
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.

Miki
New user
Posts: 9
Joined: 21 Dec 2015, 13:22

Re: SR-04 problem - Distance: 0

#4 Post by Miki » 28 Dec 2015, 21:42

hmm,

i connected VCC and GND from a 5V Power supply, Trig direct on D5 of my nodmcu and Echo with the 10k resitor on D8.

http://www.esp8266.nu/forum/download/fi ... iew&id=195
Attachments
test.JPG
test.JPG (32.89 KiB) Viewed 8077 times

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: SR-04 problem - Distance: 0

#5 Post by BertB » 30 Dec 2015, 16:42

Did you also enter an ID value in the settings?

mkotek
Normal user
Posts: 116
Joined: 15 Dec 2015, 10:58
Location: Lomianki, Poland
Contact:

[SOLVED] SR-04 problem - Distance: 0

#6 Post by mkotek » 07 Jan 2016, 15:22

BertB wrote:Did you also enter an ID value in the settings?
That was it - for some reason, the values have not been updated, when IDX was set to 0. Even though, the Send Data was unchecked. Now it works as expected. Thank you.
Michal 'Kotek', greetings from Poland. Zapraszam na mój blog o automatyce domowej po polsku: http://www.ukotka.com.

BerndJ
Normal user
Posts: 86
Joined: 28 Sep 2015, 06:57

Re: SR-04 problem - Distance: 0

#7 Post by BerndJ » 13 Jan 2016, 18:51

Hi,

now I get the next HC-SR04 Modules and think we had a buck in the software.

Some ESP-12E Modules show a PullUp Resistor on the second Port (echo Pin).
The HC-SR04 pin is low, I use Voltage Devider 4K7 - 10K to convert the level and get 0.62 Volt on the ESP Port.
If i disconnect my voltage devider then i get full 3.2 V.

Sometimes it´s running, but when it´s falling into these mode, no chance.

Problems are at big distances, the max i get are 40 cm, mostly only 10cm and on long time test.

Any ideas?

Bernd

Post Reply

Who is online

Users browsing this forum: No registered users and 125 guests