-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhackerz_akeru.ino
62 lines (47 loc) · 1.13 KB
/
hackerz_akeru.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* - GPS TX pin is plugged to Akeru pin 0
* - GPS VCC pin is plugged to Akeru pin 3V3
* - GPS GND pin is plugged to Akeru pin GND
*/
#include <SoftwareSerial.h>
#include "TinyGPS.h"
#include "Akeru.h"
Akeru_ akeru;
TinyGPS gps;
struct coord {
float latitude;
float longitude;
};
void setup() {
// LED 13 is used to "debug" sigfox operations
pinMode(13, OUTPUT);
// Initialize sigfox modem
akeru.begin();
// Start serial communication, because everyone needs to !
Serial.begin(115200);
delay(2000);
}
void loop() {
// Get NMEA data
float latitude;
float longitude;
unsigned long fix_age = 9999;
while (fix_age > 1000) {
while(Serial.available()) {
if (gps.encode(Serial.read())) {
gps.f_get_position(&latitude, &longitude, &fix_age);
}
Serial.flush();
}
}
// Some debug can't be harmful
Serial.println(latitude);
Serial.println(longitude);
Serial.println(fix_age);
coord coordinates = {latitude, longitude};
// Send data to Sigfox network
digitalWrite(13, HIGH);
akeru.send(&coordinates, sizeof(coord));
digitalWrite(13, LOW);
delay(1000);
}