letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.3k stars 2.22k forks source link

Devices Position - HC-SR04 (2020) i2c #4489

Open AlexUmnikov opened 1 year ago

AlexUmnikov commented 1 year ago

Greetings. Now on sale there is a Position module - HC-SR04 (2020) that works not only GPIO but also UART and IIC (port 0x57) In the assembly for ESP8266, I found it only for working with GPIO. Is there a build to work with HC-SR04 with I2C?

TD-er commented 1 year ago

Nope, not yet. But do you have a link to the module?

Edit: Is it this one?

AlexUmnikov commented 1 year ago

Here is a discussion of how it works. https://forum.arduino.ua/viewtopic.php?id=2428 Still it goes like V2 What I understood - everything is the same as in V1 GPIO, only the command is sent and the response is read via I2C I have now soldered the resistor. Got address 0x57

TD-er commented 1 year ago

And where to buy them? You mentioned they were on sale. I looked for it at the usual sites, but nowhere they mention anything regarding a "2020" version.

AlexUmnikov commented 1 year ago

(I don't like ads), bought here https://aliexpress.ru/item/32477198302.html?spm=a2g2w.orderdetail.0.0.66304aa6c34yNT&sku_id=12000024554661973 Here's another, but expensive https://www.sgbotic.com/index.php?dispatch=products.view&product_id=3028 If you look at the reviews, there are two options, old and new. The difference is in the availability of places for soldering resistors and the inscription 2020 on the reverse side.

TD-er commented 1 year ago

Looks like this is a library for those: https://github.com/SGBotic/SGBotic_I2CPing/blob/master/SGBotic_I2CPing.cpp Not sure how the 3rd byte is being handled in that example as most of the resolution is thrown away by handling it as an integer and the entire value is divided by 10'000.

AlexUmnikov commented 1 year ago

Yes, it is, but how to insert it into espeasy? As I understand it, in Rules there is no way to work with i2c, only with GPIO. And the datasheet says: distance = ((byte_h << 16) + (byte_m << 8) +byte_l)/1000 And it's in mm