Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By dubpetr
#65410 Hi, I'm trying to use HC-SR04 ultrasound sensor with ESP8266 Basic. I've found viewtopic.php?f=153&t=11794, but this "analog" approach decrease accuracy on longer distances, which is inacceptable for my application (measuring water level in rainwater reservoir - I need it accurate especially, when water level is low = far away from sensor).
Something like https://www.arduino.cc/en/Reference/pulseIn function would make this goal very easy, since the whole measurement can be done by a few lines of code like https://community.thinger.io/t/esp8266- ... c-sr04/386. (HC-SR04 triggers measurement by at least 10 us long pulse, so using 1ms should not be problem, no "full" driver for HC-SR04 needed.)
I think, PulseIn function may by handy for another applications as well.

BTW: ESP8266 Basic is a great concept - I like the fact, I may change my program "on site" without connecting anything to my computer!
User avatar
By heckler
#65421 dubpetr,

Were I you, (which I am not :D ) I would consider combining the esp8266 module with an external microcontroller. (this is what I do) I would let the esp module do what it does best and let the mocrocontroller handle the rest.

For me the esp module running this GREAT espBASIC is excellent at web page interface and sending emails and providing an easy web interface and sending data to an external web data collection, etc. etc.

But it is not so great (imho) or I have not figured out how to make it great (lack of understanding of esp basic and the underlying OS) at precise timing and interfacing with outside sensors that require precise-ness.

Whereas an external microcontroller running your favorite OS or programming language (like the PIC micro and PICBASIC or >>insert your favorite here<<) is where you can get the preciseness and definite expected results.

So what I have done is to communicate back and forth with the esp module and my PIC micro using serial interface.

This is not to say that this is the only way, it is just what works for me! :mrgreen:

regards
dwight
User avatar
By schufti
#65425 the problem with PulseIn is that the underlying SDK is not realtime and one has no influence or insight how long the SDK will be busy with internal tasks. If such function is not provided via the SDK one would nerver get a reliable result for such short events.
User avatar
By ardhuru
#65440 Thats, a strange co-incidence! I am working on precisely the same application.

Here are my thoughts:

1) Totally agree with Heckler; let a pic do the more time-sensitive tasks.

2) Tried home-made capacitive sensors, gave up for want of good repeatability; not final, though, intend to do some more work as it looks promising.

3) Ultrasonics: read in a number of places that the HC-SR04 start misbehaving after a few days in the damp environment. I guess a Maxbotix sensor like one of these would be ideal https://www.maxbotix.com/Ultrasonic_Sensors.htm?1b8106 , but they're expensive.

4) Car reverse sensors; this seems to be a cheap and reliable way of achieving the goal, if you can live with the limitations. The sensors are robust, and waterproof; the electronics is away from the actual transducer and can be sealed for protection. And, since it is a Tx/Rx transducer, mounting is much easier. The limitations: a) minimum distance of 20 cms; can live with that. b) Maximum distance of 250 cms; not a problem, my tank is less than 2 meters. Resolution in 10's of cms. This, I believe has now changed to 1 cm in the newer models, yet to confirm. The digital output is a kind of Manchester coding that contains distance data for all 4 transducers. I'll be using 2, to monitor 2 tanks. AND, these units are CHEAP! Here in my country, I paid the equivalent of 8 USD for the unit, including 4 transducers.

Regards,

Anand