MKRFOX1200 with a magnetic sensor (Sigfox)

Hey,

It is my first time using an Arduino and I am following a project to work with a magnetic sensor. The purpose is that I receive a Sigfox message when the door is opened (magnets away from each other) and when the door is closed (magnets together).

This is the project I'm following:

The problem is: I only receive a message when I open the door, not when the door is closed. Does anybody know how to change the code so that it will work in both ways?

Thank you in advance!

This the code (you can find it also on the website):

#include <SigFox.h>
#include <ArduinoLowPower.h>

volatile int alarm_source = 0;

void setup() {
if (!SigFox.begin()) {
//something is really wrong, try rebooting
reboot();
}
//Send module to standby until we need to send a message
SigFox.end();
pinMode(0, INPUT_PULLUP);
LowPower.attachInterruptWakeup(0, alarmEvent1, RISING);
}

void loop()
{
// Sleep until an event is recognized
LowPower.sleep();
SigFox.begin();
delay(100);
String to_be_sent = “DOOR”;
SigFox.beginPacket();
SigFox.print(to_be_sent);
int ret = SigFox.endPacket();
// shut down module, back to standby
SigFox.end();
}

void alarmEvent1() {
alarm_source = 1;
}

void reboot() {
NVIC_SystemReset();
while (1);
}