Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setHighPower freezes #192

Open
mantielero opened this issue Aug 23, 2024 · 1 comment
Open

setHighPower freezes #192

mantielero opened this issue Aug 23, 2024 · 1 comment

Comments

@mantielero
Copy link

I have an arduino nano v3 and a RFM69HW. Everything works fine, but when I set: radio.setHighPower(); it gets blocked when I perform: radio.send(TONODEID,sendbuffer,9);.

The RFM69HW is fed using the 3V3 from the RFM69HW (I am not sure if this could be an issue).

My code:

// RFM69HCW Example Sketch
// Send serial input characters from one RFM69 node to another
// Based on RFM69 library sample code by Felix Rusu
// http://LowPowerLab.com/contact
// Modified for RFM69HCW by Mike Grusin, 4/16

// This sketch will show you the basics of using an
// RFM69HCW radio module. SparkFun's part numbers are:
// 915MHz: https://www.sparkfun.com/products/12775
// 434MHz: https://www.sparkfun.com/products/12823

// See the hook-up guide for wiring instructions:
// https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide

// Uses the RFM69 library by Felix Rusu, LowPowerLab.com
// Original library: https://www.github.com/lowpowerlab/rfm69
// SparkFun repository: https://github.com/sparkfun/RFM69HCW_Breakout

// Include the RFM69 and SPI libraries:

#include <RFM69.h>
#include <RFM69_ATC.h>     //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <DHT.h>


// Temperature / Humidity sensor
#define DHTTYPE DHT11  // Dependiendo del tipo de sensor
DHT dht(3,DHTTYPE);    // Initialization

// Distance sensor
const int Trigger = 5; //Pin digital 2 para el Trigger del sensor
// el 2 es usado por el IRQ del RFM69
const int Echo = 4;    //Pin digital 3 para el Echo del sensor

#define IS_RFM69HW
// Addresses for this node. CHANGE THESE FOR EACH NODE!

#define NETWORKID     0   // Must be the same for all nodes
#define MYNODEID      1   // My node ID
#define TONODEID      2   // +Destination node ID

// RFM69 frequency, uncomment the frequency of your module:
#define FREQUENCY     RF69_868MHZ  // In Europe

// AES encryption (or not):

#define ENCRYPT       true // Set to "true" to use encryption
#define ENCRYPTKEY    "TOPSECRETPASSWRD" // Use the same 16-byte key on all nodes

// Use ACKnowledge when sending messages (or not):

#define USEACK        true // Request ACKs or not

// Packet sent/received indicator LED (optional):

#define LED           9 // LED positive pin
#define GND           8 // LED ground pin

// Create a library object for our RFM69HCW module:

RFM69 radio;
// NOTA: para el ATmega328p, RFM.h define: RF69_IRQ_PIN=2

void setup()
{
  // Open a serial port so we can send keystrokes to the module:

  Serial.begin(9600);

  // Distance sensor
  pinMode(Trigger, OUTPUT); //pin como salida
  pinMode(Echo, INPUT);  //pin como entrada
  digitalWrite(Trigger, LOW);//Inicializamos el pin con 0

  // Comenzamos el sensor DHT
  dht.begin();

  // Print some info to the serial console
  Serial.print("Node ");
  Serial.print(MYNODEID,DEC);
  Serial.println(" ready");  

  // Set up the indicator LED (optional):

  // Initialize the RFM69HCW:
  radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
  radio.setHighPower(); // Always use this for RFM69HCW
  //radio.setPowerDBm(20);
  //radio.setPowerLevel(31);

  // Turn on encryption if desired:

  if (ENCRYPT)
    radio.encrypt(ENCRYPTKEY);
}

void loop()
{

  static char sendbuffer[9];

  // Leemos la humedad relativa
  float humidity = dht.readHumidity();
  // Leemos la temperatura en grados centígrados (por defecto)
  float temperature = dht.readTemperature();
  // Comprobamos si ha habido algún error en la lectura
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Error obteniendo los datos del sensor DHT11");
    return;
  }
  float velocity = 331.4 + 0.606 * temperature + 0.0124 * humidity;


 
  Serial.println("- Velocity calculated"); 
  //-----------
  long t; //tiempo que demora en llegar el eco
  long d; //distancia en centimetros

  digitalWrite(Trigger, HIGH);
  delayMicroseconds(10);          //Enviamos un pulso de 10us
  digitalWrite(Trigger, LOW);
 
  t = pulseIn(Echo, HIGH); //obtenemos el ancho del pulso
  Serial.println("- Trigger + Echo");   

  d = velocity * t  / 20000;  

  Serial.println("Before print");
  Serial.print("Humedad: ");
  Serial.print(humidity,0);
  Serial.print("%   ");
  Serial.print("Temperatura: ");
  Serial.print(temperature,0);
  Serial.print("*C   ");
  Serial.print("   Velocity: ");
  Serial.print(velocity,0);
  Serial.print("m/s  ");  
  Serial.print("Distancia: ");
  Serial.print(d,0);      //Enviamos serialmente el valor de la distancia
  Serial.println("cm  ");

  snprintf(sendbuffer, sizeof(sendbuffer), "%02d%03d%03d",  
            (int)round(humidity), 
            (int)round(temperature), 
            (int)round(d));
           
  Serial.println(sendbuffer);


  // SENDING
  delay(500);

  Serial.println("Sending: start");
  delay(500);
  radio.send(TONODEID,sendbuffer,9);
  delay(500);
  Serial.println("Sending: end");
  delay(500);


  delay(2000);          //Hacemos una pausa de 100ms
}

Any suggestion? I am a newbie by the way.

@mantielero
Copy link
Author

By feeding the RFM69HW with: (Arduino Nano V3 - 5V) --> (Regulator: 5V-->3V3) --> (RFM69), it sends the message once, but it freezes in the second iteration after printing: Sending: start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant