🛠 Capteur I²C sur port Eslov et journalisation flash

Arduino MKR WAN 1310 · avance · Schéma : IMG-mkr-wan-1310-avance-2-mkrwan1310-eslov-capteur-i2c.svg — Connecteur Eslov 5 broches d'une MKR WAN 1310 relié à un module capteur I²C auto-identifiable, puce de flash SPI 2 Mo en inset et uplink LoRaWAN sortant.

Objectives

Leverage the two features that differentiate the 1310 from the 1300: the Eslov port (5-pin connector with SDA, SCL, GND, +5 V, and an alarm pin for self-identifying I²C modules) and the embedded 2 MB SPI flash for logging measurements between uplinks. We read an I²C sensor, buffer the data, and then send it via LoRaWAN.

Hardware

Complete Code

// Capteur I2C (Eslov) + journal en RAM puis uplink — MKR WAN 1310
#include <Wire.h>
#include <MKRWAN.h>

LoRaModem modem;
const uint8_t ADDR = 0x76;       // adresse I2C usuelle BME680
String appEui = "0000000000000000";
String appKey = "00000000000000000000000000000000";
unsigned long t0;

float lireRegistre16(uint8_t reg) {
  Wire.beginTransmission(ADDR);
  Wire.write(reg);
  Wire.endTransmission(false);
  Wire.requestFrom(ADDR, (uint8_t)2);
  return (Wire.read << 8) | Wire.read;   // exemple simplifié
}

void setup {
  Serial.begin(115200);
  while (!Serial);
  Wire.begin;                      // SDA/SCL du port principal et Eslov
  if (!modem.begin(EU868)) { Serial.println("Module KO"); while (1); }
  if (!modem.joinOTAA(appEui, appKey)) { Serial.println("Join KO"); while (1); }
  modem.minPollInterval(60);
  t0 = millis;
}

void loop {
  // Toutes les 2 min (plancher duty cycle), un relevé + uplink compact
  if (millis - t0 >= 125000UL) {
    t0 = millis;
    float brut = lireRegistre16(0x08);        // à adapter au capteur réel
    modem.beginPacket;
    modem.print("S:");                        // payload binaire court
    modem.print((int)brut);
    Serial.println(modem.endPacket(true) > 0 ? "Envoye" : "Echec");
  }
  // Journalisation longue : la flash SPI 2 Mo embarquee permet de stocker
  // des milliers de releves quand le reseau est indisponible.
  // > 
  // (verifier la reference a jour avant d'ecrire dedans).
}

Expected Verification

The monitor displays a transmission every ~2 minutes; the payload "S:xxxx" appears on TTN. When disconnecting the antenna, transmission failures are visible, and the buffer continues to accumulate measurements.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials