Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver for HC-SR04 #865

Closed
Juan1ll0 opened this issue Oct 16, 2022 · 11 comments
Closed

Driver for HC-SR04 #865

Juan1ll0 opened this issue Oct 16, 2022 · 11 comments

Comments

@Juan1ll0
Copy link

Juan1ll0 commented Oct 16, 2022

Hi guys,
I'm writing some code with Gobot for an IOT device that need to measure a water tank level. I'm think that using an HC-SR04 is a good option but i find that Gobot doesn't have support for this sensor. I found library at https://github.com/raspberrypi-go-drivers/hcsr04 that works fine. I know that this sensor can not be used under "firmata" adaptor because of "pulseIn" function is not implemented, but with another adaptor like "raspi" Can I found any solution?. Is any sensor supported by Gobot similar to this?

I'm trying to write a new Gobot Driver adopting code of https://github.com/raspberrypi-go-drivers/hcsr04 to gobot using a "DirectPinDriver" but doesn't work. Can somebody tell me if is posible?

@gen2thomas
Copy link
Collaborator

Like already mentioned, firmata is not best suitable because "pulsIn". I just add some issues as reference:

@gen2thomas
Copy link
Collaborator

Hi @Juan1ll0 , please could you provide your new driver (with an example) by a Draft-PR to dev-branch. So maybe we can find a solution.

@Juan1ll0
Copy link
Author

Hi @Juan1ll0 , please could you provide your new driver (with an example) by a Draft-PR to dev-branch. So maybe we can find a solution.

@Juan1ll0
Copy link
Author

Juan1ll0 commented Oct 21, 2022

Sorry it doesn't work the code only compiles. I try to transform code like structs, pins and similar but it doesn't work. For example the mentioned project used github.com/stianeikeland/go-rpio/v4 and I transform pins to DirectPinDriver gobot implementation and similar things. The code I worte implent the gobot interface Driver like this guide explain https://gobot.io/documentation/guides/adding-hardware-support/ and you can do: hsrc04 := hcsr04.NewHCSR04(raspberry, "17","27") and works perfectly but doesn't give you measurements.

@gen2thomas
Copy link
Collaborator

@Juan1ll0 please create a branch with your code and file a Draft-PR or add the files here (e.g. as zip) and I can do that.

@Juan1ll0
Copy link
Author

OK. I'll do it

@Juan1ll0
Copy link
Author

Juan1ll0 commented Oct 21, 2022

@Juan1ll0 please create a branch with your code and file a Draft-PR or add the files here (e.g. as zip) and I can do that.

You've got at https://github.com/hybridgroup/gobot/pull/872. Sorry about my code but i'm not an experto on go. Than you by your interest.
It fails test sorry but I can't write then yet, it was only a concept test

@gen2thomas
Copy link
Collaborator

Ok, could you please describe:

  • which adaptor do you use and which specific hardware and installed OS/FW
  • how is the setup (e.g. you could provide an example in your PR)
  • what exactly does not work (Do you have a specific error, timeout etc?)

@Juan1ll0
Copy link
Author

Juan1ll0 commented Oct 21, 2022

Ok, could you please describe:

  • which adaptor do you use and which specific hardware and installed OS/FW
  • how is the setup (e.g. you could provide an example in your PR)
  • what exactly does not work (Do you have a specific error, timeout etc?)

I use a raspberry pi 4 with Raspian, with Gobot 1.16 and Go 1.18.

Adaptor: raspi
Setup: On pins 11 for trigger and 13 for echo
Error: Timeout - message: ERRO[0000] impossible to measure distance error="echo not received after 60 milliseconds"

I thought the problem is on function StartDistanceMonitor or in getPinStateChangeTime i will continue investigating.

@gen2thomas
Copy link
Collaborator

@Juan1ll0 please see my remarks in PR.

@gen2thomas gen2thomas added the in work the implementation or bug fix is in work by developers label Nov 19, 2022
@gen2thomas gen2thomas added done on dev the feature or bug is solved on dev branch and wait for merge to release branch and removed in work the implementation or bug fix is in work by developers labels Oct 27, 2023
@gen2thomas
Copy link
Collaborator

available since v2.2.0

@gen2thomas gen2thomas removed the done on dev the feature or bug is solved on dev branch and wait for merge to release branch label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants