quarta-feira, 4 de maio de 2022

PROGRAMANDO WISOL LOM204 ( LoRaWAN CLASS A - OTAA) COM ARDUINO STM 2.2.0 E ACESSANDO INTERNET VIA 802.3

 


IMPORTANTE: Opção NÃO OFICIAL da WISOL, indicamos uso do KEIL C

O objetivo deste BLOG é demonstrar como é possível programar o módulo WISOL LOM204A02 via Arduino Framework e assim utilizá-lo como OPENCPU (atualmente programado com o KEIL C), também mostra como adicioná-lo na Internet via Ethernet 802.3.

Será enviada Temperatura e Umidade (Random) para o servidor TTN e também será realizado um HTTP Request em 

arduino.tips

IMPORTANTE: Opção NÃO OFICIAL da WISOL, indicamos uso do KEIL C


O exemplo fará a leitura do sensor AHT10 VIA I2C e então fará a publicação no servidor loraWAN TTN. No exemplo, foi utilizado o  KIT LOM204A02 da Wisol, e como gateway LoraWAN um Dragino modelo LG308 e servidor TTN.


WIZNET W5500
O chip W5500 é um controlador Ethernet embutido TCP/IP cabeado que fornece conexão de Internet mais fácil para sistemas embarcados. O W5500 permite que os usuários tenham a conectividade com a Internet em seus aplicativos apenas usando o único chip em que Pilha TCP/IP, 10/100 Ethernet MAC e PHY embutidos.
O TCP/IP Hardwired da WIZnet é a tecnologia comprovada no mercado que suporta TCP, UDP, Protocolos IPv4, ICMP, ARP, IGMP e PPPoE. W5500 incorpora a memória interna de 32 Kbytes buffer de memória para o processamento de pacotes Ethernet. Se você usa o W5500, você pode implemente o aplicativo Ethernet apenas adicionando o programa de soquete simples. Sua maneira mais rápida e fácil em vez de usar qualquer outra solução Ethernet incorporada. Comercial pode usar 8 soquetes de hardware independentes simultaneamente.
SPI (Serial Peripheral Interface) é fornecido para fácil integração com o MCU. O SPI do W5500 suporta velocidade de 80 MHz e novo protocolo SPI eficiente para o comunicação de rede de alta velocidade. Para reduzir o consumo de energia do sistema, W5500 fornece WOL (Wake on LAN) e modo de desligamento.

KHOIH LIBRARIES - ETHERNET_GENERIC

Biblioteca Ethernet simples para placas AVR, Portenta_H7, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52 e RASPBERRY_PI_PICO usando escudos Ethernet W5100, W5200, W5500, W5100S Com esta biblioteca, você pode usar o Arduino Ethernet (blindagem ou placa) para se conectar à Internet. A biblioteca fornece funcionalidades de cliente e servidor. A biblioteca permite que você se conecte a uma rede local também com DHCP e resolva o DNS. A biblioteca h-only agora suporta recursos SPI1/SPI2, EthernetLarge, Ethernet2 e Ethernet3 simplesmente alterando as definições no esboço. RASPBERRY_PI_PICO usando núcleo arduino-pico agora pode usar SPI1. Agora STM32, placas Arduino_mbed podem usar qualquer hardware/software personalizado SPI


TTN
The Thing Network

A Rede de Coisas (TTN) é uma iniciativa iniciada pela sociedade civil holandesa. O objetivo é ter redes LoRaWAN instaladas em todas as cidades do mundo. Ao interconectar essas redes locais, a TTN quer construir uma infra-estrutura mundial para facilitar uma Internet das Coisas (IoT) pública.

A The Things Network (TTN) é o servidor IoT na nuvem utilizado nesse projeto. É um dos servidores gratuitos para LoRaWAN mais utilizados, com mais de 90 mil desenvolvedores, mais de 9 mil gateways de usuários conectados à rede ao redor do mundo e mais de 50 mil aplicações em funcionamento.

A TTN comercializa nós e gateways LoRa e provê treinamento individual e coletivo para empresas e desenvolvedores que desejam utilizar o LoRa. Possui uma comunidade bem ativa nos fóruns, sempre colaborando e ajudando a resolver problemas, além de prover diversos meios de integrar a TTN com a aplicação que se deseja usar. Possui integração nativa com diversas aplicações como: Cayenne, Hypertext Transfer Protocol (HTTP), permitindo ao usuário realizar uplink para um gateway e receber downlink por HTTP, OpenSensors e EVRYTHNG . Caso o usuário queira criar sua própria aplicação, a TTN disponibiliza Application Programming Interface (API) para uso com Message Queuing Telemetry Transport (MQTT) e diversos Software Developer Kits (SDK) para uso com as linguagens Python, Java , Node.Js , NODE-RED e Go

A rede TTN utiliza o protocolo LoRaWAN objetivando uma cobertura em longo alcance para os dispositivos da rede, caracterizando-a assim com uma Wide Area Network (WAN). Devido ao baixo consumo de energia e ao uso da tecnologia LoRa, é chamada de LPWAN (Low Power Wide Area Network). O grande diferencial da TTN é seu estabelecimento como uma rede aberta (open-source) e colaborativa (crowd-sourced), onde qualquer usuário pode contribuir instalando um gateway em sua residência.

Os elementos da TTN são classificados como: 

• Endpoints (nós): Os dispositivos responsáveis pela camada de sensoriamento da rede, o endpoint LoRaWAN. Podem coletar informações através de sensores e também acionar dispositivos/máquinas via atuadores. São configurados através de uma das três classes distintas do protocolo LaRaWAN; 

• Gateways: Elementos responsáveis por concentrar e processar as informações enviadas pelos endpoints. Os gateways em geral estão conectados a internet, seja por WiFi/Ethernet ou 3G/4G em locais remotos. Mesmo que uma mesma rede LoRaWAN tenha diferentes objetivos, baseados em aplicações distintas, os gateways possuem o objetivo comum de fornecer a maior área de cobertura possível; 

• Aplicações: Conectar e interligar os diferentes dispositivos da rede TTN para o fornecimento de informações gerais sobre a coleta de dados dos dispositivos.

ARDUINO

O que é Arduino? Se você sabe pouco sobre Arduino, por favor dê uma olhada abaixo:

Você conhece Arduino. Instale o IDE primeiro:
https://www.arduino.cc/en/Main/Software

LOM204 e Arduino

LOM204 é baseado em STM32L071.  No Arduino STM32 existe este core.

Como instalar Arduino STM32?
adicionar em Arquivo Preferências URLs adicionais

http://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json


BSP


Em seguida, instale o BSP para STM32. Se a instalação estiver concluída como segue:

LIB LoraWAN para Arduino - LMIC (Catena)


POR FAVOR, LEIA O DOCUMENTO!

Adicione ao Arduino IDE:

Abra o  exemplo TTN-OTA.ino  e configure 3 parâmetros para LoRaWAN_OTAA os quais deve ser obtidos no servidor TTN.



Defina mapeamento de Pinos para ser compatível com LOM204.
const lmic_pinmap lmic_pins = {
    .nss = RADIO_NSS,
    .rxtx = RADIO_ANT_SWITCH_HF, 
    .rst = RADIO_RESET,
    .dio = {RADIO_DIO_0, RADIO_DIO_1, RADIO_DIO_2},
};

Defina a Região
lmic_project_config.h

// project-specific definitions //#define CFG_eu868 1 //#define CFG_us915 1 #define CFG_au915 1 //#define CFG_as923 1 // #define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP /* for as923-JP */ //#define CFG_kr920 1 //#define CFG_in866 1 #define CFG_sx1276_radio 1 //#define LMIC_USE_INTERRUPTS








Adicionar em  boards.txt

# LOM204
GenL0.menu.pnum.GENERIC_L072CZYX=WISOL LOM204
GenL0.menu.pnum.GENERIC_L072CZYX.upload.maximum_size=131072
GenL0.menu.pnum.GENERIC_L072CZYX.upload.maximum_data_size=20480
GenL0.menu.pnum.GENERIC_L072CZYX.build.board=GENERIC_L072CZYX
GenL0.menu.pnum.GENERIC_L072CZYX.build.product_line=STM32L072xx
GenL0.menu.pnum.GENERIC_L072CZYX.build.variant=STM32L0xx/LOM204

Teremos então no menu o LOM204



No PACKAGE do STM32, alguns arquivos tiveram que ser alterados:

Em
C:\Users\Usuario\AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.2.0\variants\STM32L0xx

Descompacte

Teremos em variants uma placa LOM204


Conteúdo de variant_generic.h (alterado para LOM204)

/* ******************************************************************************* * Copyright (c) 2020-2021, STMicroelectronics * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************* */ #pragma once /*---------------------------------------------------------------------------- * STM32 pins number *----------------------------------------------------------------------------*/ #define PA0 PIN_A0 #define PA1 PIN_A1 #define PA2 PIN_A2 #define PA3 PIN_A3 #define PA4 PIN_A4 #define PA5 PIN_A5 #define PA6 PIN_A6 #define PA7 PIN_A7 #define PA8 8 #define PA9 9 #define PA10 10 #define PA11 11 #define PA12 12 #define PA13 13 #define PA14 14 #define PA15 15 #define PB0 PIN_A8 #define PB1 PIN_A9 #define PB2 18 #define PB3 19 #define PB4 20 #define PB5 21 #define PB6 22 #define PB7 23 #define PB8 24 #define PB9 25 #define PB10 26 #define PB11 27 #define PB12 28 #define PB13 29 #define PB14 30 #define PB15 31 #define PC0 PIN_A10 #define PC1 PIN_A11 #define PC2 PIN_A12 #define PC13 35 #define PC14 36 #define PC15 37 #define PH0 38 #define PH1 39 // Alternate pins number #define PA2_ALT1 (PA2 | ALT1) #define PA3_ALT1 (PA3 | ALT1) #define PA6_ALT1 (PA6 | ALT1) #define PA7_ALT1 (PA7 | ALT1) #define PA14_ALT1 (PA14 | ALT1) #define PB4_ALT1 (PB4 | ALT1) #define PB5_ALT1 (PB5 | ALT1) #define NUM_DIGITAL_PINS 40 #define NUM_ANALOG_INPUTS 13 // On-board LED pin number #ifndef LED_BUILTIN #define LED_BUILTIN PNUM_NOT_DEFINED #endif // On-board user button #ifndef USER_BTN #define USER_BTN PNUM_NOT_DEFINED #endif // SPI definitions #ifndef PIN_SPI_SS //LOM204 - SX1276 #define PIN_SPI_SS PA4 #endif #ifndef PIN_SPI_MOSI //LOM204 - SX1276 #define PIN_SPI_MOSI PA7 #endif #ifndef PIN_SPI_MISO //LOM204 - SX1276 #define PIN_SPI_MISO PA6 #endif #ifndef PIN_SPI_SCK //LOM204 - SX1276 #define PIN_SPI_SCK PA5 #endif #ifndef PIN_SPI1_SS //LOM204 #define PIN_SPI1_SS PB12 #endif #ifndef PIN_SPI1_MOSI //LOM204 #define PIN_SPI1_MOSI PB15 #endif #ifndef PIN_SPI1_MISO //LOM204 #define PIN_SPI1_MISO PB14 #endif #ifndef PIN_SPI1_SCK //LOM204 #define PIN_SPI1_SCK PB13 #endif // I2C definitions #ifndef PIN_WIRE_SDA //LOM204 #define PIN_WIRE_SDA PB9 #endif #ifndef PIN_WIRE_SCL //LOM204 #define PIN_WIRE_SCL PB8 #endif // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE #define TIMER_TONE TIM6 #endif #ifndef TIMER_SERVO #define TIMER_SERVO TIM7 #endif // UART Definitions #ifndef SERIAL_UART_INSTANCE #define SERIAL_UART_INSTANCE 4 #endif // Default pin used for generic 'Serial' instance // Mandatory for Firmata #ifndef PIN_SERIAL_RX //LOM204 #define PIN_SERIAL_RX PA10 #endif #ifndef PIN_SERIAL_TX //LOM204 #define PIN_SERIAL_TX PA9 #endif //Serial1 #define PIN_SERIAL1_TX PB3 #define PIN_SERIAL1_RX PB4 //Extra LOM204 #define RADIO_TCXO_VCC_PIN PB1 #define RADIO_ANT_SWITCH_PIN_RX PA15 //LMIC #define RADIO_NSS PA4 #define RADIO_ANT_SWITCH_HF PA15 #define RADIO_RESET PA8 #define RADIO_DIO_0 PA12 #define RADIO_DIO_1 PB2 #define RADIO_DIO_2 PB5 // Extra HAL modules #if !defined(HAL_DAC_MODULE_DISABLED) #define HAL_DAC_MODULE_ENABLED #endif /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ #ifdef __cplusplus // These serial port names are intended to allow libraries and architecture-neutral // sketches to automatically default to the correct port name for a particular type // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, // the first hardware serial port whose RX/TX pins are not dedicated to another use. // // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor // // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial // // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library // // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. // // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX // pins are NOT connected to anything by default. #ifndef SERIAL_PORT_MONITOR #define SERIAL_PORT_MONITOR Serial #endif #ifndef SERIAL_PORT_HARDWARE #define SERIAL_PORT_HARDWARE Serial #endif #endif

Neste exemplo, será transmitido para LoRaWAN (TTN) os dados do sensor AHT10.

Segue código final (alterado)

/******************************************************************************* * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman * Copyright (c) 2018 Terry Moore, MCCI * * Permission is hereby granted, free of charge, to anyone * obtaining a copy of this document and accompanying files, * to do whatever they want with them without any restriction, * including, but not limited to, copying, modification and redistribution. * NO WARRANTY OF ANY KIND IS PROVIDED. * * This example sends a valid LoRaWAN packet with payload "Hello, * world!", using frequency and encryption settings matching those of * the The Things Network. * * This uses OTAA (Over-the-air activation), where where a DevEUI and * application key is configured, which are used in an over-the-air * activation procedure where a DevAddr and session keys are * assigned/generated for use with all further communication. * * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably * violated by this sketch when left running for longer)! * To use this sketch, first register your application and device with * the things network, to set or generate an AppEUI, DevEUI and AppKey. * Multiple devices can use the same AppEUI, but each device has its own * DevEUI and AppKey. * * Do not forget to define the radio type correctly in * arduino-lmic/project_config/lmic_project_config.h or from your BOARDS.txt. * *******************************************************************************/ #include <lmic.h> #include <hal/hal.h> #include <SPI.h> #include "defines.h" char server[] = "arduino.tips"; unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds const unsigned long postingInterval = 10000L; // delay between updates, in milliseconds // Initialize the Web client object EthernetClient client; HardwareSerial Serial1(PB4, PB3); // // For normal use, we require that you edit the sketch to replace FILLMEIN // with values assigned by the TTN console. However, for regression tests, // we want to be able to compile these scripts. The regression tests define // COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non- // working but innocuous value. // #ifdef COMPILE_REGRESSION_TEST # define FILLMEIN 0 #else # warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!" # define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN) #endif // This EUI must be in little-endian format, so least-significant-byte // first. When copying an EUI from ttnctl output, this means to reverse // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3, // 0x70. static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} // This should also be in little endian format, see above. static const u1_t PROGMEM DEVEUI[8]={ 0x92, 0x8C, 0xEE, 0xFE, 0xFF, 0x1D, 0x57, 0x88 }; void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} // This key should be in big endian format (or, since it is not really a // number but a block of memory, endianness does not really apply). In // practice, a key taken from ttnctl can be copied as-is. static const u1_t PROGMEM APPKEY[16] = { 0x97, 0x4A, 0xBB, 0x55, 0x8A, 0x25, 0x01, 0x94, 0xA6, 0xCB, 0xC2, 0x16, 0xE2, 0xAB, 0x2E, 0x5B }; void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} uint8_t mydata[] = {0,0,0}; //Temperature, Humidity, NULL static osjob_t sendjob; // Schedule TX every this many seconds (might become longer due to duty // cycle limitations). const unsigned TX_INTERVAL = 15; // Pin mapping const lmic_pinmap lmic_pins = { .nss = RADIO_NSS, .rxtx = RADIO_ANT_SWITCH_HF, .rst = RADIO_RESET, .dio = {RADIO_DIO_0, RADIO_DIO_1, RADIO_DIO_2}, }; void printHex2(unsigned v) { v &= 0xff; if (v < 16) Serial.print('0'); Serial.print(v, HEX); } 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")); { u4_t netid = 0; devaddr_t devaddr = 0; u1_t nwkKey[16]; u1_t artKey[16]; LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey); Serial.print("netid: "); Serial.println(netid, DEC); Serial.print("devaddr: "); Serial.println(devaddr, HEX); Serial.print("AppSKey: "); for (size_t i=0; i<sizeof(artKey); ++i) { if (i != 0) Serial.print("-"); printHex2(artKey[i]); } Serial.println(""); Serial.print("NwkSKey: "); for (size_t i=0; i<sizeof(nwkKey); ++i) { if (i != 0) Serial.print("-"); printHex2(nwkKey[i]); } Serial.println(); } // Disable link check validation (automatically enabled // during join, but because slow data rates change max TX // size, we don't use it in this example. LMIC_setLinkCheckMode(0); break; /* || This event is defined but not used in the code. No || point in wasting codespace on it. || || 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; 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) { Serial.print(F("Received ")); Serial.print(LMIC.dataLen); Serial.println(F(" bytes of payload")); } // Schedule next transmission os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send); 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; /* || This event is defined but not used in the code. No || point in wasting codespace on it. || || case EV_SCAN_FOUND: || Serial.println(F("EV_SCAN_FOUND")); || break; */ case EV_TXSTART: Serial.println(F("EV_TXSTART")); char mydata_temperature_humidity[64]; sprintf(mydata_temperature_humidity, "Temperature: %u Humidity %u",(uint8_t) rand(),(uint8_t) rand()); Serial.println(mydata_temperature_humidity); mydata[0]=(uint8_t) rand(); //payload mydata[1]=(uint8_t) rand(); //payload break; case EV_TXCANCELED: Serial.println(F("EV_TXCANCELED")); break; case EV_RXSTART: /* do not print anything -- it wrecks timing */ break; case EV_JOIN_TXCOMPLETE: Serial.println(F("EV_JOIN_TXCOMPLETE: no JoinAccept")); break; default: Serial.print(F("Unknown event: ")); Serial.println((unsigned) ev); 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 { // Prepare upstream data transmission at the next possible time. LMIC_setTxData2(1, mydata, sizeof(mydata)-1, true); //ack Serial.println(F("Packet queued")); } // Next TX is scheduled after TX_COMPLETE event. } void setup() { //LOM204 pinMode(RADIO_TCXO_VCC_PIN,OUTPUT); digitalWrite(RADIO_TCXO_VCC_PIN,HIGH); //LOM204 Serial.begin(9600); Serial.println(F("Starting")); Serial.print("\nStarting WebClient on "); Serial.print(BOARD_NAME); Serial.print(F(" with ")); Serial.println(SHIELD_TYPE); Serial.println(ETHERNET_GENERIC_VERSION); #if (USING_SPI1) #if defined(CUR_PIN_MISO) ETG_LOGWARN(F("!Default SPI pinout:!")); ETG_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); ETG_LOGWARN1(F("MISO:"), CUR_PIN_MISO); ETG_LOGWARN1(F("SCK:"), CUR_PIN_SCK); ETG_LOGWARN1(F("SS:"), CUR_PIN_SS); ETG_LOGWARN(F("=========================")); #endif #else ETG_LOGWARN(F("Default SPI pinout:")); ETG_LOGWARN1(F("MOSI:"), MOSI); ETG_LOGWARN1(F("MISO:"), MISO); ETG_LOGWARN1(F("SCK:"), SCK); ETG_LOGWARN1(F("SS:"), SS); ETG_LOGWARN(F("=========================")); #endif #if defined(ESP8266) // For ESP8266, change for other boards if necessary #ifndef USE_THIS_SS_PIN #define USE_THIS_SS_PIN D2 // For ESP8266 #endif ETG_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); // For ESP8266 // Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8 // Ethernet_Generic X X X X X 0 // D2 is safe to used for Ethernet_Generic libs //Ethernet.setCsPin (USE_THIS_SS_PIN); Ethernet.init (USE_THIS_SS_PIN); #elif defined(ESP32) // You can use Ethernet.init(pin) to configure the CS pin //Ethernet.init(10); // Most Arduino shields //Ethernet.init(5); // MKR ETH shield //Ethernet.init(0); // Teensy 2.0 //Ethernet.init(20); // Teensy++ 2.0 //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet #ifndef USE_THIS_SS_PIN #define USE_THIS_SS_PIN 5 //22 // For ESP32 #endif ETG_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); // Must use library patch for Ethernet, EthernetLarge libraries // ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge // ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3 //Ethernet.setCsPin (USE_THIS_SS_PIN); Ethernet.init (USE_THIS_SS_PIN); #elif ETHERNET_USE_RPIPICO pinMode(USE_THIS_SS_PIN, OUTPUT); digitalWrite(USE_THIS_SS_PIN, HIGH); // ETHERNET_USE_RPIPICO, use default SS = 5 or 17 #ifndef USE_THIS_SS_PIN #if defined(ARDUINO_ARCH_MBED) #define USE_THIS_SS_PIN 17 // For Arduino Mbed core #else #define USE_THIS_SS_PIN 17 // For E.Philhower core #endif #endif ETG_LOGWARN1(F("RPIPICO setCsPin:"), USE_THIS_SS_PIN); // Must use library patch for Ethernet, EthernetLarge libraries // For RPI Pico using Arduino Mbed RP2040 core // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 // For RPI Pico using E. Philhower RP2040 core // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 // Default pin 5/17 to SS/CS //Ethernet.setCsPin (USE_THIS_SS_PIN); Ethernet.init (USE_THIS_SS_PIN); #else //defined(ESP8266) // unknown board, do nothing, use default SS = 10 #ifndef USE_THIS_SS_PIN #define USE_THIS_SS_PIN 28 // For other boards (LOM204) #endif #if defined(BOARD_NAME) ETG_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); #else ETG_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN); #endif // For other boards, to change if necessary Ethernet.init (USE_THIS_SS_PIN); #endif // defined(ESP8266) // start the ethernet connection and the server: // Use DHCP dynamic IP and random mac uint16_t index = millis() % NUMBER_OF_MAC; // Use Static IP //Ethernet.begin(mac[index], ip); Ethernet.begin(mac[index]); //SPIClass SPI2(HSPI); //Ethernet.begin(mac[index], &SPI2); // Just info to know how to connect correctly // To change for other SPI #if defined(CUR_PIN_MISO) ETG_LOGWARN(F("Currently Used SPI pinout:")); ETG_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); ETG_LOGWARN1(F("MISO:"), CUR_PIN_MISO); ETG_LOGWARN1(F("SCK:"), CUR_PIN_SCK); ETG_LOGWARN1(F("SS:"), CUR_PIN_SS); ETG_LOGWARN(F("=========================")); #else ETG_LOGWARN(F("Currently Used SPI pinout:")); ETG_LOGWARN1(F("MOSI:"), MOSI); ETG_LOGWARN1(F("MISO:"), MISO); ETG_LOGWARN1(F("SCK:"), SCK); ETG_LOGWARN1(F("SS:"), SS); ETG_LOGWARN(F("=========================")); #endif Serial.print(F("Using mac index = ")); Serial.println(index); Serial.print(F("Connected! IP address: ")); Serial.println(Ethernet.localIP()); if ( (Ethernet.getChip() == w5500) || (Ethernet.getAltChip() == w5100s) ) { Serial.print(F("Speed: ")); Serial.print(Ethernet.speedReport()); Serial.print(F(", Duplex: ")); Serial.print(Ethernet.duplexReport()); Serial.print(F(", Link status: ")); Serial.println(Ethernet.linkReport()); } Serial.println(); Serial.println(F("Starting connection to server...")); // LMIC init os_init(); // Reset the MAC state. Session and pending data transfers will be discarded. LMIC_reset(); LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100); LMIC_selectSubBand(1); //TTN - FSB2 start in 0 // Start job (sending automatically starts OTAA too) do_send(&sendjob); } // this method makes a HTTP connection to the server void httpRequest() { Serial.println(); // close any connection before send a new request // this will free the socket on the WiFi shield client.stop(); // if there's a successful connection if (client.connect(server, 80)) { Serial.println(F("Connecting...")); // send the HTTP PUT request client.println(F("GET /asciilogo.txt HTTP/1.1")); client.println(F("Host: arduino.tips")); client.println(F("Connection: close")); client.println(); // note the time that the connection was made lastConnectionTime = millis(); } else { // if you couldn't make a connection Serial.println(F("Connection failed")); } } void loop() { while (client.available()) { char c = client.read(); Serial.write(c); Serial.flush(); } // if 10 seconds have passed since your last connection, // then connect again and send data if (millis() - lastConnectionTime > postingInterval) { httpRequest(); } os_runloop_once(); }

defines.h

/**************************************************************************************************************************** defines.h Ethernet_Generic is a library for the W5x00 Ethernet shields trying to merge the good features of previous Ethernet libraries Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Generic ***************************************************************************************************************************************/ #ifndef defines_h #define defines_h #define DEBUG_ETHERNET_GENERIC_PORT Serial // Debug Level from 0 to 4 #define _ETG_LOGLEVEL_ 3 #if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) #if defined(ETHERNET_USE_SAMD) #undef ETHERNET_USE_SAMD #endif #define ETHERNET_USE_SAMD true #endif #if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) #if defined(ETHERNET_USE_NRF528XX) #undef ETHERNET_USE_NRF528XX #endif #define ETHERNET_USE_NRF528XX true #endif #if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) #if defined(ETHERNET_USE_SAM_DUE) #undef ETHERNET_USE_SAM_DUE #endif #define ETHERNET_USE_SAM_DUE true #endif #if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) #if defined(ETHERNET_USE_RPIPICO) #undef ETHERNET_USE_RPIPICO #endif #define ETHERNET_USE_RPIPICO true #endif #if defined(ETHERNET_USE_SAMD) // For SAMD // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) #define BOARD_TYPE "SAMD MKRWIFI1010" #elif defined(ARDUINO_SAMD_NANO_33_IOT) #define BOARD_TYPE "SAMD NANO_33_IOT" #elif defined(ARDUINO_SAMD_MKRFox1200) #define BOARD_TYPE "SAMD MKRFox1200" #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) #define BOARD_TYPE "SAMD MKRWAN13X0" #elif defined(ARDUINO_SAMD_MKRGSM1400) #define BOARD_TYPE "SAMD MKRGSM1400" #elif defined(ARDUINO_SAMD_MKRNB1500) #define BOARD_TYPE "SAMD MKRNB1500" #elif defined(ARDUINO_SAMD_MKRVIDOR4000) #define BOARD_TYPE "SAMD MKRVIDOR4000" #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" #elif defined(ADAFRUIT_METRO_M0_EXPRESS) #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" #elif defined(ADAFRUIT_GEMMA_M0) #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" #elif defined(ADAFRUIT_TRINKET_M0) #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" #elif defined(ADAFRUIT_ITSYBITSY_M0) #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" #elif defined(ARDUINO_SAMD_HALLOWING_M0) #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" #elif defined(ADAFRUIT_METRO_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" #define USE_THIS_SS_PIN 10 #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" #elif defined(ADAFRUIT_PYPORTAL) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" #elif defined(SEEED_WIO_TERMINAL) #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" #elif defined(SEEED_FEMTO_M0) #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" #elif defined(SEEED_XIAO_M0) #define BOARD_TYPE "SAMD SEEED_XIAO_M0" #ifdef USE_THIS_SS_PIN #undef USE_THIS_SS_PIN #endif #define USE_THIS_SS_PIN A1 #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 #elif defined(Wio_Lite_MG126) #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" #elif defined(WIO_GPS_BOARD) #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" #elif defined(SEEEDUINO_ZERO) #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" #elif defined(SEEEDUINO_LORAWAN) #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" #elif defined(SEEED_GROVE_UI_WIRELESS) #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" #elif defined(__SAMD21E18A__) #define BOARD_TYPE "SAMD21E18A" #elif defined(__SAMD21G18A__) #define BOARD_TYPE "SAMD21G18A" #elif defined(__SAMD51G19A__) #define BOARD_TYPE "SAMD51G19A" #elif defined(__SAMD51J19A__) #define BOARD_TYPE "SAMD51J19A" #elif defined(__SAMD51J20A__) #define BOARD_TYPE "SAMD51J20A" #elif defined(__SAM3X8E__) #define BOARD_TYPE "SAM3X8E" #elif defined(__CPU_ARC__) #define BOARD_TYPE "CPU_ARC" #elif defined(__SAMD51__) #define BOARD_TYPE "SAMD51" #else #define BOARD_TYPE "SAMD Unknown" #endif #elif (ETHERNET_USE_SAM_DUE) // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 #define BOARD_TYPE "SAM DUE" #elif (ETHERNET_USE_NRF528XX) // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 #if defined(NRF52840_FEATHER) #define BOARD_TYPE "NRF52840_FEATHER" #elif defined(NRF52832_FEATHER) #define BOARD_TYPE "NRF52832_FEATHER" #elif defined(NRF52840_FEATHER_SENSE) #define BOARD_TYPE "NRF52840_FEATHER_SENSE" #elif defined(NRF52840_ITSYBITSY) #define BOARD_TYPE "NRF52840_ITSYBITSY" #define USE_THIS_SS_PIN 10 // For other boards #elif defined(NRF52840_CIRCUITPLAY) #define BOARD_TYPE "NRF52840_CIRCUITPLAY" #elif defined(NRF52840_CLUE) #define BOARD_TYPE "NRF52840_CLUE" #elif defined(NRF52840_METRO) #define BOARD_TYPE "NRF52840_METRO" #elif defined(NRF52840_PCA10056) #define BOARD_TYPE "NRF52840_PCA10056" #elif defined(NINA_B302_ublox) #define BOARD_TYPE "NINA_B302_ublox" #elif defined(NINA_B112_ublox) #define BOARD_TYPE "NINA_B112_ublox" #elif defined(PARTICLE_XENON) #define BOARD_TYPE "PARTICLE_XENON" #elif defined(ARDUINO_NRF52_ADAFRUIT) #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" #else #define BOARD_TYPE "nRF52 Unknown" #endif #elif ( defined(CORE_TEENSY) ) // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 #if defined(__IMXRT1062__) // For Teensy 4.1/4.0 #if defined(ARDUINO_TEENSY41) #define BOARD_TYPE "TEENSY 4.1" // Use true for NativeEthernet Library, false if using other Ethernet libraries #define USE_NATIVE_ETHERNET true #elif defined(ARDUINO_TEENSY40) #define BOARD_TYPE "TEENSY 4.0" #else #define BOARD_TYPE "TEENSY 4.x" #endif #elif defined(__MK66FX1M0__) #define BOARD_TYPE "Teensy 3.6" #elif defined(__MK64FX512__) #define BOARD_TYPE "Teensy 3.5" #elif defined(__MKL26Z64__) #define BOARD_TYPE "Teensy LC" #elif defined(__MK20DX256__) #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) #elif defined(__MK20DX128__) #define BOARD_TYPE "Teensy 3.0" #elif defined(__AVR_AT90USB1286__) #error Teensy 2.0++ not supported yet #elif defined(__AVR_ATmega32U4__) #error Teensy 2.0 not supported yet #else // For Other Boards #define BOARD_TYPE "Unknown Teensy Board" #endif #elif ( defined(ESP8266) ) // For ESP8266 #warning Use ESP8266 architecture #include <ESP8266mDNS.h> #define ETHERNET_USE_ESP8266 #define BOARD_TYPE "ESP8266" #elif ( defined(ESP32) ) // For ESP32 #warning Use ESP32 architecture #define ETHERNET_USE_ESP32 #define BOARD_TYPE "ESP32" #define W5500_RST_PORT 21 #elif ETHERNET_USE_RPIPICO // Default pin 5 (in Mbed) or 17 to SS/CS #if defined(ARDUINO_ARCH_MBED) // For RPI Pico using Arduino Mbed RP2040 core // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 #define USE_THIS_SS_PIN 17 #if defined(BOARD_NAME) #undef BOARD_NAME #endif #if defined(ARDUINO_RASPBERRY_PI_PICO) #define BOARD_TYPE "MBED RASPBERRY_PI_PICO" #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) #define BOARD_TYPE "MBED DAFRUIT_FEATHER_RP2040" #elif defined(ARDUINO_GENERIC_RP2040) #define BOARD_TYPE "MBED GENERIC_RP2040" #else #define BOARD_TYPE "MBED Unknown RP2040" #endif #else // For RPI Pico using E. Philhower RP2040 core #if (USING_SPI2) // SCK: GPIO14, MOSI: GPIO15, MISO: GPIO12, SS/CS: GPIO13 for SPI1 #define USE_THIS_SS_PIN 13 #else // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 for SPI0 #define USE_THIS_SS_PIN 17 #endif #endif #define SS_PIN_DEFAULT USE_THIS_SS_PIN // For RPI Pico #warning Use RPI-Pico RP2040 architecture #else // For Mega // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 // Reduce size for Mega #define SENDCONTENT_P_BUFFER_SZ 512 #define BOARD_TYPE "AVR Mega" #endif #ifndef BOARD_NAME #define BOARD_NAME BOARD_TYPE #endif #include <SPI.h> /////////////////////////////////////////////////////////// // W5100 chips can have up to 4 sockets. W5200 & W5500 can have up to 8 sockets. // Use EthernetLarge feature, Larger buffers, but reduced number of simultaneous connections/sockets (MAX_SOCK_NUM == 2) #define ETHERNET_LARGE_BUFFERS ////////////////////////////////////////////////////////// // For boards supporting multiple hardware / software SPI buses, such as STM32 // Tested OK with Nucleo144 F767ZI and L552ZE_Q so far #if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) || defined(STM32L5) ) // Be sure to use true only if necessary for your board, or compile error #define USING_CUSTOM_SPI true #if ( USING_CUSTOM_SPI ) // Currently test OK for F767ZI and L552ZE_Q #define USING_SPI1 true #if (USING_SPI1) //#include <SPI.h> // For L552ZE-Q, F767ZI, but you can change the pins for any other boards // SCK: 23, MOSI: 22, MISO: 25, SS/CS: 24 for SPI1 #define CUR_PIN_MISO PIN_SPI1_MISO #define CUR_PIN_MOSI PIN_SPI1_MOSI #define CUR_PIN_SCK PIN_SPI1_SCK #define CUR_PIN_SS PIN_SPI1_SS #define SPI_NEW_INITIALIZED true // Don't create the instance with CUR_PIN_SS, or Ethernet not working // To change for other boards' SPI libraries SPIClass SPI_New(CUR_PIN_MOSI, CUR_PIN_MISO, CUR_PIN_SCK); //#warning Using USE_THIS_SS_PIN = CUR_PIN_SS = 24 #if defined(USE_THIS_SS_PIN) #undef USE_THIS_SS_PIN #endif #define USE_THIS_SS_PIN CUR_PIN_SS //24 #endif #endif #endif ////////////////////////////////////////////////////////// #include "Ethernet_Generic.h" #if defined(ETHERNET_LARGE_BUFFERS) #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library with Large Buffer" #else #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library" #endif // Enter a MAC address and IP address for your controller below. #define NUMBER_OF_MAC 20 byte mac[][NUMBER_OF_MAC] = { { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 }, { 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 }, }; // Select the IP address according to your local network IPAddress ip(192, 168, 100, 222); // Google DNS Server IP IPAddress myDns(8, 8, 8, 8); #endif //defines_h

