ZerzeusseNicolas DAILLYTheo Gosse
Published © GPL3+

Lora-Link Tournament Creator

YU-GI-OH LoraLink is a complete system for create and manage a YU-GI-OH tournament, allowing dueslist to register to tournament for conpetti

BeginnerWork in progress3 days71
Lora-Link Tournament Creator

Things used in this project

Story

Read more

Custom parts and enclosures

coin_de_table.stl

Sketchfab still processing.

Code

Sodaq Explorer Code

Arduino
This code initializes a LoRaWAN device using OTAA, sets up serial communication, and sends payloads to The Things Network upon button press.
#include <Sodaq_RN2483.h>

// Table definition
#define NUM_TABLE 54

// Serial definitions
#define DEBUG_SERIAL    SerialUSB
#define LORA_SERIAL     Serial2

// Pin definition
#define BUTTON_PIN      7

// LoRa configuration (OTAA)
const uint8_t APP_EUI[8] = {0x0A, 0x00, 0xAC, 0x0B, 0x20, 0x67, 0x00, 0xD0};
const uint8_t DEV_EUI[8] = {0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x06, 0x82, 0x59};
const uint8_t APP_KEY[16] = {0xBB, 0x53, 0x0E, 0xA1, 0xEA, 0x16, 0x34, 0x62, 0xF6, 0x99, 0x0D, 0x45, 0x27, 0xD4, 0x3D, 0xB4};

void setup() {
    // Initialize debug serial communication
    DEBUG_SERIAL.begin(57600);
    while (!DEBUG_SERIAL); // Wait for serial monitor to open

    // Initialize LoRa serial communication
    LORA_SERIAL.begin(LoRaBee.getDefaultBaudRate());

    // Initialize button pin
    pinMode(BUTTON_PIN, INPUT_PULLUP);

    // Initialize LoRa communication
    LoRaBee.setDiag(DEBUG_SERIAL);
    initializeLoRa();

    DEBUG_SERIAL.println("Setup complete. Waiting for button press to send payload.");
}

void loop() {
    if (digitalRead(BUTTON_PIN) == LOW) {
        delay(100); // Debounce delay
        sendPayload(); // Send table number as payload
        delay(1000); // Delay to avoid multiple sends on single button press
    }
}

void initializeLoRa() {
    delay(100);

    if (LoRaBee.initOTA(LORA_SERIAL, DEV_EUI, APP_EUI, APP_KEY, true)) {
        DEBUG_SERIAL.println("OTAA Keys Accepted.");
    } else {
        DEBUG_SERIAL.println("OTAA Key Setup Failed!");
        haltExecution();
    }
}

void sendPayload() {
    // Convert table number to bytes
    uint8_t payload[1];
    payload[0] = NUM_TABLE;

    DEBUG_SERIAL.print("Button pressed. Sending payload: ");
    DEBUG_SERIAL.println(NUM_TABLE); // Print the payload being sent

    // Send LoRa payload and handle response
    uint8_t attempts = 3; // Number of retry attempts
    bool success = false;

    while (attempts-- > 0 && !success) {
        switch (LoRaBee.send(1, payload, sizeof(payload))) {
            case NoError:
                DEBUG_SERIAL.println("Successful transmission.");
                success = true;
                break;
            case NoResponse:
                DEBUG_SERIAL.println("No response from the device.");
                break;
            case Timeout:
                DEBUG_SERIAL.println("Connection timed out. Check your serial connection.");
                break;
            case PayloadSizeError:
                DEBUG_SERIAL.println("Payload size error.");
                break;
            default:
                DEBUG_SERIAL.println("Unknown error.");
                break;
        }

        if (!success) {
            delay(1000); // Wait before retrying
        }
    }

    if (!success) {
        DEBUG_SERIAL.println("Failed to send payload after multiple attempts.");
    }
}

void haltExecution() {
    while (true) {}
}

YU-GI-OH_LoraLink

Github du projet

Credits

Zerzeusse
1 project • 1 follower
Contact
Nicolas DAILLY
33 projects • 21 followers
Associated Professor at UniLaSalle - Amiens / Head of the Computer Network Department / Teach Computer and Telecommunication Networks
Contact
Theo Gosse
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.