Skip to content

Instantly share code, notes, and snippets.

@sourceperl
Last active January 12, 2018 10:35
Show Gist options
  • Save sourceperl/7e26aa0975389ed6e3255e749a676422 to your computer and use it in GitHub Desktop.
Save sourceperl/7e26aa0975389ed6e3255e749a676422 to your computer and use it in GitHub Desktop.
Test of Arduino MKRFox1200
/*
MKRFox1200 Test: send s counter every 15 min
Power with 2 AA battery: under 3.18v, avg current is 1.7 ma
*/
#include <ArduinoLowPower.h>
#include <SigFox.h>
// some vars
uint32_t s = 0;
void setup() {
// init IO
pinMode(LED_BUILTIN, OUTPUT);
// fix wakeup interrupt for use with LowPower.sleep()
LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, {}, CHANGE);
// init Sigfox module
if (!SigFox.begin()) {
reboot();
}
delay(100);
SigFox.end();
}
void loop() {
// second counter
s++;
// process jobs
if (s % 4 == 0 and s < 60)
led_pulse();
if (s % 900 == 0)
sigfox_send();
// sleep for 1s (work with 500...)
LowPower.sleep(500);
}
void led_pulse() {
digitalWrite(LED_BUILTIN, HIGH);
delay(40);
digitalWrite(LED_BUILTIN, LOW);
}
void sigfox_send() {
SigFox.begin();
delay(100);
SigFox.beginPacket();
SigFox.write(s);
int ret = SigFox.endPacket();
SigFox.end();
}
void reboot() {
NVIC_SystemReset();
while (1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment