-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
GrovePi support #510
Comments
Hello @lucavallin there is not yet GrovePi support for Gobot, but it looks like a relatively modest task to add a new i2c Driver for it, and then implement the DigitalReader/DigitalWriter and AnalogReader interfaces. Let me know if I can be of assistance. I have a GrovePi+ around here in the lab somewhere... Thanks! |
Hey @deadprogram! Thanks for your reply: I'd like to give it a shot, just starting with this kind of low level stuff so it'd be good for me to play around with it. However, do you know if there's documentation about the architecture of Gobot? Like, besides adding a dexter driver for the GrovePi, do I need to take care of anything else? |
Started to work on it, however not very clear to me the bigger picture (is this a platform? or a driver?). Anyways, this is it so far: https://github.com/lucavallin/gobot/blob/feature/grovepi-i2c-driver/drivers/i2c/grovepi_driver.go I'm not sure about the read methods in particular... I used to specify a size for the amount of data to read. I don't see support for that in the i2c connection we're using... any suggestions? |
Hi @lucavallin I think the functions you are looking for are I would expect your implementation of func (d *GrovePiDriver) AnalogRead(pin string) (value int, err error) {
nPin, err := strconv.Atoi(pin)
if err != nil {
return 0, err
}
if _, err = d.connection.Write([]byte{CommandReadAnalog, nPin, 0, 0}); err != nil {
return
}
time.Sleep(100 * time.Millisecond)
if _, err = d.connection.Write([]byte{1, 1}); err != nil {
return
}
val := make([]byte, 4)
_, err = d.connection.Read(val)
if err != nil {
return
}
return ((int(val[1]) << 8) | int(val[2])), nil
} |
I see, looks good, that should be enough for me to go on with it.
Thank you! |
The only reason for the mapping to "int" is that is seems like that is what is expected by the GrovePi's i2c interface. That, along with the bitshifting, I copied from the @DexterInd repo here https://github.com/DexterInd/GrovePi/blob/master/Software/Go/grovepi/grovepi.go#L67 Also, looks like a 0x1 needs to be written as the first byte in any command sent to the GrovePi. Which means that the code above should actually be changed to this: if _, err = d.connection.Write([]byte{1, CommandReadAnalog, nPin, 0, 0}); err != nil {
return
} I have not found my GrovePi yet, so I have not been able to test it out myself. |
Thanks again! Tonight I will play around with it a bit more :) |
Update: I've successfully implemented DigitalWrite. Now I can turn on my leds... |
The DHTXX is a pulse based device, similar to some ultrasonic range finders. There is in fact already an issue discussing this #361 The "best" solution is probably to use some edge-detection/epoll type solution. Some ongoing work in this area within Gobot, but still as of yet not released anywhere. |
Alright, thanks. Not directly related but good for the record: https://www.dexterindustries.com/GrovePi/programming/grovepi-protocol-adding-custom-sensors/ |
Update: I just ordered a digital sensor from which I can read from, with this I should be able to add the digitalRead part |
Hi @lucavallin any chance of still getting a PR for this? |
Hi @deadprogram, need to check what I have left. I remember I had the digitalwrite working but no tests, then I moved to arduino because it's just simpler to work with. Will check asap. |
@deadprogram No luck so far, I don't think I'll be submitting a PR any soon, sorry! |
Thanks for the update, @lucavallin |
Hi @lucavallin I've just merged into the https://github.com/hybridgroup/gobot/blob/dev/drivers/i2c/grovepi_driver.go It implements the https://github.com/hybridgroup/gobot/blob/dev/examples/raspi_grove_pi_button.go Should be useful for anyone with the @DexterInd hardware. I will have to acquire a GrovePi Zero to test if that also works in the same way. |
Hi @deadprogram, that's awesome news! I will take another look at it so I can see what I was missing, maybe I can help maintaining too or something... Thanks!!! |
Hi @deadprogram, just got back from my holidays, the driver works nicely, approved! |
This was just release as part of v1.12.0 thank you. Now closing. |
Hello, I tried to make Gobot work with my GrovePi (https://www.dexterindustries.com/grovepi/) but no success. I can't actually understand whether this is supported at all. So, is it?
Or should I add a new adapter to use this?
This is how I currently interact with the GrovePi without Gobot: https://github.com/lucavallin/hytta-pi/blob/master/cmd/hytta/main.go
The text was updated successfully, but these errors were encountered: