Reset Board using the RST Pin in case it gets stuck



  • Dear Pycom-Community,

    at the moment I'm using a GPy as a communication module for my 5V Arduino. The GPy is 3.3V. I'm using Cat m1 with the GPy at the moment and I've experienced stability issues, I just can't fix programmatically (Guru meditation errors and lock-ups of the modem) so I want to reset the GPy through the Arduino, in the case, the GPy doesn't send a ping in a certain timeframe to the arduino.

    According to different posts, I'm not so sure about the internal watchdog of the Pycom-modules:
    [https://forum.pycom.io/topic/4589/external-watchdog?=1601900599657](link url)
    [https://forum.pycom.io/topic/4303/external-watchdog-board-for-pycom/4?
    =1601894304611](link url)
    [https://forum.pycom.io/topic/5198/calling-machine-reset-from-timer-interrupt-routine/7?_=1601894304614](link url)

    As far as I've understood, you have to ground the RST Pin, which is the physical Pin 9 on the GPy: [https://forum.pycom.io/topic/475/reset-pin](link url)

    I've tried it out and grounded the Pin manually and the GPy got reset.

    What would be the best way to use the Arduino to reset the GPy? Personally, I've thought using one digital Pin of the Arduino as an input and the GPy changes the state from High to Low, and Low to High of this Pin frequently. If the Arduino does not recognize a change of state of that Pin in a certain timeframe, it puts the RST Pin of the the GPy low through another digital output pin connected to the RST Pin of the GPy (2 Pins of the Arduino in use, 2 Pins of the GPy in use, while one is the RST Pin of the GPy). It's also gets recommended here: [https://electronics.stackexchange.com/questions/172878/how-do-i-get-my-arduino-to-reset-another-board](link url)

    I could use a logic converter between the 2 boards, so the 5V Arduino can communicate with the 3.3V GPy. I'm not sure, but can I just hook up the RST Pin of the GPy with a digital pin of the Arduino, setting that Arduino pin as digital Output and High and put it Low, in the case the GPy hangs? In the datasheet, a pullup-resistor for the RST Pin is recommended on page 5: [https://www.espressif.com/sites/default/files/documentation/esp32_hardware_design_guidelines_en.pdf](link url)

    But in this thread, somebody said, that the RST Pin is already pulled up for the LoPy so I think, it should be the same for the GPy: [https://forum.pycom.io/topic/475/reset-pin](link url)

    I also kinda would like to reverse that setup. The Arduino watching over the GPy, in the case of a hang up, but the GPy also watching over the Arduino, resetting the Arduino via the Arduino's Reset Pin in the case the Arduino didn't send a measurement string in ages.

    I would be happy about any input. I thank everybody in advance!

    Kind regards,

    SciWax



  • Thank you for the advise. I wish I would be an engineer sometimes.

    Okay, a direct connection between a Digital Pin of a 5V Arduino and the RST Pin of a Pycom board is alright, when you set that Digital Pin of the Arduino as an Input. It's also okay, when you set this Digital Pin of the Arduino as an Output for a short amount of time to make the RST Pin Low, but never set that Digital Pin of the Arduino HIGH or otherwise you get in trouble (the RST Pin wont like that).

    An example code snippet from Arduino Code for pulling the RST Pin LOW, if anybody has the same goal:

    if ((millis() - WDstartMillis >= WDperiod) && barkRec == true) {
      Serial.println(F("Bite! Watchdog reset!"));
      pinMode(RSTGPyPin, OUTPUT);   // sets Pin LOW automatically
      delay(1);
      digitalWrite(RSTGPyPin, LOW); // supposedly not needed
      delay(1);
      pinMode(RSTGPyPin, INPUT); // GPy gains control back
      barkRec = false;
    }
    


  • @SciWax said in Reset Board using the RST Pin in case it gets stuck:

    Am I not doing that already? After powering the Arduino, the Digital Pin connected to the RST Pin directly gets set as an input pin and when I switch it to an output pin for a short time, I never set it HIGH. Your suggestion sounds like the one in this thread: https://arduino.stackexchange.com/questions/67463/reset-nodemcu-master-from-arduino-slave

    If you are doing that already, than there is no risk for either board. It is effectively an open drain mode, which is commonly used e.g. for I2C,



  • @robert-hh said in Reset Board using the RST Pin in case it gets stuck:

    @SciWax There are a few alternative options to deal with it:

    • if possible, configure the Arduino output as Open Drain
    • depending on the type of arduino, you may run it at 3.3V
    • add a diode between the Arduino output and GPy reset, with anode at GPy and Kathode (the pin with the bar) facing to the Arduino.
    • It may also work to first do a digit_write(0), then switch the Pin to output, and then switch it back to input. That way, a high level is never forced to the Arduino output.

    You just have to go for one of these options.

    Thanks for the help again!

    I'm using an Arduino Mega 2560.

    • I think it's not possible to configure a Digital Output of the Mega as Open drain
    • It's a 5V device
    • the suggestion with the diode sounds like a really easy way to implement (Any type of diode you would suggest (Like a type number)? )
    • Am I not doing that already? After powering the Arduino, the Digital Pin connected to the RST Pin directly gets set as an input pin and when I switch it to an output pin for a short time, I never set it HIGH. Your suggestion sounds like the one in this thread: https://arduino.stackexchange.com/questions/67463/reset-nodemcu-master-from-arduino-slave

    As a last alternative, I guess I could just use a logic converter and be done with it to play it safe



  • @SciWax There are a few alternative options to deal with it:

    • if possible, configure the Arduino output as Open Drain
    • depending on the type of arduino, you may run it at 3.3V
    • add a diode between the Arduino output and GPy reset, with anode at GPy and Kathode (the pin with the bar) facing to the Arduino.
    • It may also work to first do a digit_write(0), then switch the Pin to output, and then switch it back to input. That way, a high level is never forced to the Arduino output.

    You just have to go for one of these options.



  • Hi @Gijs ,
    I have a rather concerning question. Resetting the GPy works so far with my Arduino, but I'm kinda concerned. Sorry for bothering you again with it and thanks for the help last time!

    I've researched more about sinking current.

    For my Watchdog Setup, 2 Pins between the Arduino and the GPy are directly connected with each other (Arduino is 5V and GPy 3V3). I'm using Pin 10 on the GPy as an Output Pin toggling it High/Low, which the Arduino can read on a Digital Pin. If the 5V Arduino doesn't detect a pinstate change on its Digital Pin, it sets the Reset Line on the GPy low through another Digital Pin. Because Pin 10 is set as an output pin, it can sink a max of 12 mA according to the datasheet. Now I'm a litte concerned about the RST Pin on the GPy and my connection there with the 5V Arduino.

    Like in your first answer, one Digital Pin of the Arduino is directly and constantely connected with the RST Pin of the GPy. This Arduino Digital Pin is set as an Input till I set it as an Output and pull it low, so I can reset the GPy via it's RST Pin. Now the thing is, that the RST Pin isn't set as an Output so the max sinking current of 12 mA doesn't apply to the RST Pin, right? Only the input leakage current of 50 nA (page 20 in the following document)?

    https://pycom.io/wp-content/uploads/2018/08/gpy-specsheet.pdf

    Wouldn't there flow a constant current into the RST Pin, because a 5V Arduino is connected to a 3V3 MCU, in case the GPy? Would I damage the GPy in the long run?

    My concern came up, after finding the following sources:
    https://forum.arduino.cc/index.php?topic=327812.msg2263820#msg2263820
    https://arduino.stackexchange.com/questions/56798/how-much-voltage-and-current-can-a-arduino-uno-digital-input-sink



  • @Gijs said in Reset Board using the RST Pin in case it gets stuck:

    The other way could work the same, but using a voltage divider. The 3.3V of the Gpy module is already above the HIGH threshold of the ATMEGA IC, not needing any sort of logic level converter per sé

    Yeah, that's true. I forgot about this possibility. So I will place a voltage divider between the RESET Pin of the Arduino and one of the GPy GPIO's, so I don't brick the chosen GPIO on the GPy, because they don't work at the same logic level. Now I just have to calculate, which resistors should be okay.

    Thank you for the adivse!



  • @robert-hh Thank you so much for the input and the github-link! I will surely come back to it, when I only use the GPy itself. In my current project iteration, I have to use an Arduino microcontroller, where the GPy itself is basically only used for sending my measurement data and receiving the time from a ntp server, so that my RTC always shows the right time.



  • @SciWax The reset pin is on the GPY the one next to the Reset button. It is also the physical pin 9 of the ESP32 chip itself. You can pull that one low to trigger a physical reset.
    For that purpose I made an external watchdog based on an Attiny85 which can be freely configured. See: https://github.com/robert-hh/ATTiny-Watchdog-for-MicroPython
    The Attiny can well run at 3.3V- It uses the Arduino environment and includes the drivers for Micropython.



  • @Gijs Thank you for the advise, Gijs!

    Indeed, that's also the conclusion I came to. According to the Arduino Website:

    Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode() when you're using them as inputs.
    Source: Arduino Website

    When I connect a Digital Pin of the Arduino to the RST Pin of the GPy, it will be the input of the RST Pin, so it won't float and won't put out random changes of the pin state. This would be bad.

    I've tested the suggestion in this thread:
    Reset nodemcu from Arduino Slave

    Basically you just have to set your chosen Arduino Digital Pin to Output, where it gets set automatically to Low and then set it back to input, so you give the control back to the GPy RST Pin.

    pinMode(Arduino_Pin, OUTPUT);
    delay(1);
    pinMode(Arduino_Pin, INPUT);
    

    I've just tested it with two 5V Arduinos and it works as expected. I will test it with the GPy too, as soon as I've finished the code for the pings on the GPy.


  • Global Moderator

    Hi,

    To use the arduino as a watchdog for the GPY, you could indeed check the state of a pin as you mention, and when the state is not updated, reset the GPy module. I would use one of the IO pins of the arduino as an pinMode(INPUT), until the GPy needs resetting, then you would set pinMode(OUTPUT); digitalWrite(LOW), pulling the pin low, and thus pulling the reset line low, whilst never putting 5V on the reset line.

    The other way could work the same, but using a voltage divider. The 3.3V of the Gpy module is already above the HIGH threshold of the ATMEGA IC, not needing any sort of logic level converter per sé

    Best,
    Gijs


Log in to reply
 

Pycom on Twitter