Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. not working Ethernet Gateway (sensebender and/or nano gateway)

not working Ethernet Gateway (sensebender and/or nano gateway)

Scheduled Pinned Locked Moved Hardware
32 Posts 9 Posters 3.5k Views 8 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rafael156
    wrote on last edited by rafael156
    #16

    can anyone tell me how to flash the sensebender board (Atmel ATSAMD21J18A) with openocd and an Atmel JtagIce3 running on windows? i have a batch file, but it returns an error.

    Batch file:

    openocd\bin\openocd --debug 4 --log_output log.txt -d0 -s openocd/share/openocd/scripts/ -f arduino_zero.cfg -c "telnet_port disabled; init; halt; at91samd bootloader 0; program {{%1}} verify reset;shutdown"
    

    log_file:

    Debug: 17 12 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_debug_level 0
    Debug: 18 12 command.c:145 script_debug(): command - debug_level ocd_debug_level 0
    debug_level: 0
    adapter speed: 500 kHz
    adapter_nsrst_delay: 100
    cortex_m reset_config sysresetreq
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x81000000 pc: 0x00005460 msp: 0x20007fb8
    target state: halted
    target halted due to debug-request, current mode: Thread 
    xPSR: 0x81000000 pc: 0x000005e8 msp: 0x20007ffc
    ** Programming Started **
    auto erase enabled
    Runtime Error: embedded:startup.tcl:454: ** Programming Failed **
    in procedure 'program' 
    in procedure 'program_error' called at file "embedded:startup.tcl", line 510
    at file "embedded:startup.tcl", line 454
    
    1 Reply Last reply
    0
    • R Offline
      R Offline
      rafael156
      wrote on last edited by
      #17

      ok, I flashed the bootloader and now LED5 (D5) is lit permanently. A new USB port is also not recognized.
      the fuse settings were probably not set either. do I still have to set them or don't I need them at sensebender gw?
      but i need the USB port, otherwise i can't transfer sketches.
      if I transfer sketches via SWD nothing happens after the upload.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rafael156
        wrote on last edited by
        #18

        i just found out that the platform.txt is not correct/outdated. The file "...\Arduino15\packages\MySensors\hardware\samd\1.0.5\platform.txt"
        Line 148 should be changed from

        openocd-0.9.0-arduino5-static.path 
        

        to

        openocd-0.9.0-arduino6-static.path
        

        can one of the mysensors samd board 1.0.5 please change that?

        1 Reply Last reply
        1
        • R Offline
          R Offline
          rafael156
          wrote on last edited by
          #19

          has anyone managed to get an arduino nano running with NRF and W5100 as ethernet gateway? mine won't even accept the IP address (should be 192.168.1.110) after a successful sketch:

           MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1<\n>
          4 TSM:INIT<\n>
          5 TSF:WUR:MS=0<\n>
          11 TSM:INIT:TSP OK<\n>
          13 TSM:INIT:GW MODE<\n>
          15 TSM:READY:ID=0,PAR=0,DIS=0<\n>
          17 MCO:REG:NOT NEEDED<\n>
          580 GWT:TIN:IP=0.0.0.0<\n>
          1582 MCO:BGN:STP<\n>
          1584 MCO:BGN:INIT OK,TSP=1<\n>
          1586 TSM:READY:NWD REQ<\n>
          1624 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:<\n>
          
          1 Reply Last reply
          0
          • tbowmoT Offline
            tbowmoT Offline
            tbowmo
            Admin
            wrote on last edited by
            #20

            The SAMD21 doesn't use fuses in the same way that the atmega328 does. For example, the clock source is set by the running program, and not the fuses. The only fuses awailable is BOD, WDT and bootprotection. (See page 43 in the datasheet)

            So it should not be needed to set any fuses in the SAMD21 in order to get it working.

            btw. why did you replace the atsamd21 in the first place?

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rafael156
              wrote on last edited by
              #21

              Okay, thanks for the clarification.
              i changed the processor because the USB interface was not recognized under windows and i couldn't program the board anymore. leds were lit but, so i thought that the samd must be broken.
              the new one shows the same behavior after flashing with mysensors 2.3.1 ... so it must be somewhere due to the software.

              can you please initiate the change to the "platform.txt" (see https://forum.mysensors.org/post/96909)?

              tbowmoT 1 Reply Last reply
              0
              • R rafael156

                Okay, thanks for the clarification.
                i changed the processor because the USB interface was not recognized under windows and i couldn't program the board anymore. leds were lit but, so i thought that the samd must be broken.
                the new one shows the same behavior after flashing with mysensors 2.3.1 ... so it must be somewhere due to the software.

                can you please initiate the change to the "platform.txt" (see https://forum.mysensors.org/post/96909)?

                tbowmoT Offline
                tbowmoT Offline
                tbowmo
                Admin
                wrote on last edited by
                #22

                @rafael156

                Is it the standard gateway sketch, that you use for the SAMD? If not, could you post it here? Then I could try programming a spare samd21 board at some point in time (I do not know if I get around to it this weekend, as I have lots of projects running through my head at the moment)

                R 1 Reply Last reply
                0
                • tbowmoT tbowmo

                  @rafael156

                  Is it the standard gateway sketch, that you use for the SAMD? If not, could you post it here? Then I could try programming a spare samd21 board at some point in time (I do not know if I get around to it this weekend, as I have lots of projects running through my head at the moment)

                  R Offline
                  R Offline
                  rafael156
                  wrote on last edited by
                  #23

                  @tbowmo yes, it is the standard "SensebenderGatewaySerial" sketch.
                  i try to reinstall the arduino ide completely on the weekend and use older versions. it is worth a try...

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rafael156
                    wrote on last edited by rafael156
                    #24

                    ok, the weekend has brought a lot of information... both problems have been solved:
                    To the Arduino Nano+W5100+NRF24:

                    • Note versions:
                      Clean Install (delete Dirs: ".../Documents/Arduino", "AppData", "Arduino IDE") before compiling:
                      Arduino IDE 1.6.13
                      Arduino AVR 1.6.18
                      Arduino SAMD 1.6.12
                      MySensors SAMD 1.0.5
                      MySensors Lib 2.3.1

                    • if no W5100 is attached, then 0.0.0.0 comes in the log

                    • Both GNDs of the W5100 must be connected!

                    • Voltage with +5V, if voltage transformer present

                    • optional: fix bug of W5100: https://arduinodiy.wordpress.com/2017/04/12/the-w5100-bug/

                    • successful log Nano_5V_16Mhz+W5100+NRF24:
                      0 MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1
                      4 TSM:INIT
                      5 TSF:WUR:MS=5000
                      11 TSM:INIT:TSP OK
                      13 TSM:INIT:GW MODE
                      15 TSM:READY:ID=0,PAR=0,DIS=0
                      17 MCO:REG:NOT NEEDED
                      320 GWT:TIN:IP=128.168.1.38
                      1323 MCO:BGN:STP
                      1325 MCO:SLP:MS=250,SMS=0,I1=255,M1=255,I2=255,M2=255,M2=255
                      1330 !MCO:SLP:REP
                      1332 TSM:READY:NWD REQ
                      1369 TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
                      1581 MCO:BGN:INIT OK,TSP=1

                    • power consumption Nano_5V_16Mhz+W5100+NRF24: 250mA

                    • operate the W5100 with its own +5V power supply!

                    With 2kB SRAM, the Arduino Nano meets the minimum requirements for an ETHERNET(!) gateway (serial gateway is no problem). It can happen from time to time that the W5100 is not responsive for a short time because the nano does not follow. It is best to deactivate MY_DEBUG or use a mega with 8kB memory.

                    My working Nano+W5100+NRF24 Sketch:

                    /*
                     * The MySensors Arduino library handles the wireless radio link and protocol
                     * between your home built sensors/actuators and HA controller of choice.
                     * The sensors forms a self healing radio network with optional repeaters. Each
                     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                     * network topology allowing messages to be routed to nodes.
                     *
                     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                     * Copyright (C) 2013-2018 Sensnology AB
                     * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
                     *
                     * Documentation: http://www.mysensors.org
                     * Support Forum: http://forum.mysensors.org
                     *
                     * This program is free software; you can redistribute it and/or
                     * modify it under the terms of the GNU General Public License
                     * version 2 as published by the Free Software Foundation.
                     *
                     *******************************
                     *
                     * REVISION HISTORY
                     * Version 1.0 - Henrik EKblad
                     * Contribution by a-lurker and Anticimex,
                     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
                     * Contribution by Tomas Hozza <thozza@gmail.com>
                     *
                     *
                     * DESCRIPTION
                     * The EthernetGateway sends data received from sensors to the ethernet link.
                     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
                     *
                     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
                     *
                     * LED purposes:
                     * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below
                     * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
                     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                     * - ERR (red) - fast blink on error during transmission error or receive crc error
                     *
                     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
                     *
                     */
                    
                    // Enable debug prints to serial monitor
                    //#define MY_DEBUG
                    
                    // Enable and select radio type attached
                    #define MY_RADIO_RF24
                    //#define MY_RADIO_NRF5_ESB
                    //#define MY_RADIO_RFM69
                    //#define MY_RADIO_RFM95
                    
                    // Enable gateway ethernet module type
                    #define MY_GATEWAY_W5100
                    #define MY_GATEWAY_MAX_CLIENTS  3
                    
                    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                    //#define MY_W5100_SPI_EN 4
                    
                    // Enable Soft SPI for NRF radio (note different radio wiring is required)
                    // The W5100 ethernet module seems to have a hard time co-operate with
                    // radio on the same spi bus.
                    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                    #define MY_SOFTSPI
                    #define MY_SOFT_SPI_SCK_PIN 14
                    #define MY_SOFT_SPI_MISO_PIN 16
                    #define MY_SOFT_SPI_MOSI_PIN 15
                    #endif
                    
                    // When W5100 is connected we have to move CE/CSN pins for NRF radio
                    #ifndef MY_RF24_CE_PIN
                    #define MY_RF24_CE_PIN 5
                    #endif
                    #ifndef MY_RF24_CS_PIN
                    #define MY_RF24_CS_PIN 6
                    #endif
                    
                    // Enable UDP communication
                    //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
                    
                    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                    #define MY_IP_ADDRESS 192,168,1,38
                    
                    // If using static ip you can define Gateway and Subnet address as well
                    #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                    #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                    
                    // Renewal period if using DHCP
                    //#define MY_IP_RENEWAL_INTERVAL 60000
                    
                    // The port to keep open on node server mode / or port to contact in client mode
                    #define MY_PORT 5003
                    
                    // Controller ip address. Enables client mode (default is "server" mode).
                    // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
                    //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
                    
                    // The MAC address can be anything you want but should be unique on your network.
                    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                    // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                    #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                    
                    // Enable inclusion mode
                    #define MY_INCLUSION_MODE_FEATURE
                    // Enable Inclusion mode button on gateway
                    //#define MY_INCLUSION_BUTTON_FEATURE
                    // Set inclusion mode duration (in seconds)
                    #define MY_INCLUSION_MODE_DURATION 60
                    // Digital pin used for inclusion mode button
                    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
                    
                    // Set blinking period
                    #define MY_DEFAULT_LED_BLINK_PERIOD 300
                    
                    // Flash leds on rx/tx/err
                    // Uncomment to override default HW configurations
                    //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                    //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                    //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                    
                    #if defined(MY_USE_UDP)
                    #include <EthernetUdp.h>
                    #endif
                    #include <Ethernet.h>
                    #include <MySensors.h>
                    
                    void setup()
                    {
                    	// Setup locally attached sensors
                     sleep(250);    // Optional, if W5100 is rebooting
                    }
                    
                    void presentation()
                    {
                    	// Present locally attached sensors here
                    }
                    
                    void loop()
                    {
                    	// Send locally attached sensors data here
                    }
                    
                    
                    
                    1 Reply Last reply
                    1
                    • R Offline
                      R Offline
                      rafael156
                      wrote on last edited by rafael156
                      #25

                      To the Sensebender Board with W5100+NRF24:

                      • Sensebender can be flashed via Arduino IDE: Bootloader and Sketch
                      • Note versions (work):
                        Arduino IDE 1.6.13
                        Arduino AVR 1.6.18
                        Arduino SAMD 1.6.12
                        MySensors SAMD 1.0.5
                        MySensors Lib 2.3.1
                      • Installed is an Atmel "ATSAMD21J18A-AU".
                      • Windows 10 does not recognize the serial port after a few flashes (native USB ATSAMD21J18A-AU). Then the PC must be restarted.
                      • the bootloader has to be flashed via SWD interface (e.g. with Atmel JtagICE3):
                        -> install Atmel Studio 7 (for JtagICE3 drivers) and erase chip
                        -> Connect the pins of the JTAGICE3 to Sensebender:
                        JTAGICE3: ARM SWD Pin:
                        Pin 1 (TCK) SWDCLK
                        Pin 2 (GND) GND
                        Pin 4 (VTG) VCC
                        Pin 5 (TMS) SWDIO
                        Pin 6 (nSRST) nRESET
                        -> bootloader about Ardunio IDE flash: Programmer "Atmel EDBG or Atmel Sam ICE"
                        -> usb port should now be found automatically (windows 10 has drivers already integrated, install win7.8 driver from MySensors)
                      • sketch normal about arduino ide and port selection flashes

                      My working Sensebender W5100+NRF24 sketch:

                      /*
                       * The MySensors Arduino library handles the wireless radio link and protocol
                       * between your home built sensors/actuators and HA controller of choice.
                       * The sensors forms a self healing radio network with optional repeaters. Each
                       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                       * network topology allowing messages to be routed to nodes.
                       *
                       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                       * Copyright (C) 2013-2018 Sensnology AB
                       * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
                       *
                       * Documentation: http://www.mysensors.org
                       * Support Forum: http://forum.mysensors.org
                       *
                       * This program is free software; you can redistribute it and/or
                       * modify it under the terms of the GNU General Public License
                       * version 2 as published by the Free Software Foundation.
                       *
                       *******************************
                       *
                       * REVISION HISTORY
                       * Version 1.0 - Henrik EKblad
                       * Contribution by a-lurker and Anticimex,
                       * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
                       * Contribution by Tomas Hozza <thozza@gmail.com>
                       *
                       *
                       * DESCRIPTION
                       * The EthernetGateway sends data received from sensors to the ethernet link.
                       * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
                       *
                       * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
                       *
                       * LED purposes:
                       * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below
                       * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
                       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                       * - ERR (red) - fast blink on error during transmission error or receive crc error
                       *
                       * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
                       *
                       */
                      
                      //@riss
                      // Define sketch version
                      #define SKETCH_VERSION "0.4"
                      //@riss
                      
                      // Enable debug prints to serial monitor
                      #define MY_DEBUG
                      
                      // Enable and select radio type attached
                      #define MY_RADIO_RF24
                      //#define MY_RADIO_NRF5_ESB
                      //#define MY_RADIO_RFM69
                      //#define MY_RADIO_RFM95
                      
                      // Enable gateway ethernet module type
                      #define MY_GATEWAY_W5100
                      #define MY_GATEWAY_MAX_CLIENTS  3
                      
                      // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                      //#define MY_W5100_SPI_EN 4
                      
                      // Enable Soft SPI for NRF radio (note different radio wiring is required)
                      // The W5100 ethernet module seems to have a hard time co-operate with
                      // radio on the same spi bus.
                      #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                      #define MY_SOFTSPI
                      #define MY_SOFT_SPI_SCK_PIN 14
                      #define MY_SOFT_SPI_MISO_PIN 16
                      #define MY_SOFT_SPI_MOSI_PIN 15
                      #endif
                      
                      // When W5100 is connected we have to move CE/CSN pins for NRF radio
                      #ifndef MY_RF24_CE_PIN
                      #define MY_RF24_CE_PIN 5
                      #endif
                      #ifndef MY_RF24_CS_PIN
                      #define MY_RF24_CS_PIN 6
                      #endif
                      
                      // Enable UDP communication
                      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
                      
                      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                      #define MY_IP_ADDRESS 192,168,1,38
                      
                      // If using static ip you can define Gateway and Subnet address as well
                      #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                      #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                      
                      // Renewal period if using DHCP
                      //#define MY_IP_RENEWAL_INTERVAL 60000
                      
                      // The port to keep open on node server mode / or port to contact in client mode
                      #define MY_PORT 5003
                      
                      // Controller ip address. Enables client mode (default is "server" mode).
                      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
                      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
                      
                      // The MAC address can be anything you want but should be unique on your network.
                      // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                      // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                      
                      // Enable inclusion mode
                      #define MY_INCLUSION_MODE_FEATURE
                      // Enable Inclusion mode button on gateway
                      //#define MY_INCLUSION_BUTTON_FEATURE
                      // Set inclusion mode duration (in seconds)
                      #define MY_INCLUSION_MODE_DURATION 60
                      // Digital pin used for inclusion mode button
                      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
                      
                      // Set blinking period
                      #define MY_DEFAULT_LED_BLINK_PERIOD 300
                      
                      // Flash leds on rx/tx/err
                      // Uncomment to override default HW configurations
                      //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                      //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                      //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                      
                      #if defined(MY_USE_UDP)
                      #include <EthernetUdp.h>
                      #endif
                      #include <Ethernet.h>
                      #include <MySensors.h>
                      
                      //@riss
                      #include <SD.h>
                      #include <drivers/ATSHA204/ATSHA204.cpp>
                      
                      Sd2Card card;
                      
                      #define EEPROM_VERIFICATION_ADDRESS 0x01
                      
                      static uint8_t num_of_leds = 5;
                      static uint8_t leds[] = {LED_BLUE, LED_RED, LED_GREEN, LED_YELLOW, LED_ORANGE};
                      //@riss
                      
                      void setup()
                      {
                      	// Setup locally attached sensors
                       sleep(250);      // wait for the W5100
                      }
                      
                      void presentation()
                      {
                      	// Present locally attached sensors here
                      }
                      
                      void loop()
                      {
                      	// Send locally attached sensors data here
                      }
                      
                      
                      
                      
                      //@riss
                      void preHwInit()
                      {
                      
                        pinMode(MY_SWC1, INPUT_PULLUP);
                        pinMode(MY_SWC2, INPUT_PULLUP);
                        if (digitalRead(MY_SWC1) && digitalRead(MY_SWC2)) {
                          return;
                        }
                      
                        uint8_t tests = 0;
                      
                        for (int i=0; i< num_of_leds; i++) {
                          pinMode(leds[i], OUTPUT);
                        }
                        if (digitalRead(MY_SWC1)) {
                          uint8_t led_state = 0;
                          while (!Serial) {
                            digitalWrite(LED_BLUE, led_state);
                            led_state ^= 0x01;
                            delay(500);
                          } // Wait for USB to be connected, before spewing out data.
                        }
                        digitalWrite(LED_BLUE, LOW);
                        if (Serial) {
                          Serial.println("Sensebender GateWay test routine");
                          Serial.print("MySensors core version : ");
                          Serial.println(MYSENSORS_LIBRARY_VERSION);
                          Serial.print("GateWay sketch version : ");
                          Serial.println(SKETCH_VERSION);
                          Serial.println("----------------------------------");
                          Serial.println();
                        }
                        if (testSha204()) {
                          digitalWrite(LED_GREEN, HIGH);
                          tests++;
                        }
                        if (testSDCard()) {
                          digitalWrite(LED_YELLOW, HIGH);
                          tests++;
                        }
                      
                        if (testEEProm()) {
                          digitalWrite(LED_ORANGE, HIGH);
                          tests++;
                        }
                        if (testAnalog()) {
                          digitalWrite(LED_BLUE, HIGH);
                          tests++;
                        }
                        if (tests == 4) {
                          while(1) {
                            for (int i=0; i<num_of_leds; i++) {
                              digitalWrite(leds[i], HIGH);
                              delay(200);
                              digitalWrite(leds[i], LOW);
                            }
                          }
                        } else {
                          while (1) {
                            digitalWrite(LED_RED, HIGH);
                            delay(200);
                            digitalWrite(LED_RED, LOW);
                            delay(200);
                          }
                        }
                      
                      }
                      
                      bool testSha204()
                      {
                        uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
                        uint8_t ret_code;
                        if (Serial) {
                          Serial.print("- > SHA204 ");
                        }
                        atsha204_init(MY_SIGNING_ATSHA204_PIN);
                        ret_code = atsha204_wakeup(rx_buffer);
                      
                        if (ret_code == SHA204_SUCCESS) {
                          ret_code = atsha204_getSerialNumber(rx_buffer);
                          if (ret_code != SHA204_SUCCESS) {
                            if (Serial) {
                              Serial.println(F("Failed to obtain device serial number. Response: "));
                            }
                            Serial.println(ret_code, HEX);
                          } else {
                            if (Serial) {
                              Serial.print(F("Ok (serial : "));
                              for (int i=0; i<9; i++) {
                                if (rx_buffer[i] < 0x10) {
                                  Serial.print('0'); // Because Serial.print does not 0-pad HEX
                                }
                                Serial.print(rx_buffer[i], HEX);
                              }
                              Serial.println(")");
                            }
                            return true;
                          }
                        } else {
                          if (Serial) {
                            Serial.println(F("Failed to wakeup SHA204"));
                          }
                        }
                        return false;
                      }
                      
                      bool testSDCard()
                      {
                        if (Serial) {
                          Serial.print("- > SD CARD ");
                        }
                        if (!card.init(SPI_HALF_SPEED, MY_SDCARD_CS)) {
                          if (Serial) {
                            Serial.println("SD CARD did not initialize!");
                          }
                        } else {
                          if (Serial) {
                            Serial.print("SD Card initialized correct! - ");
                            Serial.print("type detected : ");
                            switch(card.type()) {
                            case SD_CARD_TYPE_SD1:
                              Serial.println("SD1");
                              break;
                            case SD_CARD_TYPE_SD2:
                              Serial.println("SD2");
                              break;
                            case SD_CARD_TYPE_SDHC:
                              Serial.println("SDHC");
                              break;
                            default:
                              Serial.println("Unknown");
                            }
                          }
                          return true;
                        }
                        return false;
                      }
                      
                      bool testEEProm()
                      {
                        uint8_t eeprom_d1, eeprom_d2;
                        SerialUSB.print(" -> EEPROM ");
                        eeprom_d1 = hwReadConfig(EEPROM_VERIFICATION_ADDRESS);
                        delay(500);
                        eeprom_d1 = ~eeprom_d1; // invert the bits
                        hwWriteConfig(EEPROM_VERIFICATION_ADDRESS, eeprom_d1);
                        delay(500);
                        eeprom_d2 = hwReadConfig(EEPROM_VERIFICATION_ADDRESS);
                        if (eeprom_d1 == eeprom_d2) {
                          SerialUSB.println("PASSED");
                          hwWriteConfig(EEPROM_VERIFICATION_ADDRESS, ~eeprom_d1);
                          return true;
                        }
                        SerialUSB.println("FAILED!");
                        return false;
                      }
                      
                      bool testAnalog()
                      {
                        int bat_detect = analogRead(MY_BAT_DETECT);
                        Serial.print("-> analog : ");
                        Serial.print(bat_detect);
                        if (bat_detect < 400 || bat_detect > 650) {
                          Serial.println(" Failed");
                          return false;
                        }
                        Serial.println(" Passed");
                        return true;
                      }
                      //@riss
                      
                      JCLBJ 1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        rafael156
                        wrote on last edited by
                        #26

                        Thanks to everyone who helped! now it would be interesting again, if it also works with the latest SAMD and arduino ide versions...?! has somebody already tested it/ been running?

                        1 Reply Last reply
                        0
                        • tbowmoT Offline
                          tbowmoT Offline
                          tbowmo
                          Admin
                          wrote on last edited by
                          #27

                          it should not be necessary to use atmel studio to erase the SAMD21, before you reflash with arduino. The erase cycle is included in the flashing process..

                          I haven't updated any of my SAMD21 boards the last year, so don't know if the latest arduino breaks something.

                          alexsh1A 1 Reply Last reply
                          0
                          • tbowmoT tbowmo

                            it should not be necessary to use atmel studio to erase the SAMD21, before you reflash with arduino. The erase cycle is included in the flashing process..

                            I haven't updated any of my SAMD21 boards the last year, so don't know if the latest arduino breaks something.

                            alexsh1A Offline
                            alexsh1A Offline
                            alexsh1
                            wrote on last edited by
                            #28

                            @tbowmo said in not working Ethernet Gateway (sensebender and/or nano gateway):

                            I haven't updated any of my SAMD21 boards the last year, so don't know if the latest arduino breaks something.

                            I updated SAMD21 (Sensebender) with the latest Arduino and nothing has been broken.
                            I have not tested it extensively though.

                            1 Reply Last reply
                            0
                            • R Offline
                              R Offline
                              rollin
                              wrote on last edited by
                              #29

                              the pinout of the jtagice 3 is not compatible with the cortex m0 debug port pinout. So check the pinout of both devices first to be sure that they match.

                              tbowmoT 1 Reply Last reply
                              0
                              • R rollin

                                the pinout of the jtagice 3 is not compatible with the cortex m0 debug port pinout. So check the pinout of both devices first to be sure that they match.

                                tbowmoT Offline
                                tbowmoT Offline
                                tbowmo
                                Admin
                                wrote on last edited by
                                #30

                                @rollin said in not working Ethernet Gateway (sensebender and/or nano gateway):

                                the pinout of the jtagice 3 is not compatible with the cortex m0 debug port pinout. So check the pinout of both devices first to be sure that they match.

                                Yes, they do not match.. I created https://www.openhardware.io/view/192/Jtag-ICE3-breakout to make them compatible :)

                                1 Reply Last reply
                                0
                                • R rafael156

                                  To the Sensebender Board with W5100+NRF24:

                                  • Sensebender can be flashed via Arduino IDE: Bootloader and Sketch
                                  • Note versions (work):
                                    Arduino IDE 1.6.13
                                    Arduino AVR 1.6.18
                                    Arduino SAMD 1.6.12
                                    MySensors SAMD 1.0.5
                                    MySensors Lib 2.3.1
                                  • Installed is an Atmel "ATSAMD21J18A-AU".
                                  • Windows 10 does not recognize the serial port after a few flashes (native USB ATSAMD21J18A-AU). Then the PC must be restarted.
                                  • the bootloader has to be flashed via SWD interface (e.g. with Atmel JtagICE3):
                                    -> install Atmel Studio 7 (for JtagICE3 drivers) and erase chip
                                    -> Connect the pins of the JTAGICE3 to Sensebender:
                                    JTAGICE3: ARM SWD Pin:
                                    Pin 1 (TCK) SWDCLK
                                    Pin 2 (GND) GND
                                    Pin 4 (VTG) VCC
                                    Pin 5 (TMS) SWDIO
                                    Pin 6 (nSRST) nRESET
                                    -> bootloader about Ardunio IDE flash: Programmer "Atmel EDBG or Atmel Sam ICE"
                                    -> usb port should now be found automatically (windows 10 has drivers already integrated, install win7.8 driver from MySensors)
                                  • sketch normal about arduino ide and port selection flashes

                                  My working Sensebender W5100+NRF24 sketch:

                                  /*
                                   * The MySensors Arduino library handles the wireless radio link and protocol
                                   * between your home built sensors/actuators and HA controller of choice.
                                   * The sensors forms a self healing radio network with optional repeaters. Each
                                   * repeater and gateway builds a routing tables in EEPROM which keeps track of the
                                   * network topology allowing messages to be routed to nodes.
                                   *
                                   * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
                                   * Copyright (C) 2013-2018 Sensnology AB
                                   * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
                                   *
                                   * Documentation: http://www.mysensors.org
                                   * Support Forum: http://forum.mysensors.org
                                   *
                                   * This program is free software; you can redistribute it and/or
                                   * modify it under the terms of the GNU General Public License
                                   * version 2 as published by the Free Software Foundation.
                                   *
                                   *******************************
                                   *
                                   * REVISION HISTORY
                                   * Version 1.0 - Henrik EKblad
                                   * Contribution by a-lurker and Anticimex,
                                   * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
                                   * Contribution by Tomas Hozza <thozza@gmail.com>
                                   *
                                   *
                                   * DESCRIPTION
                                   * The EthernetGateway sends data received from sensors to the ethernet link.
                                   * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
                                   *
                                   * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
                                   *
                                   * LED purposes:
                                   * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below
                                   * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
                                   * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                                   * - ERR (red) - fast blink on error during transmission error or receive crc error
                                   *
                                   * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
                                   *
                                   */
                                  
                                  //@riss
                                  // Define sketch version
                                  #define SKETCH_VERSION "0.4"
                                  //@riss
                                  
                                  // Enable debug prints to serial monitor
                                  #define MY_DEBUG
                                  
                                  // Enable and select radio type attached
                                  #define MY_RADIO_RF24
                                  //#define MY_RADIO_NRF5_ESB
                                  //#define MY_RADIO_RFM69
                                  //#define MY_RADIO_RFM95
                                  
                                  // Enable gateway ethernet module type
                                  #define MY_GATEWAY_W5100
                                  #define MY_GATEWAY_MAX_CLIENTS  3
                                  
                                  // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                                  //#define MY_W5100_SPI_EN 4
                                  
                                  // Enable Soft SPI for NRF radio (note different radio wiring is required)
                                  // The W5100 ethernet module seems to have a hard time co-operate with
                                  // radio on the same spi bus.
                                  #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
                                  #define MY_SOFTSPI
                                  #define MY_SOFT_SPI_SCK_PIN 14
                                  #define MY_SOFT_SPI_MISO_PIN 16
                                  #define MY_SOFT_SPI_MOSI_PIN 15
                                  #endif
                                  
                                  // When W5100 is connected we have to move CE/CSN pins for NRF radio
                                  #ifndef MY_RF24_CE_PIN
                                  #define MY_RF24_CE_PIN 5
                                  #endif
                                  #ifndef MY_RF24_CS_PIN
                                  #define MY_RF24_CS_PIN 6
                                  #endif
                                  
                                  // Enable UDP communication
                                  //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
                                  
                                  // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                                  #define MY_IP_ADDRESS 192,168,1,38
                                  
                                  // If using static ip you can define Gateway and Subnet address as well
                                  #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                                  #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                                  
                                  // Renewal period if using DHCP
                                  //#define MY_IP_RENEWAL_INTERVAL 60000
                                  
                                  // The port to keep open on node server mode / or port to contact in client mode
                                  #define MY_PORT 5003
                                  
                                  // Controller ip address. Enables client mode (default is "server" mode).
                                  // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
                                  //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
                                  
                                  // The MAC address can be anything you want but should be unique on your network.
                                  // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
                                  // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
                                  #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                                  
                                  // Enable inclusion mode
                                  #define MY_INCLUSION_MODE_FEATURE
                                  // Enable Inclusion mode button on gateway
                                  //#define MY_INCLUSION_BUTTON_FEATURE
                                  // Set inclusion mode duration (in seconds)
                                  #define MY_INCLUSION_MODE_DURATION 60
                                  // Digital pin used for inclusion mode button
                                  //#define MY_INCLUSION_MODE_BUTTON_PIN  3
                                  
                                  // Set blinking period
                                  #define MY_DEFAULT_LED_BLINK_PERIOD 300
                                  
                                  // Flash leds on rx/tx/err
                                  // Uncomment to override default HW configurations
                                  //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                                  //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                                  //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
                                  
                                  #if defined(MY_USE_UDP)
                                  #include <EthernetUdp.h>
                                  #endif
                                  #include <Ethernet.h>
                                  #include <MySensors.h>
                                  
                                  //@riss
                                  #include <SD.h>
                                  #include <drivers/ATSHA204/ATSHA204.cpp>
                                  
                                  Sd2Card card;
                                  
                                  #define EEPROM_VERIFICATION_ADDRESS 0x01
                                  
                                  static uint8_t num_of_leds = 5;
                                  static uint8_t leds[] = {LED_BLUE, LED_RED, LED_GREEN, LED_YELLOW, LED_ORANGE};
                                  //@riss
                                  
                                  void setup()
                                  {
                                  	// Setup locally attached sensors
                                   sleep(250);      // wait for the W5100
                                  }
                                  
                                  void presentation()
                                  {
                                  	// Present locally attached sensors here
                                  }
                                  
                                  void loop()
                                  {
                                  	// Send locally attached sensors data here
                                  }
                                  
                                  
                                  
                                  
                                  //@riss
                                  void preHwInit()
                                  {
                                  
                                    pinMode(MY_SWC1, INPUT_PULLUP);
                                    pinMode(MY_SWC2, INPUT_PULLUP);
                                    if (digitalRead(MY_SWC1) && digitalRead(MY_SWC2)) {
                                      return;
                                    }
                                  
                                    uint8_t tests = 0;
                                  
                                    for (int i=0; i< num_of_leds; i++) {
                                      pinMode(leds[i], OUTPUT);
                                    }
                                    if (digitalRead(MY_SWC1)) {
                                      uint8_t led_state = 0;
                                      while (!Serial) {
                                        digitalWrite(LED_BLUE, led_state);
                                        led_state ^= 0x01;
                                        delay(500);
                                      } // Wait for USB to be connected, before spewing out data.
                                    }
                                    digitalWrite(LED_BLUE, LOW);
                                    if (Serial) {
                                      Serial.println("Sensebender GateWay test routine");
                                      Serial.print("MySensors core version : ");
                                      Serial.println(MYSENSORS_LIBRARY_VERSION);
                                      Serial.print("GateWay sketch version : ");
                                      Serial.println(SKETCH_VERSION);
                                      Serial.println("----------------------------------");
                                      Serial.println();
                                    }
                                    if (testSha204()) {
                                      digitalWrite(LED_GREEN, HIGH);
                                      tests++;
                                    }
                                    if (testSDCard()) {
                                      digitalWrite(LED_YELLOW, HIGH);
                                      tests++;
                                    }
                                  
                                    if (testEEProm()) {
                                      digitalWrite(LED_ORANGE, HIGH);
                                      tests++;
                                    }
                                    if (testAnalog()) {
                                      digitalWrite(LED_BLUE, HIGH);
                                      tests++;
                                    }
                                    if (tests == 4) {
                                      while(1) {
                                        for (int i=0; i<num_of_leds; i++) {
                                          digitalWrite(leds[i], HIGH);
                                          delay(200);
                                          digitalWrite(leds[i], LOW);
                                        }
                                      }
                                    } else {
                                      while (1) {
                                        digitalWrite(LED_RED, HIGH);
                                        delay(200);
                                        digitalWrite(LED_RED, LOW);
                                        delay(200);
                                      }
                                    }
                                  
                                  }
                                  
                                  bool testSha204()
                                  {
                                    uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
                                    uint8_t ret_code;
                                    if (Serial) {
                                      Serial.print("- > SHA204 ");
                                    }
                                    atsha204_init(MY_SIGNING_ATSHA204_PIN);
                                    ret_code = atsha204_wakeup(rx_buffer);
                                  
                                    if (ret_code == SHA204_SUCCESS) {
                                      ret_code = atsha204_getSerialNumber(rx_buffer);
                                      if (ret_code != SHA204_SUCCESS) {
                                        if (Serial) {
                                          Serial.println(F("Failed to obtain device serial number. Response: "));
                                        }
                                        Serial.println(ret_code, HEX);
                                      } else {
                                        if (Serial) {
                                          Serial.print(F("Ok (serial : "));
                                          for (int i=0; i<9; i++) {
                                            if (rx_buffer[i] < 0x10) {
                                              Serial.print('0'); // Because Serial.print does not 0-pad HEX
                                            }
                                            Serial.print(rx_buffer[i], HEX);
                                          }
                                          Serial.println(")");
                                        }
                                        return true;
                                      }
                                    } else {
                                      if (Serial) {
                                        Serial.println(F("Failed to wakeup SHA204"));
                                      }
                                    }
                                    return false;
                                  }
                                  
                                  bool testSDCard()
                                  {
                                    if (Serial) {
                                      Serial.print("- > SD CARD ");
                                    }
                                    if (!card.init(SPI_HALF_SPEED, MY_SDCARD_CS)) {
                                      if (Serial) {
                                        Serial.println("SD CARD did not initialize!");
                                      }
                                    } else {
                                      if (Serial) {
                                        Serial.print("SD Card initialized correct! - ");
                                        Serial.print("type detected : ");
                                        switch(card.type()) {
                                        case SD_CARD_TYPE_SD1:
                                          Serial.println("SD1");
                                          break;
                                        case SD_CARD_TYPE_SD2:
                                          Serial.println("SD2");
                                          break;
                                        case SD_CARD_TYPE_SDHC:
                                          Serial.println("SDHC");
                                          break;
                                        default:
                                          Serial.println("Unknown");
                                        }
                                      }
                                      return true;
                                    }
                                    return false;
                                  }
                                  
                                  bool testEEProm()
                                  {
                                    uint8_t eeprom_d1, eeprom_d2;
                                    SerialUSB.print(" -> EEPROM ");
                                    eeprom_d1 = hwReadConfig(EEPROM_VERIFICATION_ADDRESS);
                                    delay(500);
                                    eeprom_d1 = ~eeprom_d1; // invert the bits
                                    hwWriteConfig(EEPROM_VERIFICATION_ADDRESS, eeprom_d1);
                                    delay(500);
                                    eeprom_d2 = hwReadConfig(EEPROM_VERIFICATION_ADDRESS);
                                    if (eeprom_d1 == eeprom_d2) {
                                      SerialUSB.println("PASSED");
                                      hwWriteConfig(EEPROM_VERIFICATION_ADDRESS, ~eeprom_d1);
                                      return true;
                                    }
                                    SerialUSB.println("FAILED!");
                                    return false;
                                  }
                                  
                                  bool testAnalog()
                                  {
                                    int bat_detect = analogRead(MY_BAT_DETECT);
                                    Serial.print("-> analog : ");
                                    Serial.print(bat_detect);
                                    if (bat_detect < 400 || bat_detect > 650) {
                                      Serial.println(" Failed");
                                      return false;
                                    }
                                    Serial.println(" Passed");
                                    return true;
                                  }
                                  //@riss
                                  
                                  JCLBJ Offline
                                  JCLBJ Offline
                                  JCLB
                                  wrote on last edited by
                                  #31

                                  @rafael156 said in not working Ethernet Gateway (sensebender and/or nano gateway):

                                  To the Sensebender Board with W5100+NRF24:

                                  • Sensebender can be flashed via Arduino IDE: Bootloader and Sketch
                                  • Note versions (work):
                                    Arduino IDE 1.6.13
                                    Arduino AVR 1.6.18
                                    Arduino SAMD 1.6.12
                                    MySensors SAMD 1.0.5
                                    MySensors Lib 2.3.1

                                  Thanks a lot ! ! !
                                  I've lost 2 days trying to understand why it was not working anymore while uploading the exact same sketch as before !

                                  Last release are not that stable finally.

                                  1 Reply Last reply
                                  0
                                  • JenniferTJ Offline
                                    JenniferTJ Offline
                                    JenniferT
                                    Banned
                                    wrote on last edited by
                                    #32
                                    This post is deleted!
                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    36

                                    Online

                                    11.7k

                                    Users

                                    11.2k

                                    Topics

                                    113.1k

                                    Posts


                                    Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • MySensors
                                    • OpenHardware.io
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular