Skip to content
  • 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. Development
  3. [Solved] How to adjust MySBootloader files to compile other EN & CSN pins different channel and external 8MHz crystal
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

[Solved] How to adjust MySBootloader files to compile other EN & CSN pins different channel and external 8MHz crystal

Scheduled Pinned Locked Moved Development
26 Posts 2 Posters 140 Views 2 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.
  • JoeridemanJ Offline
    JoeridemanJ Offline
    Joerideman
    wrote on last edited by tekka
    #1

    It took some time to learn how to use the make program. But I figured this out. But, with every version of bootloader that I create, I can not upload a sketch using the Serial programming via the Arduino IDE. This is possible with the 8MHz internal osc bootloader in the MySbootloader folders.

    I used this repository https://github.com/mysensors/MySensorsBootloaderRF24

    I have made a few changes/additions in different files:

    mysbootloader.c --> #define RF24_CHANNEL (122)
    makefile -->CLK = 8000000L  
    BAUDRATE = 57600 
    ISP_HFUSE = D2 //DA and 
    ISP_LFUSE = FF //F7 and 
    ISP_EFUSE = 06 //was 06 /FE
    HW.h --> #elif defined(SPI_PINS_CE8_CSN9)
    	#define CSN_PORT	PORTB	// port for CSN
    	#define CSN_DDR		DDRB	// DDR for CSN
    	#define	CSN_PIN		PB1		// Arduino Pin 9 <-> Bit 1 of port B
    
    	#define CE_PORT		PORTB	// port for CE
    	#define CE_DDR		DDRB	// DDR for CE
    	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
    
    HW.h --> 	#elif defined(SPI_PINS_CE8_CSN9)
    		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
    		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN) | ~_BV(SPI_MISO);
    	
    

    I was not sure what this part is used for, so I experimented giving it the same fusesettings as I use in the boards.txt

    ISP_HFUSE = D2 //DA and 
    ISP_LFUSE = FF //F7 and 
    ISP_EFUSE = 06 //was 06 /FE
    

    So I want to use:
    8 MHz external oscillator. (alltough I start to wonder now how important an oscillator is)
    PB0 or pin 8 for CE
    PB1 or pin 9 for CSN
    RFChannel 122

    tekkaT 1 Reply Last reply
    0
    • JoeridemanJ Joerideman

      It took some time to learn how to use the make program. But I figured this out. But, with every version of bootloader that I create, I can not upload a sketch using the Serial programming via the Arduino IDE. This is possible with the 8MHz internal osc bootloader in the MySbootloader folders.

      I used this repository https://github.com/mysensors/MySensorsBootloaderRF24

      I have made a few changes/additions in different files:

      mysbootloader.c --> #define RF24_CHANNEL (122)
      makefile -->CLK = 8000000L  
      BAUDRATE = 57600 
      ISP_HFUSE = D2 //DA and 
      ISP_LFUSE = FF //F7 and 
      ISP_EFUSE = 06 //was 06 /FE
      HW.h --> #elif defined(SPI_PINS_CE8_CSN9)
      	#define CSN_PORT	PORTB	// port for CSN
      	#define CSN_DDR		DDRB	// DDR for CSN
      	#define	CSN_PIN		PB1		// Arduino Pin 9 <-> Bit 1 of port B
      
      	#define CE_PORT		PORTB	// port for CE
      	#define CE_DDR		DDRB	// DDR for CE
      	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
      
      HW.h --> 	#elif defined(SPI_PINS_CE8_CSN9)
      		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
      		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN) | ~_BV(SPI_MISO);
      	
      

      I was not sure what this part is used for, so I experimented giving it the same fusesettings as I use in the boards.txt

      ISP_HFUSE = D2 //DA and 
      ISP_LFUSE = FF //F7 and 
      ISP_EFUSE = 06 //was 06 /FE
      

      So I want to use:
      8 MHz external oscillator. (alltough I start to wonder now how important an oscillator is)
      PB0 or pin 8 for CE
      PB1 or pin 9 for CSN
      RFChannel 122

      tekkaT Offline
      tekkaT Offline
      tekka
      Admin
      wrote on last edited by tekka
      #2

      @Joerideman What board are you using? Also, please post the entire SPI communication section from HW.h for full reference.

      1 Reply Last reply
      0
      • JoeridemanJ Offline
        JoeridemanJ Offline
        Joerideman
        wrote on last edited by Joerideman
        #3

        I am using my own board. ATmega328P-AU with 8MHz external crystal osc. Shown on this page:
        https://forum.mysensors.org/topic/11158/please-check-my-pcb-design-for-24v-led-dimmer

        hw.h:

        /* 
         * MYSBootloader 1.3.0-rc.1
         * OTA RF24 bootloader for MySensors: https://www.mysensors.org
         * Based on MySensors library 2.2
         * Developed and maintained by tekka 2018
         */
        
        #ifndef HW_H
        #define HW_H
        
        // hardware
        # define UART_SRA UCSR0A
        # define UART_SRB UCSR0B
        # define UART_SRC UCSR0C
        # define UART_SRL UBRR0L
        # define UART_UDR UDR0
        
        /* set the UART baud rate defaults */
        #ifndef BAUD_RATE
        	#if F_CPU >= 16000000L
        		#define BAUD_RATE   115200L
        	#elif F_CPU >= 8000000L
        		#define BAUD_RATE   57600L
        	#elif F_CPU >= 1000000L
        		#define BAUD_RATE   9600L   // 19200 also supported, but with significant error
        	#elif F_CPU >= 128000L
        		#define BAUD_RATE   4800L   // Good for 128kHz internal RC
        	#else
        		#define BAUD_RATE 1200L     // Good even at 32768Hz
        	#endif
        #endif
        
        #ifndef UART
        	#define UART 0
        #endif
        
        #define BAUD_SETTING (( (F_CPU + BAUD_RATE * 4L) / ((BAUD_RATE * 8L))) - 1 )
        #define BAUD_ACTUAL (F_CPU/(8 * ((BAUD_SETTING)+1)))
        #if BAUD_ACTUAL <= BAUD_RATE
        	#define BAUD_ERROR (( 100*(BAUD_RATE - BAUD_ACTUAL) ) / BAUD_RATE)
        	#if BAUD_ERROR >= 5
        		#error BAUD_RATE error greater than -5%
        	#elif BAUD_ERROR >= 2
        		#warning BAUD_RATE error greater than -2%
        	#endif
        #else
        	#define BAUD_ERROR (( 100*(BAUD_ACTUAL - BAUD_RATE) ) / BAUD_RATE)
        	#if BAUD_ERROR >= 5
        		#error BAUD_RATE error greater than 5%
        	#elif BAUD_ERROR >= 2
        		#warning BAUD_RATE error greater than 2%
        	#endif
        #endif
        
        #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250
        	#error Unachievable baud rate (too slow) BAUD_RATE
        #endif // baud rate slow check
        #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3
        	#if BAUD_ERROR != 0 // permit high bitrates (ie 1Mbps@16MHz) if error is zero
        		#error Unachievable baud rate (too fast) BAUD_RATE
        	#endif
        #endif
        
        // Watchdog definitions and functions
        #define WATCHDOG_OFF    (0)
        #define WATCHDOG_16MS   (_BV(WDE))
        #define WATCHDOG_32MS   (_BV(WDP0) | _BV(WDE))
        #define WATCHDOG_64MS   (_BV(WDP1) | _BV(WDE))
        #define WATCHDOG_125MS  (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
        #define WATCHDOG_250MS  (_BV(WDP2) | _BV(WDE))
        #define WATCHDOG_500MS  (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
        #define WATCHDOG_1S     (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
        #define WATCHDOG_2S     (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
        #define WATCHDOG_4S     (_BV(WDP3) | _BV(WDE))
        #define WATCHDOG_8S     (_BV(WDP3) | _BV(WDP0) | _BV(WDE))
        
        
        static inline void watchdogReset(void) {
        	__asm__ __volatile__ ("wdr\n");
        }
        
        static void watchdogConfig(const uint8_t wdtConfig) {
        	WDTCSR = _BV(WDCE) | _BV(WDE);
        	WDTCSR = wdtConfig;
        }
        
        
        // SPI communication
        #define SPI_PORT	PORTB	// 
        #define SPI_DDR		DDRB	// 
        #define	SPI_SCLK	PB5		// Arduino Pin 13 <-> Bit 5 of port B
        #define	SPI_MISO	PB4		// Arduino Pin 12 <-> Bit 4 of port B
        #define	SPI_MOSI	PB3		// Arduino Pin 11 <-> Bit 3 of port B
        
        #if defined(SPI_PINS_CE9_CSN10)
        	#define CSN_PORT	PORTB	// port for CSN
        	#define CSN_DDR		DDRB	// DDR for CSN
        	#define	CSN_PIN		PB2		// Arduino Pin 10 <-> Bit 2 of port B
        
        	#define CE_PORT		PORTB	// port for CE 
        	#define CE_DDR		DDRB	// DDR for CE
        	#define	CE_PIN		PB1		// Arduino Pin  9 <-> Bit 1 of port B
        	
        #elif defined(SPI_PINS_CE8_CSN9)
        	#define CSN_PORT	PORTB	// port for CSN
        	#define CSN_DDR		DDRB	// DDR for CSN
        	#define	CSN_PIN		PB1		// Arduino Pin 9 <-> Bit 1 of port B
        
        	#define CE_PORT		PORTB	// port for CE
        	#define CE_DDR		DDRB	// DDR for CE
        	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
        	
        #elif defined(SPI_PINS_CSN7_CE8)
        	#define CSN_PORT	PORTD	// port for CSN
        	#define CSN_DDR		DDRD	// DDR for CSN
        	#define	CSN_PIN		PD7		// Arduino Pin 7 <-> Bit 7 of port D
        
        	#define CE_PORT		PORTB	// port for CE
        	#define CE_DDR		DDRB	// DDR for CE
        	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
        #elif defined(SPI_PINS_CE4_CSN10)
        	#define CSN_PORT	PORTB	// port for CSN
        	#define CSN_DDR		DDRB	// DDR for CSN
        	#define	CSN_PIN		PB2		// Arduino Pin 10 <-> Bit 2 of port B
        
        	#define CE_PORT		PORTD	// port for CE
        	#define CE_DDR		DDRD	// DDR for CE
        	#define	CE_PIN		PD4		// Arduino Pin  4 <-> Bit 4 of port D
        #elif defined(SPI_PINS_CE7_CSN10)
        	// NRF24Duino Configuration
        	#define CE_PORT		PORTD	// port for CE
        	#define CE_DDR		DDRD	// DDR for CE
        	#define	CE_PIN		PD7		// Arduino Pin 7 <-> Bit 7 of port D
        
        	#define CSN_PORT	PORTB	// port for CSN
        	#define CSN_DDR		DDRB	// DDR for CSN
        	#define	CSN_PIN		PB2		// Arduino Pin  10 <-> Bit 2 of port B
        	// NRF24Duino has LED on Pin 9 set the LED_PIN in MYSBootloader.c to PB1
        #endif
        
        #define CSN_LOW()	CSN_PORT &= ~_BV(CSN_PIN)
        #define CSN_HIGH()	CSN_PORT |= _BV(CSN_PIN)
        #define CE_LOW()	CE_PORT &= ~_BV(CE_PIN)
        #define CE_HIGH()	CE_PORT |= _BV(CE_PIN)
        
        
        static void initSPI(void) {
        	// Initialize the SPI pins: SCK, MOSI, CE, CSN as outputs, MISO as input
        	#if defined(SPI_PINS_CE9_CSN10)
        		// CSN_PIN (=PB2) is SS pin and set as output
        		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN);
        	#elif defined(SPI_PINS_CSN7_CE8)
        		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
        		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2);	
        		CSN_DDR = _BV(CSN_PIN);
        	#elif defined(SPI_PINS_CE4_CSN10)
        		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
        		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(PB2) | _BV(CSN_PIN);
        		CE_DDR = _BV(CE_PIN);
        	#elif defined(SPI_PINS_CE7_CSN10)
        		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
        		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(PB2) | _BV(CSN_PIN);
        		CE_DDR = _BV(CE_PIN);
        	#elif defined(SPI_PINS_CE8_CSN9)
        		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
        		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN) | ~_BV(SPI_MISO);
        	
        	#endif
        	
        	// SPE	=	SPI enable
        	// SPIE	=	SPI interrupt enable
        	// DORD	=	data order (0:MSB first, 1:LSB first)
        	// MSTR	=	Master/Slave select
        	// SPR1	=	SPI clock rate bit 1
        	// SPR0	=	SPI clock rate bit 0; 0,0=osc/4, 0,1=osc/16, 1,0=osc/64, 1,1=osc/128
        	// CPOL	=	clock polarity idle (0:low, 1:high)
        	// CPHA	=	clock phase edge sampling (0:leading, 1:trailing)
        	
        	// SPI speed setting, nRF24L01P max. 10Mhz	
        	#if (F_CPU >= 16000000)
        		// DIV 16 = 1 Mhz
        		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
        	#elif (F_CPU >= 8000000)
        		// DIV 8 = 1 Mhz
        		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
        		SPSR = _BV(SPI2X);  
        	#elif (F_CPU >= 4000000)
        		// DIV 4 = 1Mhz
        		SPCR = _BV(SPE) | _BV(MSTR);
        	#elif (F_CPU >= 2000000)
        		// DIV 2 = 1 Mhz
        		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
        		SPSR = _BV(SPI2X);
        	#else
        		// DIV 2 <= 0.5 Mhz
        		SPCR = _BV(SPE) | _BV(MSTR);
        		SPSR = _BV(SPI2X); 
        	#endif          
        	
        }
        static uint8_t SPItransfer(const uint8_t value) {
        	SPDR = value;
        	while(!(SPSR & _BV(SPIF)));		// wait until transmitted
        	return SPDR;
        }
        static inline void SPIclose(void) {
        	// disable hardware SPI
        	SPCR = 0;	
        }
        
        
        // UART
        static void initUART(void) {
        	UART_SRA = _BV(U2X0); //Double speed mode USART0
        	UART_SRB = _BV(RXEN0) | _BV(TXEN0);
        	UART_SRC = _BV(UCSZ00) | _BV(UCSZ01);
        	UART_SRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
        }
        
        void putch(const uint8_t ch) {
        	while (!(UART_SRA & _BV(UDRE0)));
        	UART_UDR = ch;
        }
        
        static uint8_t getch(void) {
        	// wait until char received
        	while(!(UART_SRA & _BV(RXC0)));
        	// 10 bytes
        	// framing error?
        	if (!(UART_SRA & _BV(FE0))) {
        		watchdogReset();
        	}
        	return UART_UDR;
        }
        
        static inline void writeTemporaryBuffer(const uint16_t address, const uint16_t data) {
        	// fill temporary page buffer
        	__boot_page_fill_short(address, data);
        }
        
        static void programPage(const uint16_t page){
        	__boot_page_erase_short(page);	// erase page
        	boot_spm_busy_wait();
        	__boot_page_write_short(page);	// program page
        	boot_spm_busy_wait();
        	__boot_rww_enable_short();		// re-enable RWW
        }
        
        static uint16_t crc16_update(uint16_t crc, const uint8_t data) {
        	crc ^= data;
        	for (uint8_t i = 0; i < 8; ++i) {
        		crc = (crc >> 1) ^ (-(int16_t)(crc & 1) & 0xA001);
        	}
        	return crc;
        }
        
        static uint16_t calcCRCrom (const uint16_t len) {
        	// init CRC
        	uint16_t _internal_crc = 0xFFFF;	
        	// start address for CRC calculation
        	uint16_t address = 0x0000;
        	// calc and prevent overflow
        	while (address < len && address < BOOTLOADER_START_ADDRESS) {
        		uint8_t _rom_byte;
        		// read a flash byte and increment the address
        		__asm__ ("lpm %0,Z+\n" : "=r" (_rom_byte), "=z" (address): "1" (address));
        		_internal_crc = crc16_update(_internal_crc,_rom_byte);
        	}
        	return _internal_crc;
        }
        
        static void blinkLed(void) {
        	LED_DDR |= _BV(LED_PIN);
        	//300ms total
        	for (uint8_t i = 0; i < 6; i++) {
        		LED_PORT ^= _BV(LED_PIN);
        		_delay_ms(50);		
        	}
        }
        
        
        #endif // HW_H
        
        
        tekkaT 1 Reply Last reply
        0
        • JoeridemanJ Joerideman

          I am using my own board. ATmega328P-AU with 8MHz external crystal osc. Shown on this page:
          https://forum.mysensors.org/topic/11158/please-check-my-pcb-design-for-24v-led-dimmer

          hw.h:

          /* 
           * MYSBootloader 1.3.0-rc.1
           * OTA RF24 bootloader for MySensors: https://www.mysensors.org
           * Based on MySensors library 2.2
           * Developed and maintained by tekka 2018
           */
          
          #ifndef HW_H
          #define HW_H
          
          // hardware
          # define UART_SRA UCSR0A
          # define UART_SRB UCSR0B
          # define UART_SRC UCSR0C
          # define UART_SRL UBRR0L
          # define UART_UDR UDR0
          
          /* set the UART baud rate defaults */
          #ifndef BAUD_RATE
          	#if F_CPU >= 16000000L
          		#define BAUD_RATE   115200L
          	#elif F_CPU >= 8000000L
          		#define BAUD_RATE   57600L
          	#elif F_CPU >= 1000000L
          		#define BAUD_RATE   9600L   // 19200 also supported, but with significant error
          	#elif F_CPU >= 128000L
          		#define BAUD_RATE   4800L   // Good for 128kHz internal RC
          	#else
          		#define BAUD_RATE 1200L     // Good even at 32768Hz
          	#endif
          #endif
          
          #ifndef UART
          	#define UART 0
          #endif
          
          #define BAUD_SETTING (( (F_CPU + BAUD_RATE * 4L) / ((BAUD_RATE * 8L))) - 1 )
          #define BAUD_ACTUAL (F_CPU/(8 * ((BAUD_SETTING)+1)))
          #if BAUD_ACTUAL <= BAUD_RATE
          	#define BAUD_ERROR (( 100*(BAUD_RATE - BAUD_ACTUAL) ) / BAUD_RATE)
          	#if BAUD_ERROR >= 5
          		#error BAUD_RATE error greater than -5%
          	#elif BAUD_ERROR >= 2
          		#warning BAUD_RATE error greater than -2%
          	#endif
          #else
          	#define BAUD_ERROR (( 100*(BAUD_ACTUAL - BAUD_RATE) ) / BAUD_RATE)
          	#if BAUD_ERROR >= 5
          		#error BAUD_RATE error greater than 5%
          	#elif BAUD_ERROR >= 2
          		#warning BAUD_RATE error greater than 2%
          	#endif
          #endif
          
          #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250
          	#error Unachievable baud rate (too slow) BAUD_RATE
          #endif // baud rate slow check
          #if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3
          	#if BAUD_ERROR != 0 // permit high bitrates (ie 1Mbps@16MHz) if error is zero
          		#error Unachievable baud rate (too fast) BAUD_RATE
          	#endif
          #endif
          
          // Watchdog definitions and functions
          #define WATCHDOG_OFF    (0)
          #define WATCHDOG_16MS   (_BV(WDE))
          #define WATCHDOG_32MS   (_BV(WDP0) | _BV(WDE))
          #define WATCHDOG_64MS   (_BV(WDP1) | _BV(WDE))
          #define WATCHDOG_125MS  (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
          #define WATCHDOG_250MS  (_BV(WDP2) | _BV(WDE))
          #define WATCHDOG_500MS  (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
          #define WATCHDOG_1S     (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
          #define WATCHDOG_2S     (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
          #define WATCHDOG_4S     (_BV(WDP3) | _BV(WDE))
          #define WATCHDOG_8S     (_BV(WDP3) | _BV(WDP0) | _BV(WDE))
          
          
          static inline void watchdogReset(void) {
          	__asm__ __volatile__ ("wdr\n");
          }
          
          static void watchdogConfig(const uint8_t wdtConfig) {
          	WDTCSR = _BV(WDCE) | _BV(WDE);
          	WDTCSR = wdtConfig;
          }
          
          
          // SPI communication
          #define SPI_PORT	PORTB	// 
          #define SPI_DDR		DDRB	// 
          #define	SPI_SCLK	PB5		// Arduino Pin 13 <-> Bit 5 of port B
          #define	SPI_MISO	PB4		// Arduino Pin 12 <-> Bit 4 of port B
          #define	SPI_MOSI	PB3		// Arduino Pin 11 <-> Bit 3 of port B
          
          #if defined(SPI_PINS_CE9_CSN10)
          	#define CSN_PORT	PORTB	// port for CSN
          	#define CSN_DDR		DDRB	// DDR for CSN
          	#define	CSN_PIN		PB2		// Arduino Pin 10 <-> Bit 2 of port B
          
          	#define CE_PORT		PORTB	// port for CE 
          	#define CE_DDR		DDRB	// DDR for CE
          	#define	CE_PIN		PB1		// Arduino Pin  9 <-> Bit 1 of port B
          	
          #elif defined(SPI_PINS_CE8_CSN9)
          	#define CSN_PORT	PORTB	// port for CSN
          	#define CSN_DDR		DDRB	// DDR for CSN
          	#define	CSN_PIN		PB1		// Arduino Pin 9 <-> Bit 1 of port B
          
          	#define CE_PORT		PORTB	// port for CE
          	#define CE_DDR		DDRB	// DDR for CE
          	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
          	
          #elif defined(SPI_PINS_CSN7_CE8)
          	#define CSN_PORT	PORTD	// port for CSN
          	#define CSN_DDR		DDRD	// DDR for CSN
          	#define	CSN_PIN		PD7		// Arduino Pin 7 <-> Bit 7 of port D
          
          	#define CE_PORT		PORTB	// port for CE
          	#define CE_DDR		DDRB	// DDR for CE
          	#define	CE_PIN		PB0		// Arduino Pin  8 <-> Bit 0 of port B
          #elif defined(SPI_PINS_CE4_CSN10)
          	#define CSN_PORT	PORTB	// port for CSN
          	#define CSN_DDR		DDRB	// DDR for CSN
          	#define	CSN_PIN		PB2		// Arduino Pin 10 <-> Bit 2 of port B
          
          	#define CE_PORT		PORTD	// port for CE
          	#define CE_DDR		DDRD	// DDR for CE
          	#define	CE_PIN		PD4		// Arduino Pin  4 <-> Bit 4 of port D
          #elif defined(SPI_PINS_CE7_CSN10)
          	// NRF24Duino Configuration
          	#define CE_PORT		PORTD	// port for CE
          	#define CE_DDR		DDRD	// DDR for CE
          	#define	CE_PIN		PD7		// Arduino Pin 7 <-> Bit 7 of port D
          
          	#define CSN_PORT	PORTB	// port for CSN
          	#define CSN_DDR		DDRB	// DDR for CSN
          	#define	CSN_PIN		PB2		// Arduino Pin  10 <-> Bit 2 of port B
          	// NRF24Duino has LED on Pin 9 set the LED_PIN in MYSBootloader.c to PB1
          #endif
          
          #define CSN_LOW()	CSN_PORT &= ~_BV(CSN_PIN)
          #define CSN_HIGH()	CSN_PORT |= _BV(CSN_PIN)
          #define CE_LOW()	CE_PORT &= ~_BV(CE_PIN)
          #define CE_HIGH()	CE_PORT |= _BV(CE_PIN)
          
          
          static void initSPI(void) {
          	// Initialize the SPI pins: SCK, MOSI, CE, CSN as outputs, MISO as input
          	#if defined(SPI_PINS_CE9_CSN10)
          		// CSN_PIN (=PB2) is SS pin and set as output
          		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN);
          	#elif defined(SPI_PINS_CSN7_CE8)
          		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
          		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2);	
          		CSN_DDR = _BV(CSN_PIN);
          	#elif defined(SPI_PINS_CE4_CSN10)
          		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
          		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(PB2) | _BV(CSN_PIN);
          		CE_DDR = _BV(CE_PIN);
          	#elif defined(SPI_PINS_CE7_CSN10)
          		// PB2 is SS pin has to be defined as OUTPUT, else SPI goes to slave mode
          		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(PB2) | _BV(CSN_PIN);
          		CE_DDR = _BV(CE_PIN);
          	#elif defined(SPI_PINS_CE8_CSN9)
          		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
          		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(CSN_PIN) | ~_BV(SPI_MISO);
          	
          	#endif
          	
          	// SPE	=	SPI enable
          	// SPIE	=	SPI interrupt enable
          	// DORD	=	data order (0:MSB first, 1:LSB first)
          	// MSTR	=	Master/Slave select
          	// SPR1	=	SPI clock rate bit 1
          	// SPR0	=	SPI clock rate bit 0; 0,0=osc/4, 0,1=osc/16, 1,0=osc/64, 1,1=osc/128
          	// CPOL	=	clock polarity idle (0:low, 1:high)
          	// CPHA	=	clock phase edge sampling (0:leading, 1:trailing)
          	
          	// SPI speed setting, nRF24L01P max. 10Mhz	
          	#if (F_CPU >= 16000000)
          		// DIV 16 = 1 Mhz
          		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
          	#elif (F_CPU >= 8000000)
          		// DIV 8 = 1 Mhz
          		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
          		SPSR = _BV(SPI2X);  
          	#elif (F_CPU >= 4000000)
          		// DIV 4 = 1Mhz
          		SPCR = _BV(SPE) | _BV(MSTR);
          	#elif (F_CPU >= 2000000)
          		// DIV 2 = 1 Mhz
          		SPCR = _BV(SPE) | _BV(MSTR) | _BV(SPR0);
          		SPSR = _BV(SPI2X);
          	#else
          		// DIV 2 <= 0.5 Mhz
          		SPCR = _BV(SPE) | _BV(MSTR);
          		SPSR = _BV(SPI2X); 
          	#endif          
          	
          }
          static uint8_t SPItransfer(const uint8_t value) {
          	SPDR = value;
          	while(!(SPSR & _BV(SPIF)));		// wait until transmitted
          	return SPDR;
          }
          static inline void SPIclose(void) {
          	// disable hardware SPI
          	SPCR = 0;	
          }
          
          
          // UART
          static void initUART(void) {
          	UART_SRA = _BV(U2X0); //Double speed mode USART0
          	UART_SRB = _BV(RXEN0) | _BV(TXEN0);
          	UART_SRC = _BV(UCSZ00) | _BV(UCSZ01);
          	UART_SRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
          }
          
          void putch(const uint8_t ch) {
          	while (!(UART_SRA & _BV(UDRE0)));
          	UART_UDR = ch;
          }
          
          static uint8_t getch(void) {
          	// wait until char received
          	while(!(UART_SRA & _BV(RXC0)));
          	// 10 bytes
          	// framing error?
          	if (!(UART_SRA & _BV(FE0))) {
          		watchdogReset();
          	}
          	return UART_UDR;
          }
          
          static inline void writeTemporaryBuffer(const uint16_t address, const uint16_t data) {
          	// fill temporary page buffer
          	__boot_page_fill_short(address, data);
          }
          
          static void programPage(const uint16_t page){
          	__boot_page_erase_short(page);	// erase page
          	boot_spm_busy_wait();
          	__boot_page_write_short(page);	// program page
          	boot_spm_busy_wait();
          	__boot_rww_enable_short();		// re-enable RWW
          }
          
          static uint16_t crc16_update(uint16_t crc, const uint8_t data) {
          	crc ^= data;
          	for (uint8_t i = 0; i < 8; ++i) {
          		crc = (crc >> 1) ^ (-(int16_t)(crc & 1) & 0xA001);
          	}
          	return crc;
          }
          
          static uint16_t calcCRCrom (const uint16_t len) {
          	// init CRC
          	uint16_t _internal_crc = 0xFFFF;	
          	// start address for CRC calculation
          	uint16_t address = 0x0000;
          	// calc and prevent overflow
          	while (address < len && address < BOOTLOADER_START_ADDRESS) {
          		uint8_t _rom_byte;
          		// read a flash byte and increment the address
          		__asm__ ("lpm %0,Z+\n" : "=r" (_rom_byte), "=z" (address): "1" (address));
          		_internal_crc = crc16_update(_internal_crc,_rom_byte);
          	}
          	return _internal_crc;
          }
          
          static void blinkLed(void) {
          	LED_DDR |= _BV(LED_PIN);
          	//300ms total
          	for (uint8_t i = 0; i < 6; i++) {
          		LED_PORT ^= _BV(LED_PIN);
          		_delay_ms(50);		
          	}
          }
          
          
          #endif // HW_H
          
          
          tekkaT Offline
          tekkaT Offline
          tekka
          Admin
          wrote on last edited by
          #4

          @Joerideman I noticed that you didn't set PB2 as output (see comments) => SPI operates in slave mode. Do you see radio activity on channel 122 after fixing that?

          1 Reply Last reply
          0
          • JoeridemanJ Offline
            JoeridemanJ Offline
            Joerideman
            wrote on last edited by
            #5

            Allright one step further.

            		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
            		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2) | ~_BV(SPI_MISO);
            		CSN_DDR = _BV(CSN_PIN);
            

            And now I can use the serial upload :).
            No luck seeing any chatter though. To be sure, I just watch commando's that come in in MySController ?

            tekkaT 1 Reply Last reply
            0
            • JoeridemanJ Joerideman

              Allright one step further.

              		// set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
              		SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2) | ~_BV(SPI_MISO);
              		CSN_DDR = _BV(CSN_PIN);
              

              And now I can use the serial upload :).
              No luck seeing any chatter though. To be sure, I just watch commando's that come in in MySController ?

              tekkaT Offline
              tekkaT Offline
              tekka
              Admin
              wrote on last edited by
              #6

              @Joerideman I'm not quite sure how setting the master SPI mode should fix the serial upload issue...What exactly are you referring to? Serial upload via FTDI adapter or FOTA (=firmware over the air) update via RF24?

              1 Reply Last reply
              0
              • JoeridemanJ Offline
                JoeridemanJ Offline
                Joerideman
                wrote on last edited by
                #7

                @tekka I can use an FTDI device now for standard uploading of the sketch. The non OTA way.

                What do you mean with the master SPI mode? Is that because of the fuses that I tried to change?

                I have watch the MyScontroller Debug window and the messages. But I only see a presentation at some point, and than it is started.

                tekkaT 1 Reply Last reply
                0
                • JoeridemanJ Joerideman

                  @tekka I can use an FTDI device now for standard uploading of the sketch. The non OTA way.

                  What do you mean with the master SPI mode? Is that because of the fuses that I tried to change?

                  I have watch the MyScontroller Debug window and the messages. But I only see a presentation at some point, and than it is started.

                  tekkaT Offline
                  tekkaT Offline
                  tekka
                  Admin
                  wrote on last edited by
                  #8

                  @Joerideman Setting PB2 as output ensures that the SPI runs in master mode which is essential for a correct communication between the ATmega328 and the RF24 radio.

                  However, after setting PB2 you report:

                  And now I can use the serial upload :).

                  which is not related to SPI (serial upload uses the UART interface).

                  I have watch the MyScontroller Debug window and the messages. But I only see a presentation at some point, and than it is started.

                  Please provide debug logs / screenshots / whatever you have for further troubleshooting...

                  1 Reply Last reply
                  0
                  • JoeridemanJ Offline
                    JoeridemanJ Offline
                    Joerideman
                    wrote on last edited by Joerideman
                    #9

                    @tekka But that setting somehow made a difference.

                    Nevermind here is the debug info from the gateway.

                    When I restart the node, it takes a few seconds before information starts rolling in.

                    10:15:48.219 -> 312137 TSF:MSG:READ,1-1-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
                    10:15:48.252 -> 312197 TSF:MSG:BC
                    10:15:48.287 -> 312216 TSF:MSG:FPAR REQ,ID=1
                    10:15:48.321 -> 312246 TSF:PNG:SEND,TO=0
                    10:15:48.355 -> 312272 TSF:CKU:OK
                    10:15:48.355 -> 312291 TSF:MSG:GWL OK
                    10:15:49.434 -> 313336 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
                    10:15:50.208 -> 314109 TSF:MSG:READ,1-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
                    10:15:50.242 -> 314169 TSF:MSG:PINGED,ID=1,HP=1
                    10:15:50.309 -> 314212 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
                    10:15:50.376 -> 314285 TSF:MSG:READ,1-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                    10:15:50.443 -> 314352 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                    10:15:50.510 -> 314428 TSF:MSG:READ,1-1-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2
                    10:15:50.576 -> 314493 TSF:MSG:READ,1-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
                    10:15:50.712 -> 314642 GWT:RFC:C=0,MSG=1;255;3;0;6;M
                    10:15:50.780 -> 314683 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
                    10:15:50.847 -> 314755 TSF:MSG:READ,1-1-0,s=255,c=3,t=11,pt=0,l=19,sg=0:4channel 24V dimmer
                    10:15:50.914 -> 314836 TSF:MSG:READ,1-1-0,s=255,c=3,t=12,pt=0,l=4,sg=0:2.00
                    10:15:50.982 -> 314900 TSF:MSG:READ,1-1-0,s=1,c=0,t=4,pt=0,l=0,sg=0:
                    10:15:51.083 -> 315013 TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
                    10:15:51.152 -> 315080 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
                    10:15:51.220 -> 315153 TSF:MSG:READ,1-1-0,s=1,c=1,t=2,pt=2,l=2,sg=0:0
                    10:15:51.287 -> 315211 TSF:MSG:READ,1-1-0,s=1,c=2,t=3,pt=0,l=0,sg=0:
                    

                    Here is the serial output from the node at the same time.

                    10:15:48.154 ->  
                    10:15:48.154 ->  __  __       ____
                    10:15:48.154 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                    10:15:48.221 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                    10:15:48.221 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                    10:15:48.221 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                    10:15:48.221 ->         |___/                      2.3.2
                    10:15:48.221 -> 
                    10:15:48.221 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
                    10:15:48.221 -> 28 TSM:INIT
                    10:15:48.221 -> 28 TSF:WUR:MS=0
                    10:15:48.221 -> 36 TSM:INIT:TSP OK
                    10:15:48.221 -> 38 TSM:INIT:STATID=1
                    10:15:48.221 -> 40 TSF:SID:OK,ID=1
                    10:15:48.221 -> 43 TSM:FPAR
                    10:15:48.221 -> 47 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                    10:15:49.404 -> 1271 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                    10:15:49.404 -> 1277 TSF:MSG:FPAR OK,ID=0,D=1
                    10:15:50.144 -> 2056 TSM:FPAR:OK
                    10:15:50.144 -> 2056 TSM:ID
                    10:15:50.144 -> 2058 TSM:ID:OK
                    10:15:50.144 -> 2060 TSM:UPL
                    10:15:50.179 -> 2068 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                    10:15:50.246 -> 2170 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                    10:15:50.314 -> 2177 TSF:MSG:PONG RECV,HP=1
                    10:15:50.314 -> 2179 TSM:UPL:OK
                    10:15:50.314 -> 2181 TSM:READY:ID=1,PAR=0,DIS=1
                    10:15:50.314 -> 2187 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                    10:15:50.449 -> 2314 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                    10:15:50.449 -> 2322 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
                    10:15:50.449 -> 2332 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                    10:15:50.754 -> 2656 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                    10:15:50.754 -> 2664 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=OK:4channel 24V dimmer
                    10:15:50.788 -> 2676 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=4,sg=0,ft=0,st=OK:2.00
                    10:15:50.788 -> 2686 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
                    10:15:51.093 -> 2994 MCO:REG:REQ
                    10:15:51.093 -> 2996 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                    10:15:51.126 -> 3063 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                    10:15:51.160 -> 3069 MCO:PIM:NODE REG=1
                    10:15:51.160 -> 3074 MCO:BGN:STP
                    10:15:51.160 -> 3080 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
                    10:15:51.260 -> 3186 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
                    10:15:51.593 -> 3520 MCO:BGN:INIT OK,TSP=1
                    
                    tekkaT 1 Reply Last reply
                    0
                    • JoeridemanJ Joerideman

                      @tekka But that setting somehow made a difference.

                      Nevermind here is the debug info from the gateway.

                      When I restart the node, it takes a few seconds before information starts rolling in.

                      10:15:48.219 -> 312137 TSF:MSG:READ,1-1-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
                      10:15:48.252 -> 312197 TSF:MSG:BC
                      10:15:48.287 -> 312216 TSF:MSG:FPAR REQ,ID=1
                      10:15:48.321 -> 312246 TSF:PNG:SEND,TO=0
                      10:15:48.355 -> 312272 TSF:CKU:OK
                      10:15:48.355 -> 312291 TSF:MSG:GWL OK
                      10:15:49.434 -> 313336 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0
                      10:15:50.208 -> 314109 TSF:MSG:READ,1-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
                      10:15:50.242 -> 314169 TSF:MSG:PINGED,ID=1,HP=1
                      10:15:50.309 -> 314212 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
                      10:15:50.376 -> 314285 TSF:MSG:READ,1-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                      10:15:50.443 -> 314352 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                      10:15:50.510 -> 314428 TSF:MSG:READ,1-1-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2
                      10:15:50.576 -> 314493 TSF:MSG:READ,1-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
                      10:15:50.712 -> 314642 GWT:RFC:C=0,MSG=1;255;3;0;6;M
                      10:15:50.780 -> 314683 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
                      10:15:50.847 -> 314755 TSF:MSG:READ,1-1-0,s=255,c=3,t=11,pt=0,l=19,sg=0:4channel 24V dimmer
                      10:15:50.914 -> 314836 TSF:MSG:READ,1-1-0,s=255,c=3,t=12,pt=0,l=4,sg=0:2.00
                      10:15:50.982 -> 314900 TSF:MSG:READ,1-1-0,s=1,c=0,t=4,pt=0,l=0,sg=0:
                      10:15:51.083 -> 315013 TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
                      10:15:51.152 -> 315080 TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
                      10:15:51.220 -> 315153 TSF:MSG:READ,1-1-0,s=1,c=1,t=2,pt=2,l=2,sg=0:0
                      10:15:51.287 -> 315211 TSF:MSG:READ,1-1-0,s=1,c=2,t=3,pt=0,l=0,sg=0:
                      

                      Here is the serial output from the node at the same time.

                      10:15:48.154 ->  
                      10:15:48.154 ->  __  __       ____
                      10:15:48.154 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                      10:15:48.221 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                      10:15:48.221 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                      10:15:48.221 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                      10:15:48.221 ->         |___/                      2.3.2
                      10:15:48.221 -> 
                      10:15:48.221 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
                      10:15:48.221 -> 28 TSM:INIT
                      10:15:48.221 -> 28 TSF:WUR:MS=0
                      10:15:48.221 -> 36 TSM:INIT:TSP OK
                      10:15:48.221 -> 38 TSM:INIT:STATID=1
                      10:15:48.221 -> 40 TSF:SID:OK,ID=1
                      10:15:48.221 -> 43 TSM:FPAR
                      10:15:48.221 -> 47 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                      10:15:49.404 -> 1271 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                      10:15:49.404 -> 1277 TSF:MSG:FPAR OK,ID=0,D=1
                      10:15:50.144 -> 2056 TSM:FPAR:OK
                      10:15:50.144 -> 2056 TSM:ID
                      10:15:50.144 -> 2058 TSM:ID:OK
                      10:15:50.144 -> 2060 TSM:UPL
                      10:15:50.179 -> 2068 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                      10:15:50.246 -> 2170 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                      10:15:50.314 -> 2177 TSF:MSG:PONG RECV,HP=1
                      10:15:50.314 -> 2179 TSM:UPL:OK
                      10:15:50.314 -> 2181 TSM:READY:ID=1,PAR=0,DIS=1
                      10:15:50.314 -> 2187 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                      10:15:50.449 -> 2314 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                      10:15:50.449 -> 2322 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
                      10:15:50.449 -> 2332 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                      10:15:50.754 -> 2656 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                      10:15:50.754 -> 2664 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=OK:4channel 24V dimmer
                      10:15:50.788 -> 2676 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=4,sg=0,ft=0,st=OK:2.00
                      10:15:50.788 -> 2686 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
                      10:15:51.093 -> 2994 MCO:REG:REQ
                      10:15:51.093 -> 2996 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                      10:15:51.126 -> 3063 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                      10:15:51.160 -> 3069 MCO:PIM:NODE REG=1
                      10:15:51.160 -> 3074 MCO:BGN:STP
                      10:15:51.160 -> 3080 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
                      10:15:51.260 -> 3186 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
                      10:15:51.593 -> 3520 MCO:BGN:INIT OK,TSP=1
                      
                      tekkaT Offline
                      tekkaT Offline
                      tekka
                      Admin
                      wrote on last edited by
                      #10

                      @Joerideman There is no sign of the bootloader here - can you confirm that your GW is listening on channel 122?

                      1 Reply Last reply
                      0
                      • JoeridemanJ Offline
                        JoeridemanJ Offline
                        Joerideman
                        wrote on last edited by Joerideman
                        #11

                        @tekka how? They are talking with each other ones everything has started. Does that not mean the gateway is on the same channel?

                        This is the code of my node: I set the channel to 122 right?

                        /***************************************************
                          combinatie van mysensors en adafruits pwm library
                        
                         versie 2. basis werking
                        
                         versie2.1 Betere response op de controller. Requests voor de 
                        
                        
                        */
                        
                        //########## mysensors instellingen
                        #define MY_NODE_ID 1
                        #define MY_RF24_CHANNEL (122)
                        
                        #define MY_RF24_CE_PIN 8
                        #define MY_RF24_CS_PIN 9
                        
                        
                        // 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
                        
                        #include <MySensors.h>
                        
                        #define SN "4channel 24V dimmer"
                        #define SV "2.00"
                        
                        //#define LED_PIN 3      // Arduino pin attached to MOSFET Gate pin // niet relevant. Dimmen gaat via i2c
                        #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                        #define LED_TYPE S_DIMMER
                        #define AMOUNT_OF_LED 1
                        byte LED_CURRENTLEVEL[] = {0, 0, 0, 0, 0};
                        byte LedCurrentStep[] = {0, 0, 0, 0, 0};
                        byte LedTempCurrentStep[] = {0, 0, 0, 0, 0};
                        byte LED_TOLEVEL[] = {0, 0, 0, 0, 0};
                        byte LedToStep[] = {0, 0, 0, 0, 0};
                        byte LED_Status[] = {0, 0, 0, 0, 0}; //all off
                        byte ledUpdate[] = {0, 0, 0, 0, 0};
                        bool updateLED = false;
                        byte sensorId = 1;
                        
                        
                        MyMessage dimmerMsg(sensorId, V_PERCENTAGE); // was ooit V_Dimmer
                        MyMessage lightMsg(sensorId, V_STATUS); //on or off was ooit V_LIGHT
                        
                        
                        #include <Wire.h>
                        #include <Adafruit_PWMServoDriver.h>
                        
                        // called this way, it uses the default address 0x40
                        //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
                        // you can also call it with a different address you want
                        Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
                        // you can also call it with a different address and I2C interface
                        //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, &Wire);
                        
                        int lichtwaarde[141] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 48, 51, 55, 58, 62, 66, 70, 74, 79, 84, 89, 94, 100, 106, 113, 120, 128, 136, 144, 153, 163, 173, 184, 195, 207, 220, 234, 249, 264, 281, 298, 317, 337, 358, 380, 404, 429, 456, 485, 515, 547, 581, 618, 656, 697, 741, 787, 837, 889, 944, 1003, 1066, 1133, 1204, 1279, 1359, 1444, 1534, 1630, 1732, 1840, 1955, 2077, 2207, 2345, 2491, 2647, 2812, 2988, 3175, 3373, 3584, 3808, 4046, 4096};
                        
                        /***
                           Dimmable LED initialization method
                        */
                        void presentation()
                        {
                        
                        
                          sendSketchInfo(SN, SV);
                        
                        
                          //Present nodes
                          for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1) ; sensorId++) { //
                            present(sensorId, LED_TYPE);
                            wait(300);
                          }
                        }
                        
                        
                        void setup() {
                          //###### Mysensors Setup
                          // Pull the gateway's current dim level - restore light level upon node power-up
                        
                        
                        
                          for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1); sensorId++) {
                            send(lightMsg.set(0));
                                wait(100);
                          }
                        
                          for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1); sensorId++) {
                            request( sensorId, V_PERCENTAGE );
                            wait(300);
                          }
                        
                          //###### PWM setup
                          pwm.begin();
                          pwm.setPWMFreq(1600);  //
                        
                          // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
                          // some i2c devices dont like this so much so if you're sharing the bus, watch
                          // out for this!
                          Wire.setClock(400000);
                        
                          for (int i = 0; i < 4; i++) { //zet alles uit
                            pwm.setPin((i), lichtwaarde[0]);
                          }
                        }
                        
                        
                        
                        
                        
                        void loop() {// de eerste 4 aansluitingen
                          if ((ledUpdate[1] + ledUpdate[2] + ledUpdate[3] + ledUpdate[4]) > 0) {
                        
                            fade();
                            wait(15);
                          }
                        
                        }
                        
                        void receive(const MyMessage &message)
                        {
                          if (message.type == V_STATUS) {
                        
                            //  Retrieve the power or dim level from the incoming request message
                            int tempStatus = ( 1 <= atoi (message.data)) ? 1 : 0;
                            //Serial.print("V type Message data = ");
                            //Serial.println(tempStatus);
                            if (tempStatus > LED_Status[message.sensor]) {
                              ledUpdate[message.sensor] = true;
                        
                              if (LED_CURRENTLEVEL[message.sensor] == 0) {
                                LED_CURRENTLEVEL[message.sensor] = 70;
                                LedToStep[message.sensor] = map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                                Serial.print("ledtostep = ");
                                Serial.println(LedToStep[message.sensor] );
                              }
                              else if (LED_CURRENTLEVEL[message.sensor] > 0) {
                                LedToStep[message.sensor] =  map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                                LedCurrentStep[message.sensor] = 0;
                        
                                Serial.print("ledtostep2 = ");
                                Serial.println(LedToStep[message.sensor] );
                              }
                            }
                            else if (tempStatus < LED_Status[message.sensor]) {
                              //Led gaat uit
                              LedToStep[message.sensor] = 0;
                              LedTempCurrentStep[message.sensor] = LedCurrentStep[message.sensor];
                        
                              ledUpdate[message.sensor] = true;
                            }
                            sensorId = message.sensor;
                            LED_Status[message.sensor] = tempStatus; //de status
                        
                        
                            send(lightMsg.set(LED_Status[message.sensor]));
                        
                          }
                          else if (message.type == V_PERCENTAGE) {
                            Serial.print("v percentage Message data = ");
                            Serial.println(atoi( message.data ));
                        
                            if (LED_CURRENTLEVEL[message.sensor] != atoi(message.data)) {
                              LED_CURRENTLEVEL[message.sensor] = (100 <= atoi( message.data )) ? 100 : atoi( message.data ); //de level
                              LedToStep[message.sensor] =  map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                        
                              ledUpdate[message.sensor] = true;
                              if (LedToStep[message.sensor] != 0) {
                              //LED_Status[message.sensor] = 1;
                               // sensorId = message.sensor;
                                //send(lightMsg.set(LED_Status[message.sensor]));
                              }
                              sensorId = message.sensor;
                              request( sensorId, V_STATUS );
                                         send(dimmerMsg.set(LED_CURRENTLEVEL[message.sensor]));
                            }
                        
                        
                          }
                        }
                        
                        void fade() {
                        
                          //als de status van een led == true. Dan de fade.
                        
                          for (int ledNumber = 1; ledNumber <= AMOUNT_OF_LED; ledNumber++) {
                            if (ledUpdate[ledNumber] == true) {
                              if (LedTempCurrentStep[ledNumber] == 0 && LED_Status[ledNumber] == 0) {
                                //Serial.println("fade0");
                                //do nothing
                              }
                              else if (LedCurrentStep[ledNumber] < LedToStep[ledNumber] && LED_Status[ledNumber] == 1) {
                                //Serial.println("fade1");
                                //increase light
                                LedCurrentStep[ledNumber]++;
                                pwm.setPin((ledNumber - 1), lichtwaarde[LedCurrentStep[ledNumber]]);
                              }
                        
                              else if (LedTempCurrentStep[ledNumber] > LedToStep[ledNumber] && LED_Status[ledNumber] == 0) {
                                //turn off  but remember the last lightlevel
                                //Serial.println("fade2");
                                LedTempCurrentStep[ledNumber]--;
                                pwm.setPin((ledNumber - 1), lichtwaarde[LedTempCurrentStep[ledNumber]]);
                              }
                              else if (LedCurrentStep[ledNumber] > LedToStep[ledNumber] && LED_Status[ledNumber] == 1) {
                                //decrease light
                                //Serial.println("fade3");
                                LedCurrentStep[ledNumber]--;
                                pwm.setPin((ledNumber - 1), lichtwaarde[LedCurrentStep[ledNumber]]);
                              }
                              if (LedCurrentStep[ledNumber] == LedToStep[ledNumber]) {
                                ledUpdate[ledNumber] = false;
                                //Serial.println("fade4");
                              }
                              if (LedCurrentStep[ledNumber] == LedToStep[ledNumber]) {
                                ledUpdate[ledNumber] = false;
                                //Serial.println("fade5");
                              }
                              if (LedTempCurrentStep[ledNumber] == 0 && LED_Status[ledNumber] == 0) {
                                ledUpdate[ledNumber] = false;
                                //Serial.println("fade6");
                              }
                            }
                        
                          }
                        
                        
                        }
                        
                        tekkaT 1 Reply Last reply
                        0
                        • JoeridemanJ Joerideman

                          @tekka how? They are talking with each other ones everything has started. Does that not mean the gateway is on the same channel?

                          This is the code of my node: I set the channel to 122 right?

                          /***************************************************
                            combinatie van mysensors en adafruits pwm library
                          
                           versie 2. basis werking
                          
                           versie2.1 Betere response op de controller. Requests voor de 
                          
                          
                          */
                          
                          //########## mysensors instellingen
                          #define MY_NODE_ID 1
                          #define MY_RF24_CHANNEL (122)
                          
                          #define MY_RF24_CE_PIN 8
                          #define MY_RF24_CS_PIN 9
                          
                          
                          // 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
                          
                          #include <MySensors.h>
                          
                          #define SN "4channel 24V dimmer"
                          #define SV "2.00"
                          
                          //#define LED_PIN 3      // Arduino pin attached to MOSFET Gate pin // niet relevant. Dimmen gaat via i2c
                          #define FADE_DELAY 10  // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
                          #define LED_TYPE S_DIMMER
                          #define AMOUNT_OF_LED 1
                          byte LED_CURRENTLEVEL[] = {0, 0, 0, 0, 0};
                          byte LedCurrentStep[] = {0, 0, 0, 0, 0};
                          byte LedTempCurrentStep[] = {0, 0, 0, 0, 0};
                          byte LED_TOLEVEL[] = {0, 0, 0, 0, 0};
                          byte LedToStep[] = {0, 0, 0, 0, 0};
                          byte LED_Status[] = {0, 0, 0, 0, 0}; //all off
                          byte ledUpdate[] = {0, 0, 0, 0, 0};
                          bool updateLED = false;
                          byte sensorId = 1;
                          
                          
                          MyMessage dimmerMsg(sensorId, V_PERCENTAGE); // was ooit V_Dimmer
                          MyMessage lightMsg(sensorId, V_STATUS); //on or off was ooit V_LIGHT
                          
                          
                          #include <Wire.h>
                          #include <Adafruit_PWMServoDriver.h>
                          
                          // called this way, it uses the default address 0x40
                          //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
                          // you can also call it with a different address you want
                          Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
                          // you can also call it with a different address and I2C interface
                          //Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, &Wire);
                          
                          int lichtwaarde[141] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 28, 30, 32, 34, 36, 38, 40, 43, 46, 48, 51, 55, 58, 62, 66, 70, 74, 79, 84, 89, 94, 100, 106, 113, 120, 128, 136, 144, 153, 163, 173, 184, 195, 207, 220, 234, 249, 264, 281, 298, 317, 337, 358, 380, 404, 429, 456, 485, 515, 547, 581, 618, 656, 697, 741, 787, 837, 889, 944, 1003, 1066, 1133, 1204, 1279, 1359, 1444, 1534, 1630, 1732, 1840, 1955, 2077, 2207, 2345, 2491, 2647, 2812, 2988, 3175, 3373, 3584, 3808, 4046, 4096};
                          
                          /***
                             Dimmable LED initialization method
                          */
                          void presentation()
                          {
                          
                          
                            sendSketchInfo(SN, SV);
                          
                          
                            //Present nodes
                            for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1) ; sensorId++) { //
                              present(sensorId, LED_TYPE);
                              wait(300);
                            }
                          }
                          
                          
                          void setup() {
                            //###### Mysensors Setup
                            // Pull the gateway's current dim level - restore light level upon node power-up
                          
                          
                          
                            for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1); sensorId++) {
                              send(lightMsg.set(0));
                                  wait(100);
                            }
                          
                            for (sensorId = 1; sensorId < (AMOUNT_OF_LED + 1); sensorId++) {
                              request( sensorId, V_PERCENTAGE );
                              wait(300);
                            }
                          
                            //###### PWM setup
                            pwm.begin();
                            pwm.setPWMFreq(1600);  //
                          
                            // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
                            // some i2c devices dont like this so much so if you're sharing the bus, watch
                            // out for this!
                            Wire.setClock(400000);
                          
                            for (int i = 0; i < 4; i++) { //zet alles uit
                              pwm.setPin((i), lichtwaarde[0]);
                            }
                          }
                          
                          
                          
                          
                          
                          void loop() {// de eerste 4 aansluitingen
                            if ((ledUpdate[1] + ledUpdate[2] + ledUpdate[3] + ledUpdate[4]) > 0) {
                          
                              fade();
                              wait(15);
                            }
                          
                          }
                          
                          void receive(const MyMessage &message)
                          {
                            if (message.type == V_STATUS) {
                          
                              //  Retrieve the power or dim level from the incoming request message
                              int tempStatus = ( 1 <= atoi (message.data)) ? 1 : 0;
                              //Serial.print("V type Message data = ");
                              //Serial.println(tempStatus);
                              if (tempStatus > LED_Status[message.sensor]) {
                                ledUpdate[message.sensor] = true;
                          
                                if (LED_CURRENTLEVEL[message.sensor] == 0) {
                                  LED_CURRENTLEVEL[message.sensor] = 70;
                                  LedToStep[message.sensor] = map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                                  Serial.print("ledtostep = ");
                                  Serial.println(LedToStep[message.sensor] );
                                }
                                else if (LED_CURRENTLEVEL[message.sensor] > 0) {
                                  LedToStep[message.sensor] =  map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                                  LedCurrentStep[message.sensor] = 0;
                          
                                  Serial.print("ledtostep2 = ");
                                  Serial.println(LedToStep[message.sensor] );
                                }
                              }
                              else if (tempStatus < LED_Status[message.sensor]) {
                                //Led gaat uit
                                LedToStep[message.sensor] = 0;
                                LedTempCurrentStep[message.sensor] = LedCurrentStep[message.sensor];
                          
                                ledUpdate[message.sensor] = true;
                              }
                              sensorId = message.sensor;
                              LED_Status[message.sensor] = tempStatus; //de status
                          
                          
                              send(lightMsg.set(LED_Status[message.sensor]));
                          
                            }
                            else if (message.type == V_PERCENTAGE) {
                              Serial.print("v percentage Message data = ");
                              Serial.println(atoi( message.data ));
                          
                              if (LED_CURRENTLEVEL[message.sensor] != atoi(message.data)) {
                                LED_CURRENTLEVEL[message.sensor] = (100 <= atoi( message.data )) ? 100 : atoi( message.data ); //de level
                                LedToStep[message.sensor] =  map(LED_CURRENTLEVEL[message.sensor], 0, 100, 0, 140);
                          
                                ledUpdate[message.sensor] = true;
                                if (LedToStep[message.sensor] != 0) {
                                //LED_Status[message.sensor] = 1;
                                 // sensorId = message.sensor;
                                  //send(lightMsg.set(LED_Status[message.sensor]));
                                }
                                sensorId = message.sensor;
                                request( sensorId, V_STATUS );
                                           send(dimmerMsg.set(LED_CURRENTLEVEL[message.sensor]));
                              }
                          
                          
                            }
                          }
                          
                          void fade() {
                          
                            //als de status van een led == true. Dan de fade.
                          
                            for (int ledNumber = 1; ledNumber <= AMOUNT_OF_LED; ledNumber++) {
                              if (ledUpdate[ledNumber] == true) {
                                if (LedTempCurrentStep[ledNumber] == 0 && LED_Status[ledNumber] == 0) {
                                  //Serial.println("fade0");
                                  //do nothing
                                }
                                else if (LedCurrentStep[ledNumber] < LedToStep[ledNumber] && LED_Status[ledNumber] == 1) {
                                  //Serial.println("fade1");
                                  //increase light
                                  LedCurrentStep[ledNumber]++;
                                  pwm.setPin((ledNumber - 1), lichtwaarde[LedCurrentStep[ledNumber]]);
                                }
                          
                                else if (LedTempCurrentStep[ledNumber] > LedToStep[ledNumber] && LED_Status[ledNumber] == 0) {
                                  //turn off  but remember the last lightlevel
                                  //Serial.println("fade2");
                                  LedTempCurrentStep[ledNumber]--;
                                  pwm.setPin((ledNumber - 1), lichtwaarde[LedTempCurrentStep[ledNumber]]);
                                }
                                else if (LedCurrentStep[ledNumber] > LedToStep[ledNumber] && LED_Status[ledNumber] == 1) {
                                  //decrease light
                                  //Serial.println("fade3");
                                  LedCurrentStep[ledNumber]--;
                                  pwm.setPin((ledNumber - 1), lichtwaarde[LedCurrentStep[ledNumber]]);
                                }
                                if (LedCurrentStep[ledNumber] == LedToStep[ledNumber]) {
                                  ledUpdate[ledNumber] = false;
                                  //Serial.println("fade4");
                                }
                                if (LedCurrentStep[ledNumber] == LedToStep[ledNumber]) {
                                  ledUpdate[ledNumber] = false;
                                  //Serial.println("fade5");
                                }
                                if (LedTempCurrentStep[ledNumber] == 0 && LED_Status[ledNumber] == 0) {
                                  ledUpdate[ledNumber] = false;
                                  //Serial.println("fade6");
                                }
                              }
                          
                            }
                          
                          
                          }
                          
                          tekkaT Offline
                          tekkaT Offline
                          tekka
                          Admin
                          wrote on last edited by
                          #12

                          @Joerideman That looks alright! Just out of curiosity, if you use the bootloader with the default settings (channel, ce/csn assignment), do you see a difference in the debug log?

                          1 Reply Last reply
                          0
                          • JoeridemanJ Offline
                            JoeridemanJ Offline
                            Joerideman
                            wrote on last edited by
                            #13

                            I used the 8MHZ int RC one

                            log node:

                            12:09:50.469 -> ⸮& ⸮⸮⸮⸮⸮AGC`⸮48⸮C⸮⸮⸮⸮⸮{}
                            12:09:50.469 -> 2058 TSM:FPAR
                            12:09:50.469 -> 2062 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:09:50.469 ->  
                            12:09:50.469 ->  __  __       ____
                            12:09:50.469 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                            12:09:50.469 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                            12:09:50.469 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                            12:09:50.469 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                            12:09:50.469 ->         |___/                      2.3.2
                            12:09:50.469 -> 
                            12:09:50.469 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
                            12:09:50.469 -> 28 TSM:INIT
                            12:09:50.469 -> 28 TSF:WUR:MS=0
                            12:09:50.469 -> 36 TSM:INIT:TSP OK
                            12:09:50.469 -> 38 TSM:INIT:STATID=1
                            12:09:50.469 -> 40 TSF:SID:OK,ID=1
                            12:09:50.469 -> 43 TSM:FPAR
                            12:09:50.469 -> 47 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:09:52.420 -> 2056 !TSM:FPAR:NO REPLY
                            12:09:52.420 -> 2058 TSM:FPAR
                            12:09:52.420 -> 2062 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:09:54.367 -> 4071 !TSM:FPAR:NO REPLY
                            12:09:54.367 -> 4073 TSM:FPAR
                            12:09:54.367 -> 4077 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:09:56.349 -> 6086 !TSM:FPAR:NO REPLY
                            12:09:56.349 -> 6088 TSM:FPAR
                            12:09:56.383 -> 6092 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:09:58.338 -> 8101 !TSM:FPAR:FAIL
                            12:09:58.338 -> 8103 TSM:FAIL:CNT=1
                            12:09:58.338 -> 8105 TSM:FAIL:DIS
                            12:09:58.338 -> 8108 TSF:TDI:TSL
                            12:10:08.065 -> 18112 TSM:FAIL:RE-INIT
                            12:10:08.065 -> 18114 TSM:INIT
                            12:10:08.098 -> 18120 TSM:INIT:TSP OK
                            12:10:08.098 -> 18122 TSM:INIT:STATID=1
                            12:10:08.098 -> 18126 TSF:SID:OK,ID=1
                            12:10:08.098 -> 18128 TSM:FPAR
                            12:10:08.098 -> 18132 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:10.054 -> 20142 !TSM:FPAR:NO REPLY
                            12:10:10.054 -> 20144 TSM:FPAR
                            12:10:10.088 -> 20148 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:12.042 -> 22157 !TSM:FPAR:NO REPLY
                            12:10:12.042 -> 22159 TSM:FPAR
                            12:10:12.075 -> 22163 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:14.024 -> 24172 !TSM:FPAR:NO REPLY
                            12:10:14.024 -> 24174 TSM:FPAR
                            12:10:14.024 -> 24178 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:14.290 -> 24473 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                            12:10:14.323 -> 24479 TSF:MSG:FPAR OK,ID=0,D=1
                            12:10:16.012 -> 26187 TSM:FPAR:OK
                            12:10:16.012 -> 26189 TSM:ID
                            12:10:16.012 -> 26189 TSM:ID:OK
                            12:10:16.012 -> 26191 TSM:UPL
                            12:10:16.012 -> 26200 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                            12:10:16.111 -> 26302 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                            12:10:16.146 -> 26308 TSF:MSG:PONG RECV,HP=1
                            12:10:16.146 -> 26312 TSM:UPL:OK
                            12:10:16.146 -> 26314 TSM:READY:ID=1,PAR=0,DIS=1
                            12:10:16.146 -> 26320 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                            12:10:16.247 -> 26447 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                            12:10:16.282 -> 26456 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
                            12:10:16.282 -> 26466 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                            12:10:16.521 -> 26703 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                            12:10:16.554 -> 26716 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=OK:4channel 24V dimmer
                            12:10:16.554 -> 26730 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=4,sg=0,ft=0,st=OK:2.00
                            12:10:16.554 -> 26742 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:16.858 -> 27049 MCO:REG:REQ
                            12:10:16.858 -> 27052 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                            12:10:16.926 -> 27121 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                            12:10:16.926 -> 27127 MCO:PIM:NODE REG=1
                            12:10:16.926 -> 27129 MCO:BGN:STP
                            12:10:16.926 -> 27136 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
                            12:10:17.029 -> 27246 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
                            12:10:17.368 -> 27580 MCO:BGN:INIT OK,TSP=1
                            12:10:38.436 -> 49125 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
                            12:10:38.436 -> 49131 TSF:MSG:BC
                            12:10:39.446 -> 50141 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
                            
                            tekkaT 1 Reply Last reply
                            0
                            • JoeridemanJ Joerideman

                              I used the 8MHZ int RC one

                              log node:

                              12:09:50.469 -> ⸮& ⸮⸮⸮⸮⸮AGC`⸮48⸮C⸮⸮⸮⸮⸮{}
                              12:09:50.469 -> 2058 TSM:FPAR
                              12:09:50.469 -> 2062 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:09:50.469 ->  
                              12:09:50.469 ->  __  __       ____
                              12:09:50.469 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                              12:09:50.469 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                              12:09:50.469 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                              12:09:50.469 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                              12:09:50.469 ->         |___/                      2.3.2
                              12:09:50.469 -> 
                              12:09:50.469 -> 16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=8,REL=255,VER=2.3.2
                              12:09:50.469 -> 28 TSM:INIT
                              12:09:50.469 -> 28 TSF:WUR:MS=0
                              12:09:50.469 -> 36 TSM:INIT:TSP OK
                              12:09:50.469 -> 38 TSM:INIT:STATID=1
                              12:09:50.469 -> 40 TSF:SID:OK,ID=1
                              12:09:50.469 -> 43 TSM:FPAR
                              12:09:50.469 -> 47 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:09:52.420 -> 2056 !TSM:FPAR:NO REPLY
                              12:09:52.420 -> 2058 TSM:FPAR
                              12:09:52.420 -> 2062 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:09:54.367 -> 4071 !TSM:FPAR:NO REPLY
                              12:09:54.367 -> 4073 TSM:FPAR
                              12:09:54.367 -> 4077 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:09:56.349 -> 6086 !TSM:FPAR:NO REPLY
                              12:09:56.349 -> 6088 TSM:FPAR
                              12:09:56.383 -> 6092 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:09:58.338 -> 8101 !TSM:FPAR:FAIL
                              12:09:58.338 -> 8103 TSM:FAIL:CNT=1
                              12:09:58.338 -> 8105 TSM:FAIL:DIS
                              12:09:58.338 -> 8108 TSF:TDI:TSL
                              12:10:08.065 -> 18112 TSM:FAIL:RE-INIT
                              12:10:08.065 -> 18114 TSM:INIT
                              12:10:08.098 -> 18120 TSM:INIT:TSP OK
                              12:10:08.098 -> 18122 TSM:INIT:STATID=1
                              12:10:08.098 -> 18126 TSF:SID:OK,ID=1
                              12:10:08.098 -> 18128 TSM:FPAR
                              12:10:08.098 -> 18132 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:10.054 -> 20142 !TSM:FPAR:NO REPLY
                              12:10:10.054 -> 20144 TSM:FPAR
                              12:10:10.088 -> 20148 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:12.042 -> 22157 !TSM:FPAR:NO REPLY
                              12:10:12.042 -> 22159 TSM:FPAR
                              12:10:12.075 -> 22163 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:14.024 -> 24172 !TSM:FPAR:NO REPLY
                              12:10:14.024 -> 24174 TSM:FPAR
                              12:10:14.024 -> 24178 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:14.290 -> 24473 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                              12:10:14.323 -> 24479 TSF:MSG:FPAR OK,ID=0,D=1
                              12:10:16.012 -> 26187 TSM:FPAR:OK
                              12:10:16.012 -> 26189 TSM:ID
                              12:10:16.012 -> 26189 TSM:ID:OK
                              12:10:16.012 -> 26191 TSM:UPL
                              12:10:16.012 -> 26200 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                              12:10:16.111 -> 26302 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                              12:10:16.146 -> 26308 TSF:MSG:PONG RECV,HP=1
                              12:10:16.146 -> 26312 TSM:UPL:OK
                              12:10:16.146 -> 26314 TSM:READY:ID=1,PAR=0,DIS=1
                              12:10:16.146 -> 26320 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                              12:10:16.247 -> 26447 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
                              12:10:16.282 -> 26456 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
                              12:10:16.282 -> 26466 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                              12:10:16.521 -> 26703 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
                              12:10:16.554 -> 26716 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=OK:4channel 24V dimmer
                              12:10:16.554 -> 26730 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=4,sg=0,ft=0,st=OK:2.00
                              12:10:16.554 -> 26742 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=4,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:16.858 -> 27049 MCO:REG:REQ
                              12:10:16.858 -> 27052 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                              12:10:16.926 -> 27121 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                              12:10:16.926 -> 27127 MCO:PIM:NODE REG=1
                              12:10:16.926 -> 27129 MCO:BGN:STP
                              12:10:16.926 -> 27136 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
                              12:10:17.029 -> 27246 TSF:MSG:SEND,1-1-0-0,s=1,c=2,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
                              12:10:17.368 -> 27580 MCO:BGN:INIT OK,TSP=1
                              12:10:38.436 -> 49125 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
                              12:10:38.436 -> 49131 TSF:MSG:BC
                              12:10:39.446 -> 50141 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
                              
                              tekkaT Offline
                              tekkaT Offline
                              tekka
                              Admin
                              wrote on last edited by tekka
                              #14

                              @Joerideman The bootloader doesn't generate serial debug output, would be helpful to see the GW debug log

                              1 Reply Last reply
                              0
                              • JoeridemanJ Offline
                                JoeridemanJ Offline
                                Joerideman
                                wrote on last edited by Joerideman
                                #15

                                @tekka Allright I am home again :-).

                                Here is the sketch I use for the gateway. It comes out of the examples folder from mysensors. I think Debug is enabled. But for 5-6 seconds after resetting the node, I get nothing out of the gateway.

                                 * 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-2019 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 tekka,
                                 * Contribution by a-lurker and Anticimex,
                                 * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
                                 * Contribution by Ivo Pullens (ESP8266 support)
                                 *
                                 * DESCRIPTION
                                 * The EthernetGateway sends data received from sensors to the WiFi link.
                                 * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
                                 *
                                 * VERA CONFIGURATION:
                                 * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
                                 * E.g. If you want to use the default values in this sketch enter: 192.168.178.66:5003
                                 *
                                 * LED purposes:
                                 * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
                                 * - 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 https://www.mysensors.org/build/connect_radio for wiring instructions.
                                 *
                                 * If you are using a "barebone" ESP8266, see
                                 * https://www.mysensors.org/build/esp8266_gateway#wiring-for-barebone-esp8266
                                 *
                                 * Inclusion mode button:
                                 * - Connect GPIO5 via switch to GND ('inclusion switch')
                                 *
                                 * Hardware SHA204 signing is currently not supported!
                                 *
                                 * Make sure to fill in your ssid and WiFi password below for ssid & pass.
                                 */
                                
                                // Enable debug prints to serial monitor
                                #define MY_DEBUG
                                
                                // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
                                #define MY_BAUD_RATE 57600
                                #define MY_RF24_CHANNEL (122)
                                
                                // Enables and select radio type (if attached)
                                #define MY_RADIO_RF24
                                //#define MY_RADIO_RFM69
                                //#define MY_RADIO_RFM95
                                
                                #define MY_GATEWAY_ESP8266
                                
                                #define MY_WIFI_SSID "-------"
                                #define MY_WIFI_PASSWORD "---------"
                                
                                // Set the hostname for the WiFi Client. This is the hostname
                                // passed to the DHCP server if not static.
                                #define MY_HOSTNAME "Mysensors_GW"
                                
                                // 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,178,87
                                
                                // If using static ip you can define Gateway and Subnet address as well
                                //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
                                //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
                                
                                // The port to keep open on node server mode
                                #define MY_PORT 5003
                                
                                // How many clients should be able to connect to this gateway (default 1)
                                #define MY_GATEWAY_MAX_CLIENTS 2
                                
                                // 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, 68
                                
                                // 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
                                // Led pins used if blinking feature is enabled above
                                #define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
                                #define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
                                #define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
                                
                                #include <ArduinoOTA.h>
                                #include <MySensors.h>
                                
                                void setup()
                                {
                                	// Setup locally attached sensors
                                	ArduinoOTA.onStart([]() {
                                		Serial.println("ArduinoOTA start");
                                	});
                                	ArduinoOTA.onEnd([]() {
                                		Serial.println("\nArduinoOTA end");
                                	});
                                	ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
                                		Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100)));
                                	});
                                	ArduinoOTA.onError([](ota_error_t error) {
                                		Serial.printf("Error[%u]: ", error);
                                		if (error == OTA_AUTH_ERROR) {
                                			Serial.println("Auth Failed");
                                		} else if (error == OTA_BEGIN_ERROR) {
                                			Serial.println("Begin Failed");
                                		} else if (error == OTA_CONNECT_ERROR) {
                                			Serial.println("Connect Failed");
                                		} else if (error == OTA_RECEIVE_ERROR) {
                                			Serial.println("Receive Failed");
                                		} else if (error == OTA_END_ERROR) {
                                			Serial.println("End Failed");
                                		}
                                	});
                                	ArduinoOTA.begin();
                                }
                                
                                void presentation()
                                {
                                	// Present locally attached sensors here
                                }
                                
                                void loop()
                                {
                                	// Send locally attached sensors data here
                                	ArduinoOTA.handle();
                                }
                                
                                
                                1 Reply Last reply
                                0
                                • JoeridemanJ Offline
                                  JoeridemanJ Offline
                                  Joerideman
                                  wrote on last edited by
                                  #16

                                  @tekka I used an rf24 sniffer. I tested if it received signals on channel 122 when I just upload my sketch. This works.

                                  No signal in over 5 minutes time after resetting the node. only signal came from the gateway itself.

                                  tekkaT 1 Reply Last reply
                                  0
                                  • JoeridemanJ Joerideman

                                    @tekka I used an rf24 sniffer. I tested if it received signals on channel 122 when I just upload my sketch. This works.

                                    No signal in over 5 minutes time after resetting the node. only signal came from the gateway itself.

                                    tekkaT Offline
                                    tekkaT Offline
                                    tekka
                                    Admin
                                    wrote on last edited by tekka
                                    #17

                                    @Joerideman Yeah, I assume something is wrong with the bootloader configuration. Can you zip and upload all bootloader files (or the entire folder) you are using with all the settings and modifications you did?

                                    1 Reply Last reply
                                    0
                                    • JoeridemanJ Offline
                                      JoeridemanJ Offline
                                      Joerideman
                                      wrote on last edited by Joerideman
                                      #18

                                      @tekka Here is a link to my onedrive: https://1drv.ms/u/s!ArHxoBCXZ0wDiKRLceoqlgchv1r_GQ?e=RvboMa

                                      It holds a zip archive.

                                      tekkaT 1 Reply Last reply
                                      0
                                      • JoeridemanJ Joerideman

                                        @tekka Here is a link to my onedrive: https://1drv.ms/u/s!ArHxoBCXZ0wDiKRLceoqlgchv1r_GQ?e=RvboMa

                                        It holds a zip archive.

                                        tekkaT Offline
                                        tekkaT Offline
                                        tekka
                                        Admin
                                        wrote on last edited by
                                        #19

                                        @Joerideman Thanks, I again had a quick look at your HW.h file and found the issue:

                                        // set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
                                        SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2) | ~_BV(SPI_MISO);
                                        CSN_DDR = _BV(CSN_PIN);
                                        

                                        SPI_DDR and CSN_DDR are both pointing at DDRB:

                                        // SPI communication
                                        #define SPI_PORT	PORTB	// 
                                        #define SPI_DDR		DDRB	//
                                        

                                        and

                                        #elif defined(SPI_PINS_CE8_CSN9)
                                        	#define CSN_PORT	PORTB	// port for CSN
                                        	#define CSN_DDR		DDRB	// DDR for CSN
                                        	#define	CSN_PIN		PB1		// Arduino Pin 9 <-> Bit 1 of port B
                                        
                                        

                                        Thus, setting CSN_DDR = _BV(CSN_PIN) you overwrite SPI_DDR. Comment out the second line and add _BV(CSN_PIN) to SPI_DDR:

                                        // set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
                                        SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2) |  _BV(CSN_PIN);
                                        //CSN_DDR = _BV(CSN_PIN);
                                        
                                        
                                        1 Reply Last reply
                                        1
                                        • JoeridemanJ Offline
                                          JoeridemanJ Offline
                                          Joerideman
                                          wrote on last edited by Joerideman
                                          #20

                                          @tekka

                                          Is this the only adjustment that I needed to make?

                                          // set pin mode: MOSI,SCLK,CE,CSN = OUTPUT, MISO = INPUT (=> all on same port)
                                          SPI_DDR = _BV(SPI_MOSI) | _BV(SPI_SCLK) | _BV(CE_PIN) | _BV(PB2) |  _BV(CSN_PIN);
                                          //CSN_DDR = _BV(CSN_PIN);
                                          

                                          at this point there is no fota and somewhere in the past days Serial update using the uart has also been destroyed again. I think I should restart with a clean download and start again. I am afraid I changed things I should not have,

                                          The log from running make. I notice now that some parts are failed. But I do not know what that means. I do not remember if this was alway the case. This might be a clue that something went wrong.

                                          G:\OneDrive\Arduino\mysensors\MySensorsBootloaderRF24-development>make
                                          rm *.o
                                          process_begin: CreateProcess(NULL, rm *.o, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          rm *.elf
                                          process_begin: CreateProcess(NULL, rm *.elf, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          rm *.hex
                                          process_begin: CreateProcess(NULL, rm *.hex, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-objcopy" -O ihex -R .eeprom MYSBootloader.elf MYSBootloader.hex
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-size" MYSBootloader.elf
                                             text    data     bss     dec     hex filename
                                             2032       6      71    2109     83d MYSBootloader.elf
                                          

                                          With a fresh download of all the files without any changes to the make file I get this:
                                          It says in dutch "make (e=2) the system can not find the file specified"

                                          rm *.o
                                          process_begin: CreateProcess(NULL, rm *.o, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          rm *.elf
                                          process_begin: CreateProcess(NULL, rm *.elf, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          rm *.hex
                                          process_begin: CreateProcess(NULL, rm *.hex, ...) failed.
                                          make (e=2): Het systeem kan het opgegeven bestand niet vinden.
                                          make: [clean] Fout 2 (genegeerd)
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-gcc" -I"C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/avr/include/avr          " -funsigned-char -funsigned-bitfields -DF_CPU=16000000L -DBAUD_RATE=115200 -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -Wall -Wextra -Wundef -pedantic -mmcu=atmega328p -c -std=gnu99 -MD -MP -MF "MYSBootloader.d" -MT"MYSBootloader.d" -MT"MYSBootloader.o"  MYSBootloader.c -o MYSBootloader.o
                                          In file included from Core.h:40:0,
                                                           from MYSBootloader.c:81:
                                          HW.h:51:4: warning: #warning is a GCC extension
                                             #warning BAUD_RATE error greater than 2%
                                              ^
                                          HW.h:51:4: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-gcc" -nostartfiles -Wl,-s -Wl,-static -Wl,-Map=".map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -mrelax -Wl,-section-start=.text=0x7800 -mmcu=atmega328p   -o MYSBootloader.elf MYSBootloader.o -lm
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-objcopy" -O ihex -R .eeprom MYSBootloader.elf MYSBootloader.hex
                                          "C:/Program Files (x86)/Atmel/Studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/avr-size" MYSBootloader.elf
                                             text    data     bss     dec     hex filename
                                             2032       6      71    2109     83d MYSBootloader.elf
                                          
                                          tekkaT 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular