Arduino Forum

Products => MKR Boards => MKRFOX1200 => Topic started by: pietervannuffel on May 29, 2017, 12:17 pm

Title: Poor localization
Post by: pietervannuffel on May 29, 2017, 12:17 pm
I did some tests with a MKRFOX1200 in Belgium (Antwerp). In a first test I did a tour with my bycicle. In a second test I drove by car between Antwerp and Hasselt. You can find the results of the tests here (https://ask.sigfox.com/questions/2191/poor-localization-in-belgium-mkrfox1200.html). The localization is useless if you want to use it to track a device. Is this due to the Sigfox technologie, the coverage in Belgium, the testplatform (MKRFOX1200) or any other reason? And will this improve?

My code:
/*
  SigFox send message.
*/

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

unsigned long timeBetweenMessages = 10 * 60 * 1000; //wait x (first number) minutes
bool debugViaLedFull = false;
bool debugViaLedSend = true;//false;//
bool debugViaLedSetup = true;
bool sigfoxDebug = true;//false;//
int messageCounter = 0;

void setup() {
  // On MKRFOX1200 the onboard LED is connected to D6
  pinMode(6, OUTPUT);
  // Reset Sigfox module
  SigFox.reset();
  delay(1000);
  // Start the module
  if (!SigFox.begin()) {
    // Something is really wrong, try rebooting
    // Reboot is useful if we are powering the board using an unreliable power source
    // (eg. solar panels or other energy harvesting methods)
    reboot();
  }
  // Wait at least 30mS after first configuration (100mS before)
  delay(100);
  if (sigfoxDebug) SigFox.debug();
  // Shut down module, back to standby
  SigFox.end();
  // Blink when setup is ready
  if (debugViaLedSetup) blinking(100,2);
}

/* Main loop */
void loop() {
  if (debugViaLedFull) blinking(3000,1);
  messageCounter = messageCounter+1;
  String TextToSend = "VNP" + SigFox.ID() +  String(messageCounter);
  sigfoxSend(TextToSend);
  if (sigfoxDebug) {
    delay(timeBetweenMessages);
  } else {
    LowPower.sleep(timeBetweenMessages);
  }
  if (debugViaLedFull) blinking(300,7);
}

/* Funtion to send messages over Sigfox */
void sigfoxSend(String str) {
  if (debugViaLedFull) blinking(300,2);
  // Start the module
  if (!SigFox.begin()) {
    // Something is really wrong, try rebooting
    // Reboot is useful if we are powering the board using an unreliable power source
    // (eg. solar panels or other energy harvesting methods)
    reboot();
  }
  // Wait at least 30mS after first configuration (100mS before)
  delay(100);
  // Clears all pending interrupts
  SigFox.status();
  delay(1);
  if (debugViaLedSend or debugViaLedFull) blinking(300,3);
  SigFox.beginPacket();
  if (debugViaLedFull) blinking(300,4);
  SigFox.print(str);
  if (debugViaLedFull) blinking(300,5);
  int result = SigFox.endPacket(true);
  // shut down module, back to standby
  SigFox.end();
}

/* Funtion to use the onboard LED for debug         */
/* Parameters: - upTime: number of ms the LED is up */
/*             - xTimes: number of blinks           */
void blinking(unsigned long upTime,int xTimes) {
  delay(3000);
  for (int x = 0; x<xTimes; x++) {
    digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(upTime);           // wait for [upTime] ms
    digitalWrite(6, LOW);    // turn the LED off by making the voltage LOW
    delay(upTime);           // wait for [upTime] ms
  }
}

/* Reboot                                           */
void reboot() {
  NVIC_SystemReset();
  while (1) ;
}