Gateway


LIB ETHERNET_GENERIC - W5500

INSTALE
POR FAVOR, LEIA O DOCUMENTO!

MONTAGEM

Conexão LOM204 com o módulo  WIZNET W5500


LOM204

W5500

PIN_SPI1_SS              PB12

SCS

PIN_SPI1_MOSI          PB15

MOSI (CORRETO)

PIN_SPI1_MISO          PB14

MISO (CORRETO)

PIN_SPI1_SCK            PB13

SCLK

GND

GND

3.3V

5V



Compilando

GRAVADOR

Instale o STM32 Cube Programmer, o Arduino (STM32 PACKAGE) irá reconhecê-lo e então utilizá-lo para programar o LOM204.

Compre o ST-LINK V2


O Kit LOM204 possui um gravador ST-LINK embarcado.


Uma vez gravado o Software, o LOM204 fará o JOIN na LoRaWAN


UPLINK message
Ligado na UART1


DOWNLINK message



ACESSANDO INTERNET VIA 802.3



THANKS TO Khoi Hoang

Fontes:


Dúvidas

suporte@smartcore.com.br


Consumo: 8mA no Arduino 

Sobre a SMARTCORE

A SmartCore fornece módulos para comunicação wireless, biometria, conectividade, rastreamento e automação.
Nosso portfólio inclui modem 2G/3G/4G/NB-IoT/Cat.M, satelital, módulos WiFi, Bluetooth, GNSS / GPS, Sigfox, LoRa, leitor de cartão, leitor QR code, mecanismo de impressão, mini-board PC, antena, pigtail, LCD, bateria, repetidor GPS e sensores.

Mais detalhes em www.smartcore.com.br

Nenhum comentário:

Postar um comentário