Tapatalk

Wireless distances very very short

Wireless distances very very short

8

PostJun 26, 2019#1

I tried two Whisper Nodes AVR with the included antennas.
I loaded the Voltage.Base and Voltage.Node sketches.
The connection works, but beyond a distance of 3m (direct line of sight), the connection doesn't work anymore.
I tried different other antennas (simple 85mm wire, coil antennas) with the same results.
I'm confused due to i expected much much further distances possible.

Might the products be damaged (never tried without antenna, of course).
Or any other hints?

Thanks in advance.

André

1885
1885

PostJun 26, 2019#2

Hi Andre,

Could you please share the sample code you're using as well a picture of the back of your Whisper Node so I can verify the model/version?

Thanks

8

PostJun 27, 2019#3

Hi

I have 3 whisper nodes. All are Version 1.0.
I ordered those about 8 weeks ago.
I swapped them among each other with the same result each time.
Due to that, i gues they have all 3 no problem or all have the same problem.


This is code 1:

Code: Select all

/*
 * SENDER
 * ======
 */
#include <T2WhisperNode.h>

/* You need to configure the Whisper Node Version */
#define T2_WPN_BOARD T2_WPN_VER_RF69
//#define T2_WPN_BOARD T2_WPN_VER_LORA

#define RADIO_FREQUENCY 868.0
#define RADIO_TX_POWER 13
#define RADIO_ENCRYPTION_KEY { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } // Only used by RF69

#if T2_WPN_BOARD == T2_WPN_VER_RF69
#include <RH_RF69.h>
RH_RF69 myRadio;
#elif T2_WPN_BOARD == T2_WPN_VER_LORA
#include <RH_RF95.h>
RH_RF95 myRadio;
#endif

// LED
T2Led myLedBlue(T2_WPN_LED_1);
T2Led myLedYellow(T2_WPN_LED_2);

// Radio
uint8_t radioBuf[(T2_MESSAGE_HEADERS_LEN + T2_MESSAGE_MAX_DATA_LEN)];

// T2 Message
T2Message myMsg;
#define nodeAddr 0x88
#define baseAddr 0x0B

// T2 Data Buffer
T2DataBuffer myDataBuffer;

// Stand-alone Task
void taskVoltageFunction(T2Task * Task); // Implemented at the bottom of this file
T2Task myTaskVoltage(&taskVoltageFunction);
//==============================================================================
void taskVoltageFunction(T2Task * Task)
{
  Serial.println(F("TaskRunning"));

  // Se the Yellow LED to blink, indicating are doing something
  myLedYellow.setBlink(10, 0, 1); // LED will lit for 10ms only once, so the interval doesn't matter
  
  sendTestVoltage(1);
  sendTestVoltage(2);
}
//==============================================================================
void sendTestVoltage(uint8_t supply)
{
  uint16_t voltage = 0;

  // Get Voltage readings from supply/battery
  if(supply == 1)
  {
    voltage = T2Utils::readVoltage(T2_WPN_VBAT_VOLTAGE, T2_WPN_VBAT_CONTROL);
    myMsg.sdx = 0x64; // Battery
  }

  if(supply == 2)
  {
    voltage = T2Utils::readVoltage(T2_WPN_VIN_VOLTAGE, T2_WPN_VIN_CONTROL);
    myMsg.sdx = 0x65; // Supply
  }

  uint8_t radioBufLen = 0;

  // Prepare Message
  myMsg.cmd = 0x00;
  myMsg.idx = 0x06;
  myMsg.src = nodeAddr;
  myMsg.dst = baseAddr;
  myMsg.data[0] = 0x01; // Operation Last Reading
  myMsg.data[1] = 0x01; // Battery/Supply Index, if multiple supplies
  myMsg.data[2] = voltage >> 8;
  myMsg.data[3] = voltage;
  myMsg.len = 4; //Update length
  
  // Encode Message and get the full length
  myMsg.getSerializedMessage(radioBuf, &radioBufLen);
  
  // Send it
  myRadio.send(radioBuf, radioBufLen);
  myRadio.waitPacketSent(100);
}
//==============================================================================
void setup()
{
  // Serial
  Serial.begin(115200);
  Serial.println(F("Voltage - Node"));

  // Radio
  myRadio.init();
  myRadio.setFrequency(RADIO_FREQUENCY);
  myRadio.setTxPower(RADIO_TX_POWER);
#if T2_WPN_BOARD == T2_WPN_VER_RF69
  uint8_t myRadioEncryptionKey[] = RADIO_ENCRYPTION_KEY;
  myRadio.setEncryptionKey(myRadioEncryptionKey);
#endif  

  // Stand-alone Task
  myTaskVoltage.runInterval(5000);   // Task will tun every 1000 milliseconds
  myTaskVoltage.runCount(0);         // Task will run forever
  myTaskVoltage.status(T2TASK_STATUS_SCHEDULED);

  // LED Example
  //myLedBlue.setBlink(20, 500, -1);   // LED will lit for 20ms every 250ms, forever
}
//==============================================================================
void loop()
{
  // Stand-alone Task - We run it as a non-blocking Task
  myTaskVoltage.run();

  // LED Example
  myLedBlue.run();
  myLedYellow.run();
}
This is code 2:

Code: Select all

