How to use SPSGRF (Sub1Ghz module) for remote a thermostat

If you like it, share it

Often there is the necessity to move a thermostat but there is the problem to move the wires.
In this tutorial I explain the simple changes to be made to the X-CUBE-SUBG1 (ver. 1.2.0) software for remoting via wireless (Sub1GHz) a thermostat or in general a digital signal.

Below there is my solution.

remoteio

All is builded using the NUCLEO-F401RE, X-NUCLEO-IDS01A4 (868 MHz transceiver evaboard) and KEIL (ver.5.20.0) compiler.
Alternatively is possible use the boards below:
X-NUCLEO-IDS01A5 (915 MHz transceiver module)
NUCLEO-L053R8
NUCLEO-L152RE
Alternatively is possible use the Compilers below:
IAR
AC6 (SW4STM32)


 

SW – Do the steps below

  1. Download the X-CUBE-SUBG1 and unzip it.
  2. Go in the directory:
    …\STM32CubeExpansion_SUBG1_V1.2.0\Projects\Multi\Examples\P2P_demo\MDK-ARM\STM32F401RE-Nucleo
    and double click on the:
    P2P_Demo.uvprojx
  3. Compile the project.
    You must see something like below.
    Program Size: Code=26008 RO-data=920 RW-data=296 ZI-data=1936  
    FromELF: creating hex file…
    .\Listing\STM32F401RE-Nucleo_P2P.hex
    Finished: 0 information, 1 warning and 0 error messages.
    “.\Listing\STM32F401RE-Nucleo_P2P.axf” – 0 Error(s), 0 Warning(s).
    Build Time Elapsed:  00:00:06
  4. Edit the file: spirit1_appli.c
    Comment the line n.416
    // RadioShieldLedOn(RADIO_SHIELD_LED);
    Insert the line n.417
    RadioShieldLedToggle(RADIO_SHIELD_LED);
  5. Edit the file: spirit1_appli.c
    Comment the line from n.409 to n.413
    and insert the line n.407
    RadioShieldLedToggle(RADIO_SHIELD_LED);
    See below.



  6. Edit the file: stm32f4xx_nucleo.c
    Comment the line n.291
    // GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
    Insert the line n.292
    GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
  7. Edit the file: spirit1_appli.h
    Line n.151 change the baudrate, see below.
    Plus the baud rate is low, plus the distance covered by the RTX increase.
    #define DATARATE 9600 // 38400
    Line n.203
    #define MAX_RETRANSMISSIONS PKT_ENABLE_RETX // PKT_DISABLE_RETX

  8. Compile again, the project.
  9. Program both KIT and you’re ready to remote your thermostat.


Schematics / Connections

I use the USB connector to power the boards using an USB charger, for this reason is necessary install the JP1 jumper on the NUCLEO board.

Thermostat Interface

remoteio_termostato

Remote Relay Interface

remoteio_rele


 

  • NOTE
    For a deep description of the Point-to-Point communications SW see this manual (UM1904)

    • The file: spirit1_appli.h
      contain the SPIRIT1 parameters, that can be modified by the user according to the
      application.

      There are two variables that are:
      Line n.62 – #define MY_ADDRESS                               0x44
      Line n.63 – #define DESTINATION_ADDRESS      0x44

      I suggest to change this two values (0x44) with a new values to avoid the possibility that another application use the same address.
    • In the file: spirit1_appli.c
      from line n.293
      there is the: SPIRIT1 P2P Process State machine



If you need this example ready to use for NUCLEO-F401RE, X-NUCLEO-IDS01A4
and KEIL, please send me an email and ask me the password for open:
Remote-Thermostat
please specify also your Name, City and Country

For run project under KEIL go in this directory:
…\Projects\Multi\Examples\P2P_demo\MDK-ARM\STM32F401RE-Nucleo
and double click on the:
P2P_Demo.uvprojx