Hello,
i have a sparkfun rf pro board with the RF95 lora on board.
i want to send a "1" every time a pulse from sensor (on pin2) come's in. but when i do this it is not working after 1 pulse:
/* Simple Pulse Counter
Counts digital pulses fed into pin 12. For reliability, the minimum pulse width is 1 millisecond.
If the signal is held high, the arduino will count it as one pulse.
*/
#include <RH_RF95.h>
RH_RF95 rf95;
float frequency = 868.0; // Change the frequency here.
uint8_t data[] = "1";
void setup(){
attachInterrupt(2, onPulse, FALLING);
SerialUSB.begin(9600);
SerialUSB.println(F("No pulses yet...")); // Message to send initially (no pulses detected yet).
if (!rf95.init())
SerialUSB.println("init failed");
// Setup ISM frequency
rf95.setFrequency(frequency);
// Setup Power,dBm
rf95.setTxPower(10);
// sensors.begin();
}
void loop(){
}
void onPulse()
{
// rf95.send(data, sizeof(data));
SerialUSB.println("1");
}
but when i comment out the line i get a perfect read on the serial monitor. It is like if he sends the data he stops the sketch:
/* Simple Pulse Counter
Counts digital pulses fed into pin 12. For reliability, the minimum pulse width is 1 millisecond.
If the signal is held high, the arduino will count it as one pulse.
*/
#include <RH_RF95.h>
RH_RF95 rf95;
float frequency = 868.0; // Change the frequency here.
uint8_t data[] = "1";
void setup(){
attachInterrupt(2, onPulse, FALLING);
SerialUSB.begin(9600);
SerialUSB.println(F("No pulses yet...")); // Message to send initially (no pulses detected yet).
if (!rf95.init())
SerialUSB.println("init failed");
// Setup ISM frequency
rf95.setFrequency(frequency);
// Setup Power,dBm
rf95.setTxPower(10);
// sensors.begin();
}
void loop(){
}
void onPulse()
{
rf95.send(data, sizeof(data));
SerialUSB.println("1");
}
a bit of help would be nice, i'm very new to this.
a second question would be how do i get the RF board and the RF95 to deep sleep until another "pulse" arrives? I want to let this sensor battery powered for months. I have a lipro battery connected to it so i want it to last long. important to know is that this board has the SAMD21 microprocessor on board.
thanks for the help in advance,
mathias