Portenta | PIR sensor not working when LoRa connected

Hi, I am using Arduino Portenta H7 with its LoRa Vision Shield. I have connected a PIR sensor to D3 pin and simply defined it as follows:

pir = pyb.Pin("D3", pyb.Pin.IN)

I’ve tested the sensor independently and it works perfectly. However, when I attempt to connect to a LoRa gateway, the sensor stops working irrespective of the connection status. I’m doing something like this:

import Lora, pyb

pir = pyb.Pin("D3", pyb.Pin.IN)

lora = Lora(band=BAND, poll_ms=60000, debug=False)
lora.join_OTAA(JOIN_EUI, APP_KEY, timeout=10000)

while(True):
    print(pir.value())

Can someone help me understand why this is happening?

Regards,
PC

Hi, D3 is used by the Arduino Portena Lora Shield as it’s BOOT0 pin. So, it would be overridden.

D0 is not in use by the Lora shield. You could use that instead. Otherwise, you need to check the schematics for the lora shield and portenta to determine what pins connect to what and which are free. You can call a pin name directly in MicroPython using it’s CPU name (D0 == PH15).

Hi, @kwagyeman, I am already using D0 for another sensor so am looking at other pins for options.

I tried connecting to D5 (PC6) after confirming with the doc that the pin’s not used by the LoRa module yet experiencing similar issues. This time when LoRa is in use, the PIR sensor value is always HIGH.

PC

Update: When I use D1 or D6 for the PIR sensor, I get RuntimeError: Sensor control failed errors.

I’ve experienced this in the past as well, but then I had other GPIO pins free so simply didn’t bother with it. I had to reinstall the firmware though each time.

PC

Hi, you can just erase the flash disk if you install a main.py script that locks the board up.

Anyway:

Pins:

PWM6->PH15
PWM7->PJ7
PWM8->PJ10
PWM9->PH6
GPIO6->PG10

Are free. I’d avoid using the D* pins as they aren’t in the schematics as names. Note that the mapping is here: micropython/ports/stm32/boards/ARDUINO_PORTENTA_H7/pins.csv at 3f421121f22cc5404d1d282d6a3fcc52323d9ba1 · openmv/micropython

Hi again,

Sorry this question might sound very stupid but I’m a little puzzled. How can I connect anything to the PWM7/PJ7 pin when it’s a part of HDC? Shouldn’t I have to connect the (here, PIR) sensor to the pin before programmatically defining?

Is there an official tutorial on such basics BTW?

PC

Is there an official tutorial on such basics BTW?

That would be up to Arduino to create. We provide a working firmware port for the Portenta of our software ontop of MicroPython.

If you’d like to be able to figure out which pins are free the best way to do this is to download the schematics which Arduino provides for the Vision Shield and the Portenta and then to follow the empty connections back to the Portenta CPU to determine the free processor pins.

This is somewhat of a giant pain.

However, you’ll want to do this to figure out which pins are free. Yes, Arduino could make this process easier if they updated their pinout diagrams to show which pins a shield used on the Portenta like we do for our shields for the OpenMV Cam.

Regarding more free pins… trace the non-PWM ones which may have some free:

The ones I posted about above being free I traced from looking at the vision shield and then mapping back to the Portena schematic.

1 Like