Guerrilla Data Collection - guides

The following tutorials are made as teaching material for the Guerrilla Data Collection workshop. Read more about the workshop here:
https://sites.google.com/view/guerrilladatacollection/home

BME280 data to SD-card

BME280 is an environmental sensor with temperature, barometric pressure and humidity. Read more about it here

Libraries

Go to the library manager "Menu->sketch->include library->manage libraries"
and search for:

Adafruit Unified Sensor by Adafruit


Adafruit BME280

Wiring

Code

#include <SD.h>
#include <Wire.h>

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)
#define Addr 0x76

Adafruit_BME280 bme; // I2C  
bool initialised = false;

File csvFile;

void setup() {  
  // put your setup code here, to run once:
  Serial.begin(9600);
  bool status;

  status = bme.begin(Addr);
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  if (!SD.begin(D8)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  pinMode(LED_BUILTIN, OUTPUT);

  delay(100);

}

void loop() {

  csvFile = SD.open("data.csv", FILE_WRITE);
  if (csvFile) {
    // First line in csv file - writes only when intialized
    if (!initialised) {
      csvFile.print("temp");
      csvFile.print(",");
      csvFile.print("alt");
      csvFile.print(",");
      csvFile.println("hum");
      initialised = true;

    }

    //Writes the values down for every loop
    csvFile.print(bme.readTemperature()); // *C
    csvFile.print(",");
    csvFile.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); // m
    csvFile.print(",");
    csvFile.println(bme.readHumidity()); // %

    csvFile.close();
    Serial.println("Write done.");
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
    digitalWrite(LED_BUILTIN, HIGH);

  }

}

GPS

Wiring

VCC - 5V
GND - GND
TX - RX

The TX and RX can't be wired while uploading to the board, since they use the same comunication port.
__

When using swop() use the following wiring:
VCC - 5V
GND - GND
TX - D7

Code

Download this file