LoRa32U4 II V1.2 Development Board

page will be ready soon

Link to ebay

Link to bsfrance code and documentation BUT BE AWARE ...i did order a board and get version 1.2 and that do not fit with drawings and photos you can find on the internet.

If you want to use IO1, IO2 or IO3 then you have to solder the bridge on the back site of the board.

I01 go to Pin1, I02 go to Pin2 and I03 go to Pin3.

it means that your LMIC settings have to be.

const lmic_pinmap lmic_pins = {
    .nss = 8,                                           // Digital pin connected to SS
    .rxtx = LMIC_UNUSED_PIN,       // we do not use these
    .rst = 4,                                            // Digital pin connected to RST
    .dio = {7, 1, 2},                               // Digital pin connected to 00,01,02 
};

 

Here are my code with use of LMIC library from github LMIC link

Remember if you upload the code and afterwards do have problems with uploading it is because use of lowpower.

Then hit reset when your IDE say uploading ..It will restart chip without loading the old code and before it start the old code it go into uploading and therefore you can now upload.

When using this code you do only have 5k back to sensor code.

I can not get the sleep current below 0,2 uA which is a little to high ..


/*
* This code is a copy and a futher development
* from https://github.com/matthijskooijman/arduino-lmic
* a great guy which did a wonderfull job
* I did put on the powerdown etc
* have fun Hjalmar Skovholm Hansen
*/
#include <lmic.h>
#include <hal/hal.h>
#include "LowPower.h"

                                  // keys from TheThingsNetwork
                                  // I do use ABP so have to put them in manually
                                  // this because of LowPower
                                  // update will come later when found a solution ;o)
static const PROGMEM u1_t NWKSKEY[16] ={ 0x18, 0x35, 0xF9, 0x9E, 0x66, 0x06, 0x75, 0xF2, 0xE2, 0x31, 0xB5, 0x62, 0x9D, 0x53, 0xFE, 0x44 };
static const u1_t PROGMEM APPSKEY[16] = { 0xF8, 0x72, 0x0D, 0x33, 0x59, 0x14, 0xCD, 0x73, 0xA1, 0x1A, 0xC2, 0xCB, 0x9C, 0x20, 0x75, 0xA3 };
static const u4_t DEVADDR = 0x26011BBE ;

void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

                                   // Our array to put data into
                                   // The Things Network suggest max 10 byte
static uint8_t mydata[] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09};

static osjob_t sendjob;

const lmic_pinmap lmic_pins = {
    .nss = 8,                      // Digital pin connected to SS
    .rxtx = LMIC_UNUSED_PIN,       // we do not use these
    .rst = 4,                      // Digital pin connected to RST
    .dio = {7, 1, 2},              // Digital pin connected to 00,01,02 
};

void onEvent (ev_t ev) {
    Serial.print(os_getTime());
    Serial.print(": ");
    switch(ev) {
        case EV_SCAN_TIMEOUT:
            Serial.println(F("EV_SCAN_TIMEOUT"));
            break;
        case EV_BEACON_FOUND:
            Serial.println(F("EV_BEACON_FOUND"));
            break;
        case EV_BEACON_MISSED:
            Serial.println(F("EV_BEACON_MISSED"));
            break;
        case EV_BEACON_TRACKED:
            Serial.println(F("EV_BEACON_TRACKED"));
            break;
        case EV_JOINING:
            Serial.println(F("EV_JOINING"));
            break;
        case EV_JOINED:
            Serial.println(F("EV_JOINED"));
            break;
        case EV_RFU1:
            Serial.println(F("EV_RFU1"));
            break;
        case EV_JOIN_FAILED:
            Serial.println(F("EV_JOIN_FAILED"));
            break;
        case EV_REJOIN_FAILED:
            Serial.println(F("EV_REJOIN_FAILED"));
            break;
            break;
        case EV_TXCOMPLETE:
            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
            if (LMIC.txrxFlags & TXRX_ACK)
                Serial.println(F("Received ack"));
            if(LMIC.dataLen) {
                // data received in rx slot after tx
                Serial.print(F("Data Received: "));
                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
                Serial.println();
            }

                                   // Here we go to sleep ...
                                   // watchdog can go max 8 sec
                                   // so we make a loop 8 times 10 equal 80 sec between
                                   // each time we do connetc to gateway
                                   // think this only work for ABP
            for (int i=0; i<=9; i++) {
               LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
            }
            do_send(&sendjob);
            break;
        case EV_LOST_TSYNC:
            Serial.println(F("EV_LOST_TSYNC"));
            break;
        case EV_RESET:
            Serial.println(F("EV_RESET"));
            break;
        case EV_RXCOMPLETE:
            // data received in ping slot
            Serial.println(F("EV_RXCOMPLETE"));
            break;
        case EV_LINK_DEAD:
            Serial.println(F("EV_LINK_DEAD"));
            break;
        case EV_LINK_ALIVE:
            Serial.println(F("EV_LINK_ALIVE"));
            break;
         default:
            Serial.println(F("Unknown event"));
            break;
    }
}

void do_send(osjob_t* j){
    // Check if there is not a current TX/RX job running
    if (LMIC.opmode & OP_TXRXPEND) {
        Serial.println(F("OP_TXRXPEND, not sending"));
    } else {
        LMIC_setTxData2(1, mydata, sizeof(mydata), 0);
        Serial.println(F("Packet queued"));
    }
}

void setup() {

    Serial.begin(115200);
    //while (!Serial); // wait to serial port are started ....USE WHEN DEBUG
    Serial.println(F("Starting"));
    os_init();
    LMIC_reset();
    #ifdef PROGMEM
      uint8_t appskey[sizeof(APPSKEY)];
      uint8_t nwkskey[sizeof(NWKSKEY)];
      memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
      memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
      LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
    #else
      LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
    #endif
    LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);      // g-band
    LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
    LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI);      // g2-band
    LMIC_setLinkCheckMode(0);
    LMIC_setDrTxpow(DR_SF7, 14);    // SF7 and max power from module = 14
    LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);
    LMIC.dn2Dr = DR_SF9;
    do_send(&sendjob);
}

void loop() {

    os_runloop_once();              // start your loop with calling LoRa statemachine

                                    // From here you can read your sensors
                                    // and update mydata array with results
                                    // I just update for fun to have some data
                                    // know overrun etc ..but just to see results
    mydata[0]= mydata[0] + 0x01;
    mydata[5]= mydata[5] + 0x01;

}