You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
#defineDHTTYPE DHT11 // Dependiendo del tipo de sensor
DHT dht(3,DHTTYPE); // Initialization// Distance sensorconstint Trigger = 5; //Pin digital 2 para el Trigger del sensor// el 2 es usado por el IRQ del RFM69constint Echo = 4; //Pin digital 3 para el Echo del sensor
#defineIS_RFM69HW// Addresses for this node. CHANGE THESE FOR EACH NODE!
#defineNETWORKID0// Must be the same for all nodes
#defineMYNODEID1// My node ID
#defineTONODEID2// +Destination node ID// RFM69 frequency, uncomment the frequency of your module:
#defineFREQUENCY RF69_868MHZ // In Europe// AES encryption (or not):
#defineENCRYPTtrue// Set to "true" to use encryption
#defineENCRYPTKEY"TOPSECRETPASSWRD"// Use the same 16-byte key on all nodes// Use ACKnowledge when sending messages (or not):
#defineUSEACKtrue// Request ACKs or not// Packet sent/received indicator LED (optional):
#defineLED9// LED positive pin
#defineGND8// LED ground pin// Create a library object for our RFM69HCW module:
RFM69 radio;
// NOTA: para el ATmega328p, RFM.h define: RF69_IRQ_PIN=2voidsetup()
{
// Open a serial port so we can send keystrokes to the module:
Serial.begin(9600);
// Distance sensorpinMode(Trigger, OUTPUT); //pin como salidapinMode(Echo, INPUT); //pin como entradadigitalWrite(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);
}
voidloop()
{
staticchar sendbuffer[9];
// Leemos la humedad relativafloat 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 lecturaif (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 ecolong d; //distancia en centimetrosdigitalWrite(Trigger, HIGH);
delayMicroseconds(10); //Enviamos un pulso de 10usdigitalWrite(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);
// SENDINGdelay(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.
The text was updated successfully, but these errors were encountered:
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.
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:
Any suggestion? I am a newbie by the way.
The text was updated successfully, but these errors were encountered: