I would like to use two HC-SR04P ultrasonic sensors for the upcoming project. My question is how to connect both of them to work properly simultaneously. @martin.grames used one connected to port eight (P8) and P9, but where to connect another one? Is necessary to use some module like sensor module?
Unfortunately, currently only one sensor can be used with the firmware on PINs P8 for Echo and P9 for Trig.
I can edit the firmware during the weekend and then send it as pull request.
Hi,
right now we do not have library for SR04p written in a way, that you could use multiple sensors.
Thanks @martin.grames for your help. I do have only one sensor but I can try to test your updated library.
Martin
Thank you for new driver. I have just a single sensor but I try it soon.
Based on my calculations (please check it, I might be wrong) and the sensor datashett you can get up to 4 meters distance (this sounds great, maybe too optimistic? ). This takes the sound 13 ms to travel 4m, times two
because the sound goes the same distance back is 24 ms. So it can take up to 24ms in the measurement loop. So your 30 ms timeout seems perfect choice.
Now this is for further discussion, but you should disable the IRQ interrupts during measurement, because they can mess your measurement. On the other side disabling interrupts can collide with some other BigClown libraries who depends on EXTI gpio interrupts which you don’t miss, but they will be handled a bit later then planned. So this is needed to be considered and tested further. From our SDK right now I do not recall any library which would have issues with this delay but I might be wrong
How many sensors would you need to have connected at the same time?
Hi @hub.martin.
That’s for your point of view.
For me I only need to measure distance by two sensors.
I’m not sure if @martin.grames need to connect more than one sensor right now.