Library suitable for Raspberry Pi Pico. #1
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
bjoern/HC_SR04#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hey,
I'm trying to include your library in my project. The PlatformIO catalog states that the library can also be used for Raspberry Pi Pico. Is that correct? I have problems there. I tried the simple_async-ino example
Thanks
Hey,
Actually I never tried it with an Pico, but I don't see a reason why it shouldn't work.
Could you explain a little bit more why it doesn't work, or what kind of problems you see?
Are you able to compile?
Is the synchron version "simble.ino" working?
Couly you also let me know how the sensor is connected (which pins etc.)?
Hey, thanks for your quick reply and your interest.
I can compile the code. But the result is 0.
[image: image.png]
sensor.isFinished is probably true
Am So., 29. Jan. 2023 um 14:25 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
The example "simple.ino" returns only 0.
Am Mo., 30. Jan. 2023 um 13:57 Uhr schrieb Wilhelm Kuckelsberg <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
[image: image.png]
Am Mo., 30. Jan. 2023 um 14:02 Uhr schrieb Wilhelm Kuckelsberg <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Could you provide some information how its wired?
Could also be an electrical issue.
I'm a bit unsure now. Your library works fine on an Arduino MEGA2560.
The picture shows my circuit board (self-made).
[image: IMG_0228.JPG]
I also tried using a different library. Also no success.
I checked the wiring several times.
Trigger on PIN 29
Echo PIN 27
The Pico and the sensor are supplied with a 5V source.
The purple brick is an IMU. The whole thing is supposed to be a control for
a drone.
I need an interrupt, otherwise the IMU will not work properly.
Am Mo., 30. Jan. 2023 um 14:47 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Unfortunately, I cannot see the image (i just see: [image: IMG_0228.JPG]).
Is it available in your github repository?
I suppose Pin 29 means the pin number on the board, not the GPIO number (which would be 22, while Pin 27 means GPIO 21)?
Is this correct?
Is it possible for you to measure the pins using an oscilloscope?
Without any idea I could imagine that this could be related to the 3.3V which is used by the Pico, while the sensor is using 5V.
How are you powering the sensor and the pico (as mentioned I cannot see your image)?
I’m doing the same with an ESP32 which is also at 3.3V which works fine, but it’s probably not the 100% perfect solution :-) .
Is it available in your github repository? - No
I suppose Pin 29 means the pin number on the board, not the GPIO number
(which would be 22, while Pin 27 means GPIO 21)?
Is this correct? - No 😕 I Idiot, I corrected that, no success.
Is it possible for you to measure the pins using an oscilloscope? - I have
little experience but will try. A friend can help me with this. But only on
weekend.
Unfortunately, I cannot see the image - The pico and HCSR04 with 5V at VSYS.
Can a level shifter be the solution?
Can you see the image now?
Am Di., 31. Jan. 2023 um 09:55 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Can you see the image now?
Unfortunately not, maybe a security setting, but I think its fine, VSYS 5V for pico and sensor, GPIO 22 for Trigger and GPIO21 for Echo, and of course GND is also connected?
Should be fine.
Can a level shifter be the solution?
In case the issue is really related to the 3.3V and 5V difference on the IO's, then yes.
But it should also work without. 5V on the 3.3V shouldn't damage the Pico, and 3.3V for the trigger should be ok for the HC-SR04.
Maybe an electrical experts starts to throw stones at me saying that, but from my experience it should be ok.
But since the synchron version is also not working (which should really not depend on the controller, interrupts etc.) then thats still the only reason I see.
Could be a small issue in wiring, using wrong IO numbers, or the 5V/3.3V problem.
Using google seems most people are using a HC-SR04+ with the pico which runs at 3.3V.
Or a voltage divider with the orignal 5V HC-SR04.
Hallo, habe es jetzt mit einem Level Shifter probiert. Kein Erfolg. Am
Wochenende kommt ein Freund zu mir, der hat Erfahrung mit einem
Oszilloskop.
Werde mich auch weiter im Netz umschauen. Es muss ja an der Pico liegen.
Ich danke Dir vielmals für Deine Geduld. Werde mich melden wenn ich weiter
gekommen bin.
Die Verkabelung ist OK, habe mir eine richtige Platine geätzt. Schade, dass
Du die Bilder nicht sehen kannst, werde mir aber zum Wochenende ein GIT
anlegen.
Am Di., 31. Jan. 2023 um 13:19 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
It's me again. It works. I used your lib again with the mega2560. The
following occurred to me.
If I display the interrupt pin in line 102 (HC_SR04.h), 5 is output. But I
took PIN18 as ECHO_PIN. The same with ECHO_PIN 2. Now interrupt 0 is
displayed.
Can we talk in german?
Am Di., 31. Jan. 2023 um 19:58 Uhr schrieb Wilhelm Kuckelsberg <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Ja deutsch ist kein Problem, denke nur englisch wäre besser, falls jemand anderes ein ähnliches Problem hat und den Verlauf lesen will.
In Zeile 102 steht bei mir nur :"}"
Intern verwende ich die Funktion: "digitalPinToInterrupt(_echo);"
Dann ist es eventuell doch ein Problem mit den Interrupts beim Pico....
Aber Du hattest doch gemeint, das die "Simple" Version auch nicht funktioniert?
Die verwendet keine Interrupts.
Funktioniert es jetzt bei Dir? Und falls ja was hast Du geändert?
I will set up a GIT tomorrow. Then I can better describe the problem with
pictures. Both simple and simple_async work on the Arduino. Not on the
Pico. I'll send you a code snippet later.
Am Do., 2. Feb. 2023 um 10:41 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Arduino MEGA2560 has the following interrupt pins.
2 (Interrupt 0), 3 (Interrupt 1), 18 (Interrupt 5), 19 (Interrupt 4), 20
(Interrupt 3) und 21 (Interrupt 2).
HC_SR04.h
private:
static HC_SR04<TECHO_PIN> *_inst;
void registerInterrupt(int interruptPin)
{
attachInterrupt(interruptPin, HC_SR04::_echo_isr, CHANGE);
Serial.print("interruptPin ");Serial.println(interruptPin);
}
I tried it with Arduino Pin 18, displayed "Interrupt 5". Arduino Pin 2
displayed "Interrupt 0"
Am Do., 2. Feb. 2023 um 15:40 Uhr schrieb Wilhelm Kuckelsberg <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Ok, just bought a PICO (actually a Pico W) and tried it on my side, both works the (synchron and the async version) without any issues and changes.
In your case I would not yet look for interrupts, since the synchron version is not using that at all, so its not related to interrupts.
Here is my setup with pin number which is done as you described:
And as mentioned both works synchron and asynchron.
Maybe you can share the code which tries to use the library?
Hey Björn,
dare not say, but it works. I don't know what caused it. I checked
everything multiple times.
But now I know your library by heart 😊. It could have been the power
supply.
Now I can finally try to combine the IMU and the ultrasonic sensor. That
was the real problem.
To my person. I am 66 years old and retired. I've only been doing this
hobby for 6 years and I really enjoy it. Even when I communicate with
people like you, it's fun. Unfortunately, such stupid mistakes happen to me
when it was the power supply. But also confusing GPIO pin and internal pin
happens to me.
I hope I didn't annoy you too much.
Best regards
William Kuckelsberg
Am Fr., 3. Feb. 2023 um 13:56 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Ja wirklich ein großartiges Hobby, sehr oft liegen solche Probleme an irgendwelchen Kleinigkeiten, die man aber auch erstmal finden muss.
Das ist meine erste Library die ich veröffentlich hatte, und auch das erste mall das ein "Issue" gemeldet wurde, deshalb war ich auch recht motiviert das Problem zu finden.
Freut mich auf jeden Fall das es jetzt alles funktioniert (zumindest mit der LIbrary) 😊
Viel Erfolg mit dem Projekt!
Hallo Björn,
wie angedroht mein Repository mit den Bildern. Sind etwas groß geworden.
https://github.com/kuckyder2te/HCR04_test_PICO
Nochmals vielen Danke für Deine Hilfe.
Am Fr., 3. Feb. 2023 um 18:02 Uhr schrieb bjoernboeckle <
@.***>:
--
Mit freundlichen Grüßen
Wilhelm Kuckelsberg
Wow sieht gut aus!
Bin mal auf ein Video des fertigen Projekts gespannt :-)