Using imp005, having pinN as my reset pin, how can I toggle it for a reboot? Let’s say for 500ms?
myReset <- hardware.pinN
Using imp005, having pinN as my reset pin, how can I toggle it for a reboot? Let’s say for 500ms?
myReset <- hardware.pinN
Off the top of my head, something like this:
myReset.configure(DIGITAL_OUT, 0);
. . .
// Toggle reset - set reset pin high
myReset.write(1);
imp.wakeup(0.5, function() {
// Timer fires after 0.5s (500ms) and pulls pin low
myReset.write(0);
});
Generally, as resets are active low, it’d be the other way round (ie replace 0’s with 1’s and vice-versa) but Tony’s suggestion of using a callback to schedule returning the reset line to the inactive state after 0.5s is how you should be doing things on an imp.
Whilst you can do an imp.sleep(0.5), this blocks other execution and prevents power management from minimizing system power consumption, so we don’t advise using imp.sleep for “long” sleeps (personally I try to avoid it for anything over about 50ms).
If you are looking for an external watchdog,
this one is 3.3V low current 25-30uA
If the chip doesn’t get a reset within a selectable timeout period it triggers a reset to your imp. Externally, so the imp could be sleeping or crashed … whatever.
I’ve used this before with an Arduino.
Generally it’s a bad idea to use a short period external watchdog with an imp - eg if the imp is trying to do an OS upgrade, it won’t be able to kick the watchdog and hence it won’t ever be able to take an OS upgrade.
Long period (minutes) ones are usually ok, and some customers have deployed these in the field. However, impOS does have watchdog functionality built in which is usually sufficient (we also reboot on illegal memory accesses etc so even bad brownouts are dealt with)
I never thought of that. OS upgrade … but don’t I have to connect it to my PC? Oh wait, it’s the Imp. I knew there was a good reason for using the Imp.