/*
 * Empfänger
 * =========
 * Talk2 Example: Voltage - Base
 * http://talk2.wisen.com.au
 *
 * This example demonstrate how to receive a message and print on the Serial.
 * The message to be received is the voltage readings from the Power Supply
 * and the Battery, sent by a remote node.
 * 
 * - This example works together with "Voltage - Node"
 * - The messages are formatted using the Talk2 Message frame
 * - Remember to adjust the frequency and TX Power to match your board
 *
 *  Copyright 2015-2016 by Mike Musskopf.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <T2WhisperNode.h>

/* You need to configure the Whisper Node Version */
#define T2_WPN_BOARD T2_WPN_VER_RF69
//#define T2_WPN_BOARD T2_WPN_VER_LORA

#define RADIO_FREQUENCY 868.0
#define RADIO_TX_POWER 13
#define RADIO_ENCRYPTION_KEY { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F } // Only used by RF69

#if T2_WPN_BOARD == T2_WPN_VER_RF69
#include <RH_RF69.h>
RH_RF69 myRadio;
#elif T2_WPN_BOARD == T2_WPN_VER_LORA
#include <RH_RF95.h>
RH_RF95 myRadio;
#endif

// LED
T2Led myLedBlue(T2_WPN_LED_1);
T2Led myLedYellow(T2_WPN_LED_2);

// Radio
uint8_t radioBuf[(T2_MESSAGE_HEADERS_LEN + T2_MESSAGE_MAX_DATA_LEN)];

// T2 Message
T2Message myMsg;
#define nodeAddr 0x88
#define baseAddr 0x0B

// T2 Data Buffer
T2DataBuffer myDataBuffer;

// Stand-alone Task
void taskPrintFunction(T2Task * Task); // Implemented at the bottom of this file
T2Task myTaskPrint(&taskPrintFunction);

// Global Variables to hold the Received data
uint16_t batVoltage = 0;
uint16_t batVoltageCounter = 0;
uint16_t supVoltage = 0;
uint16_t supVoltageCounter = 0;

void setup()
{
  // Serial
  Serial.begin(115200);
  Serial.println(F("Voltage - Base"));

  // Radio
  myRadio.init();
  myRadio.setFrequency(RADIO_FREQUENCY);
  myRadio.setTxPower(RADIO_TX_POWER);
#if T2_WPN_BOARD == T2_WPN_VER_RF69
  uint8_t myRadioEncryptionKey[] = RADIO_ENCRYPTION_KEY;
  myRadio.setEncryptionKey(myRadioEncryptionKey);
#endif  

  // Stand-alone Task
  myTaskPrint.runInterval(5000);   // Task will tun every 1000 milliseconds
  myTaskPrint.runCount(0);         // Task will run forever
  myTaskPrint.status(T2TASK_STATUS_SCHEDULED);

  // LED Example
  myLedYellow.setBlink(20, 3000, -1);   // LED will lit for 20ms every 3000ms, forever
}

void loop()
{
  // Stand-alone Task - We run it as a non-blocking Task to print the readings
  myTaskPrint.run();

  // LED Example
  myLedBlue.run();
  myLedYellow.run();
  
  // Run the Receiving function
  runReceiver();
}

void runReceiver()
{
  /* RFM69 Receive */
  uint8_t radioBufLen = sizeof(radioBuf);
  if(myRadio.recv(radioBuf, &radioBufLen))
  {
    myMsg.setSerializedMessage(radioBuf, radioBufLen);
    // Uncomment bellow to print every received message, just be careful as
    // delays here can cause messages to be lost.
    //myMsg.printMessage();

    // We can perform some message filtering based on it's headers
    if(myMsg.idx == 0x06 && myMsg.src == nodeAddr && myMsg.dst == baseAddr)
    {

      // Lets blink something
      myLedBlue.setBlink(10, 0, 1); // LED will lit for 10ms only once, so the interval doesn't matter
      
      switch(myMsg.sdx)
      {
      case 0x64: // Battery Voltage
        // Increment Counter
        batVoltageCounter++;
        // Concatenate 2 bytes into a uint16_t variable
        batVoltage = myMsg.data[2] << 8;
        batVoltage |= myMsg.data[3];
        break;

      case 0x65: // Power Supply Voltage
        // Increment Counter
        supVoltageCounter++;
        // Concatenate 2 bytes into a uint16_t variable
        supVoltage = myMsg.data[2] << 8;
        supVoltage |= myMsg.data[3];
        break;
        
      default: // Can define an operation for everything else
        // Do something
        Serial.println(F("Unexpected message received: "));
        myMsg.printMessage();
        break;
      }
    }
  }
}

void taskPrintFunction(T2Task * Task)
{
  // We simply print the last data we got
  Serial.println(F("### Latest Voltage Readings ###"));
  Serial.print(F("       Battery: ")); Serial.print(batVoltage); Serial.print(F(" millivolts. ")); Serial.println(batVoltageCounter);
  Serial.print(F("  Power Supply: ")); Serial.print(supVoltage); Serial.print(F(" millivolts. ")); Serial.println(supVoltageCounter);
  Serial.println();
}
Thanks in advance.
Regards

1885
1885

PostJun 27, 2019#4

Hi,

I can see you've ordered the "High-power" version. In this case, you'll need to set the power to a value greater than 13 or change the code as per instructions below:

From:

Code: Select all

myRadio.setTxPower(RADIO_TX_POWER);
To:

Code: Select all

myRadio.setTxPower(RADIO_TX_POWER, true);
This will tell the Radio to use the build-in PA. Also, you can set the power up to 20 for extra range. You can find additional detail about the RH69 library here: https://www.airspayce.com/mikem/arduino ... _RF69.html

Please share the results. Thanks!

8

PostJun 28, 2019#5

That was the cause.
I just tested across 10m through walls. It works perfectly with power value = 14
Thanks a lot.

I suggest to comment that alternative for the "High-power" version in the library examples. That was everything else than obvious for me.

Regards