Hi Guys
i have one Moteino as receiver and one Arduino pro mini as sender. the sender is powered up with a battery on it and the receiver has connected to my laptop to power up
i want to bring the sender in sleep mode, when the receiver is not on
in fact i need , my sender listen for example every minute, when my receiver is not on
and when the receiver is on, the receiver send something to sender, so that , the sender understand the receiver is on and start to send the data
but i dont know how
the both of them are able to receive and send data
i am searching for a solution for my problem
i really thank you to some one, who help me
in following are my receiver and sender code:
receiver code:
// Sample RFM69 receiver/gateway sketch, with ACK and optional encryption, and Automatic Transmission Control
// Passes through any wireless received messages to the serial port & responds to ACKs
// It also looks for an onboard FLASH chip, if present
// **********************************************************************************
// Copyright Felix Rusu 2016, http://www.LowPowerLab.com/contact
// **********************************************************************************
// License
// **********************************************************************************
// 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.
//
// Licence can be viewed at
// http://www.gnu.org/licenses/gpl-3.0.txt
//
// Please maintain this license information along with authorship
// and copyright notices in any redistribution of this code
// **********************************************************************************
#include <RFM69.h> //get it here: GitHub - LowPowerLab/RFM69: RFM69 library for RFM69W, RFM69HW, RFM69CW, RFM69HCW (semtech SX1231, SX1231H)
#include <RFM69_ATC.h> //get it here: GitHub - LowPowerLab/RFM69: RFM69 library for RFM69W, RFM69HW, RFM69CW, RFM69HCW (semtech SX1231, SX1231H)
#include <SPIFlash.h> //get it here: GitHub - LowPowerLab/SPIFlash: Arduino library for read/write access to SPI flash memory chips
#include <SPI.h> //included with Arduino IDE install (www.arduino.cc)
//*********************************************************************************************
//************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID 1 //unique for each node on same network
#define NETWORKID 100 //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY RF69_433MHZ
#define FREQUENCY RF69_868MHZ
//#define FREQUENCY RF69_915MHZ
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
//#define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW!
//*********************************************************************************************
//Auto Transmission Control - dials down transmit power to save battery
//Usually you do not need to always transmit at max output power
//By reducing TX power even a little you save a significant amount of battery power
//This setting enables this gateway to work with remote nodes that have ATC enabled to
//dial their power down to only the required level
//#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL
//*********************************************************************************************
#define SERIAL_BAUD 9600
#ifdef AVR_ATmega1284P
#define LED 15 // Moteino MEGAs have LEDs on D15
#define FLASH_SS 23 // and FLASH SS on D23
#else
#define LED 9 // Moteinos have LEDs on D9
#define FLASH_SS 8 // and FLASH SS on D8
#endif
#ifdef ENABLE_ATC
RFM69_ATC radio;
#else
RFM69 radio;
#endif
SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit Windbond chip (W25X40CL)
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network
void setup() {
Serial.begin(SERIAL_BAUD);
delay(10);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW_HCW
radio.setHighPower(); //must include this only for RFM69HW/HCW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
//radio.setFrequency(919000000); //set frequency to some custom frequency
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
//Serial.println(buff);
if (flash.initialize())
{
//Serial.print("SPI Flash Init OK. Unique MAC = [");
flash.readUniqueId();
for (byte i=0;i<8;i++)
{
// Serial.print(flash.UNIQUEID*, HEX);*
-
if (i!=8) ;//Serial.print(':');*
-
}*
-
// Serial.println(']');*
-
//alternative way to read it:*
_ //byte* MAC = flash.readUniqueId();_
-
//for (byte i=0;i<8;i++)*
-
//{*
_ // Serial.print(MAC*, HEX);_
_ // Serial.print(' ');_
_ //}_
_ }_
_ else*_
* Serial.println("SPI Flash MEM not found (is chip soldered?)...");*
#ifdef ENABLE_ATC
* Serial.println("RFM69_ATC Enabled (Auto Transmission Control)");
_#endif*_
}
byte ackCount=0;
uint32_t packetCount = 0;
void Blink(byte PIN, int DELAY_MS)
{
* pinMode(PIN, OUTPUT);*
* digitalWrite(PIN,HIGH);*
* delay(DELAY_MS);
_ digitalWrite(PIN,LOW);_
_}_
void loop() {
_ //process any serial input*_
* if (Serial.available() > 0)*
* {*
* char input = Serial.read();*
* if (input == 'r') //d=dump all register values*
* radio.readAllRegs();*
* if (input == 'E') //E=enable encryption*
* radio.encrypt(ENCRYPTKEY);*
* if (input == 'e') //e=disable encryption*
* radio.encrypt(null);*
* if (input == 'p')*
* {*
* promiscuousMode = !promiscuousMode;*
* radio.promiscuous(promiscuousMode);*
* Serial.print("Promiscuous mode ");Serial.println(promiscuousMode ? "on" : "off");*
* }*
* if (input == 'd') //d=dump flash area*
* {*
* Serial.println("Flash content:");*
* int counter = 0;*
* while(counter<=256){*
* Serial.print(flash.readByte(counter++), HEX);*
* Serial.print('.');*
* }*
* while(flash.busy());*
* Serial.println();*
* }*
* if (input == 'D')*
* {*
* Serial.print("Deleting Flash chip ... ");*
* flash.chipErase();*
* while(flash.busy());*
* Serial.println("DONE");*
* }*
* if (input == 'i')*
* {*
* Serial.print("DeviceID: ");*
* word jedecid = flash.readDeviceId();*
* Serial.println(jedecid, HEX);*
* }*
* if (input == 't')*
* {*
* byte temperature = radio.readTemperature(-1); // -1 = user cal factor, adjust for correct ambient*
_ byte fTemp = 1.8 * temperature + 32; // 9/5=1.8_
* Serial.print( "Radio Temp is ");*
* Serial.print(temperature);*
* Serial.print("C, ");*
* Serial.print(fTemp); //converting to F loses some resolution, obvious when C is on edge between 2 values (ie 26C=78F, 27C=80F)*
* Serial.println('F');*
* }*
* }*
* if (radio.receiveDone())*
* {*
// Serial.print("#[");
// Serial.print(++packetCount);
// Serial.print(']');
// Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
* if (promiscuousMode)*
* {*
* Serial.print("to [");Serial.print(radio.TARGETID, DEC);Serial.print("] ");*
* }*
* for (byte i = 0; i < radio.DATALEN; i++)*
_ Serial.print((char)radio.DATA*); // ############# HIER WERDEN DIE DATEN GEPRINTET???!!!!#############
// Serial.println(" 500");_
// Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");*
* if (radio.ACKRequested())*
* {*
* byte theNodeID = radio.SENDERID;*
* radio.sendACK();*
* //Serial.print(" - ACK sent.");*
* // When a node requests an ACK, respond to the ACK*
* // and also send a packet requesting an ACK (every 3rd one only)*
* // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY*
* if (ackCount++%3==0)*
* {*
* // Serial.print(" Pinging node ");*
* // Serial.print(theNodeID);*
* // Serial.print(" - ACK...");*
* delay(3); //need this when sending right after reception .. ?*
* if (radio.sendWithRetry(theNodeID, "ACK TEST", 8, 0)) // 0 = only 1 attempt, no retries*
* //Serial.print("ok!");*
* // else //Serial.print("nothing");*
* delay(0);}*
* }*
* Blink(LED,3);*
* }*
}