Skip to content

Basic configuration

Xose Pérez edited this page Oct 14, 2018 · 11 revisions

The RadioCrafts radio module has a non-volatile memory that can be used to store radio settings that will persist across reboots. That is why the AllWize library initialization code does not change any of the radio module pre-existing settings.

If you want to set the radio module into a defined state you will have to set it manually either by calling specific methods that modify these settings or by calling a role method (slave or master).

Initialization example

A simple initialization code would be:

#include "AllWize.h"
AllWize * allwize;

#define RESET_PIN 7

setup() {

    // Create and init AllWize object in the main HardwareSerial
    allwize = new AllWize(&Serial, RESET_PIN);
    allwize->begin();
    if (!allwize->waitForReady()) {
        DEBUG_SERIAL.println("Error connecting to the module, check your wiring!");
        while (true);
    }

    allwize->slave();
    allwize->setChannel(CHANNEL_04, true);
    allwize->setPower(POWER_20dBm);
    allwize->setControlInformation(0x09);

}

loop() {
}

You can check the examples in the library to know how to instantiate the library for different platforms.

Predefined roles

AllWize::slave()

  • Sets the radio into N1 mode (this is the default mode for the current version, will be upgraded to Wize once Wize modules are available).
  • Sets network role to slave.
  • Sets transmitting power to 20dBm.
  • Sets datarate to 2400bps.

AllWize::master()

  • Sets the radio into N1 mode (this is the default mode for the current version, will be upgraded to Wize once Wize modules are available).
  • Sets network role to master.
  • Sets transmitting power to 20dBm.
  • Sets datarate to 2400bps.
  • Sets install mode to host, meaning the module will transparently forward all incoming messages to the microcontroller.
  • Disables sleep mode.
  • Sets message format to Start/Stop including RSSI info.

Specific settings

This is a partial list of settings. Check the library documentation for further methods and information.

AllWize::setChannel(uint8_t channel, bool persist)

Defines the communication channel. The available channels depend on the WMBUS mode. The persist flag indicates whether the setting should be stored in non-volatile memory or not (default is false). The default one after a factory reset is channel 3.

allwize->setChannel(CHANNEL_04);

Available RF channels for RC1701HP-OSP as per datasheet:

  • 1: 169.406250 MHz (Channel 1a)
  • 2: 169.418750 Mhz (Channel 1b)
  • 3: 169.431250 MHz (Channel 2a)
  • 4: 169.443750 MHz (Channel 2b)
  • 5: 169.456250 MHz (Channel 3a)
  • 6: 169.468750 MHz (Channel 3b)
  • 7: 169.412500 MHz (Channel 1)
  • 8: 169.437500 MHz (Channel 2)
  • 9: 169.462500 MHz (Channel 3)
  • 10: 169.437500 MHz (Channel 0)

AllWize::setNetworkRole(uint8_t role)

Sets the role for the current node. It can be one of NETWORK_ROLE_SLAVE, NETWORK_ROLE_MASTER or NETWORK_ROLE_REPEATER. It is recommended to use one of the role methods AllWize::slave(), AllWize::master() or AllWize::repeater().

allwize->setNetworkRole(NETWORK_ROLE_SLAVE);

AllWize::setSleepMode(uint8_t mode)

Defines the automatic sleep mode to use. Can be one of SLEEP_MODE_DISABLE, SLEEP_MODE_AFTER_TX, SLEEP_MODE_AFTER_TX_RX, SLEEP_MODE_AFTER_TX_TIMEOUT or SLEEP_MODE_AFTER_TX_RX_TIMEOUT.

When enabled sets the module to enter sleep mode after transmission (or reception). Set the delay with AllWize::setTimeout(uint8_t). If enabled with sleep timeout, the module goes directly to Sleep after a Reset, and to Sleep after TIMEOUT when wake up.

// Enter sleep mode 2 seconds after transmission
allwize->setSleepMode(SLEEP_MODE_AFTER_TX);
allwize->setTimeout(2);

AllWize::setPower(uint8_t power, bool persist)

Sets the transmit power. It can be one of POWER_14dBm, POWER_17dBm, POWER_20dBm, POWER_24dBm or POWER_27dBm. Increasing the transmit power helps to reach further or deeper, but also spends much more energy. The persist flag indicates whether the setting should be stored in non-volatile memory or not (default is false). The default setting after a factory reset is +27dBm for the RC1701HP-OSP module.

allwize->setPower(POWER_20dBm);

According to the RC1701HP-OSP datasheet, these are the TX power peaks depending on the power setting with a 50Ohm load:

Power value Power setting dBm mA
5 POWER_27dBm +27 dBm 402.7
4 POWER_24dBm +24 dBm 268.8
3 POWER_20dBm +20 dBm 181.2
2 POWER_17dBm +17 dBm 140.2
1 POWER_14dBm +14 dBm 107.7

AllWize::setControlField(uint8_t value, bool persist)

The persist flag indicates whether the setting should be stored in non-volatile memory or not (default is false).

allwize->setControlField(0x46);

Clone this wiki locally