Skip to content

Possibility to set the TxPower #15

@TRudolphi

Description

@TRudolphi

I wanted to have the possibility to set the TxPower of my sensors so nearby nodes can be set to a lower power to save the batteries. I changed in my local copy of LoRaNow the following to add this (the sf was already in the lib, but I set it in the text for orientation):

LoRaNow.h:
#define LORANOW_DEFAULT_SF 7
#define LORANOW_DEFAULT_POWER 10

class LoRaNowClass : public Stream
{
private:
uint8_t sf = LORANOW_DEFAULT_SF;
uint8_t txpower = LORANOW_DEFAULT_POWER;

void setSpreadingFactor(int _sf);
void setTxPower(uint8_t _power );

LoRaNow.cpp:
void LoRaNowClass::setSpreadingFactor(int _sf)
{
sf = _sf;
}

void LoRaNowClass::setTxPower(uint8_t _power )
{
txpower = _power;
}

void LoRaNowClass::txMode()
{
LORANOW_DEBUG_PRINT(millis());LORANOW_DEBUG_PRINTLN("[ln] txMode");
LoRa.idle();
LoRa.setFrequency(frequency);
LoRa.setSpreadingFactor(sf);
LoRa.setTxPower(txpower);

==
Maybe this addition is also handy for other users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions