Hi
I just finished my OLEDMote, installed the default sketch from lowpowerlab github. It's getting messages from my motion sensor and my mailbox. But just for a brief second or 2. Then it shows ID:1 and RSSI-78. The OLEDMote will beep every 7-8 seconds. Why is it getting all this messages from node 1?
Daniel J
What is the content? Just blank?
Do you have a node 1 that sends data?
Its blank. Only info is node id and rssi. And i dont have any node 1 🤔
What are the IDs of your motion and mailbox?
Is the "default sketch" this one (https://github.com/LowPowerLab/RFM69/blob/master/Examples/OLEDMote/OLEDMote.ino)?
Do you use any encryption?
Quote from: Felix on March 13, 2017, 10:53:13 AM
What are the IDs of your motion and mailbox?
Is the "default sketch" this one (https://github.com/LowPowerLab/RFM69/blob/master/Examples/OLEDMote/OLEDMote.ino)?
Do you use any encryption?
My motion id is 83, doorbell is 133, and watt meter is 5. And i use encryption. i removed the mailbox moteino for now. This is what serial monitor display: [1] to [5] [RX_RSSI:-76]
This is the code:
// Sample RFM69 sketch for the MotionOLED mote containing the OLED
// Displays any messages on the network on the OLED display and beeps the buzzer every time a message is received
// The side button will step through 10 past received messages
// Library and code by Felix Rusu - [email protected]
// Get libraries at: https://github.com/LowPowerLab/
// Make sure you adjust the settings in the configuration section below !!!
// **********************************************************************************
// 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: https://www.github.com/lowpowerlab/rfm69
#include <SPIFlash.h> //get library from: https://www.github.com/lowpowerlab/spiflash
#include <LowPower.h> //get library from: https://github.com/lowpowerlab/lowpower
#include "U8glib.h" //get library from: https://code.google.com/p/u8glib/
#include <SPI.h> //included with Arduino IDE (www.arduino.cc)
//****************************************************************************************************************
//**** IMPORTANT RADIO SETTINGS - YOU MUST CHANGE/CONFIGURE TO MATCH YOUR HARDWARE TRANSCEIVER CONFIGURATION! ****
//****************************************************************************************************************
#define NODEID 122 //unique for each node on same network
#define NETWORKID 200 //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 //uncomment only for RFM69HW! Remove/comment if you have RFM69W!
//*********************************************************************************************
#define SERIAL_BAUD 19200
#define LED 5 // Moteinos have LEDs on D9, but for MotionMote we are using the external led on D5
#define BUZZER 8
#define BUTTON_INT 1 //user button on interrupt 1
#define BUTTON_PIN 3 //user button on interrupt 1
RFM69 radio;
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // I2C / TWI SSD1306 OLED 128x64
bool promiscuousMode = true; //set to 'true' to sniff all packets on the same network
void setup() {
Serial.begin(SERIAL_BAUD);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
radio.setHighPower(); //only for RFM69HW!
#endif
radio.encrypt(ENCRYPTKEY);
radio.promiscuous(promiscuousMode);
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
Serial.println(buff);
pinMode(BUZZER, OUTPUT);
//configure OLED
u8g.setRot180(); //flip screen
// assign default color value
if ( u8g.getMode() == U8G_MODE_R3G3B2 )
u8g.setColorIndex(255); // white
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
u8g.setColorIndex(3); // max intensity
else if ( u8g.getMode() == U8G_MODE_BW )
u8g.setColorIndex(1); // pixel on
else if ( u8g.getMode() == U8G_MODE_HICOLOR )
u8g.setHiColorByRGB(255,255,255);
u8g.begin();
Serial.flush();
pinMode(BUTTON_PIN, INPUT_PULLUP);
attachInterrupt(BUTTON_INT, handleButton, FALLING);
}
#define FLAG_INTERRUPT 0x01
volatile int mainEventFlags = 0;
boolean buttonPressed = false;
void handleButton()
{
mainEventFlags |= FLAG_INTERRUPT;
}
byte ackCount=0;
#define MSG_MAX_LEN 17 //OLED 1 line max # of chars (16 + EOL)
#define HISTORY_LEN 10 //hold this many past messages
typedef struct {
char data[MSG_MAX_LEN];
int rssi;
byte from;
} Message;
Message * messageHistory = new Message[HISTORY_LEN];
byte lastMessageIndex = HISTORY_LEN;
byte currMessageIndex = HISTORY_LEN;
byte historyLength = 0;
void loop() {
if (mainEventFlags & FLAG_INTERRUPT)
{
LowPower.powerDown(SLEEP_30MS, ADC_OFF, BOD_ON);
mainEventFlags &= ~FLAG_INTERRUPT;
if (!digitalRead(BUTTON_PIN)) {
buttonPressed=true;
}
}
if (buttonPressed)
{
buttonPressed = false;
Beep(10, false);
//save non-ACK messages in a circular buffer
if (!radio.ACK_RECEIVED && historyLength > 1) //only care if at least 2 messages saved. if only 1 message it should be displayed already
{
if (currMessageIndex==0)
currMessageIndex=historyLength-1;
else currMessageIndex--;
//Serial.print("HIST currIndex/histLen=");Serial.print(currMessageIndex+1);Serial.print("/");Serial.print(historyLength);
//Serial.print(" - ");
//Serial.println(messageHistory[currMessageIndex].data);
u8g.firstPage();
do {
draw(messageHistory[currMessageIndex].data, messageHistory[currMessageIndex].rssi, messageHistory[currMessageIndex].from, true);
} while(u8g.nextPage());
//delay(10); //give OLED time to draw?
}
}
if (radio.receiveDone())
{
Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
if (promiscuousMode)
Serial.print("to [");Serial.print(radio.TARGETID);Serial.print("] ");
Serial.print((char*)radio.DATA);
Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
Serial.println();
saveToHistory((char *)radio.DATA, radio.RSSI, radio.SENDERID);
Blink(LED,3);
Beep(20, true);
u8g.firstPage();
do {
draw((char*)radio.DATA, radio.RSSI, radio.SENDERID, false);
} while(u8g.nextPage());
//delay(10); //give OLED time to draw?
}
radio.receiveDone();
Serial.flush();
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_ON);
}
float batteryVolts = 5;
char* BATstr="BAT:5.00v";
void draw(char * data, int rssi, byte from, boolean isHist) {
char buff[20];
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_unifont);
u8g.drawStr( 0, 10, data);
sprintf(buff, "ID:%d", from);
u8g.drawStr( 0, 25, buff);
sprintf(buff, "RSSI:%d", rssi);
u8g.drawStr( 60, 25, buff);
if (!isHist)
{
batteryVolts = analogRead(A7) * 0.00322 * 1.42;
dtostrf(batteryVolts, 3,2, BATstr);
sprintf(buff, "BAT:%sv", BATstr);
u8g.drawStr( 0, 55, buff);
}
}
void Beep(byte theDelay, boolean both)
{
if (theDelay > 20) theDelay = 20;
tone(BUZZER, 4200); //4200
delay(theDelay);
noTone(BUZZER);
LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_ON);
if (both)
{
tone(BUZZER, 4500); //4500
delay(theDelay);
noTone(BUZZER);
}
}
void Blink(byte PIN, int DELAY_MS)
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
void saveToHistory(char * msg, int rssi, byte from)
{
byte length = strlen(msg);
byte i = 0;
if (lastMessageIndex >=9) lastMessageIndex = 0;
else lastMessageIndex++;
currMessageIndex = lastMessageIndex;
if (historyLength < HISTORY_LEN) historyLength++;
//Serial.print("HIST SAVE lastIndex=");Serial.print(lastMessageIndex);Serial.print(" strlen=");Serial.print(length);
//Serial.print(" msg=[");
for (; i<(MSG_MAX_LEN-1) && (i < length); i++)
{
messageHistory[lastMessageIndex].data[i] = msg[i];
Serial.print(msg[i]);
}
//Serial.print("] copied:");
messageHistory[lastMessageIndex].data[i] = '\0'; //terminate string
//Serial.println((char*)messageHistory[lastMessageIndex].data);
messageHistory[lastMessageIndex].rssi = rssi;
messageHistory[lastMessageIndex].from = from;
}
Those are probably ACKs although it should not capture ACKs ???
Are you sending empty non-ACK messages from node 1?
What sketch is that running?
Quote from: Felix on March 13, 2017, 02:58:42 PM
Those are probably ACKs although it should not capture ACKs ???
Are you sending empty non-ACK messages from node 1?
What sketch is that running?
Im using the default gateway sketch for node 1.
I hooked up the moteino gateway to the serial monitor, and this is what i see.
Listening at 433 Mhz...
SPI Flash MEM not found (is chip soldered?)...
RFM69_ATC Enabled (Auto Transmission Control)
#[1][5] GAL:13878.12 GPM:0.92 [RX_RSSI:-70] - ACK sent. Pinging node 5 - ACK...nothing
#[2][5] GAL:13878.10.01 GPM:01 GLM:0.01 [RX_RSSI:-70] - ACK sent.
#[3][5] GAL:13878.13 GPM:0.89 [RX_RSSI:-70] - ACK sent.
#[4][5] GAL:13878.13 GPM:0.89 [RX_RSSI:-71] - ACK sent. Pinging node 5 - ACK...nothing
#[5][5] GAL:13878.13 GPM:0.89 [RX_RSSI:-69] - ACK sent.
#[6][5] GAL:13878.10.01 GPM:01 GLM:0.01 [RX_RSSI:-71] - ACK sent.
#[7][5] GAL:13878.14 GPM:0.89 [RX_RSSI:-71] - ACK sent. Pinging node 5 - ACK...nothing
// 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: https://www.github.com/lowpowerlab/rfm69
#include <RFM69_ATC.h> //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash
#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 200 //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 //uncomment only for RFM69HW! Leave out if you have RFM69W!
//*********************************************************************************************
//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 19200
#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
radio.setHighPower(); //only for RFM69HW!
#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[i], 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[i], 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 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[i]);
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");
}
}
Serial.println();
Blink(LED,3);
}
}
void Blink(byte PIN, int DELAY_MS)
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
Any idea whats wrong?
Sorry I haven't had a chance to look at it yet, I have to put together a mote for this purpose, I will keep it on my top TODO.
FWIW I always test and use the the sketches I publish so they work at least at one point. Changes in arduino libraries and releases may impact this, I like an old 1.0.6 IDE version which is very stable and has some features that I prefer over the new versions, hence I may miss when such bugs are introduced with new IDE releases.
I put together a new OLED mote just for this. Loaded the default sketch just like yours, and the gateway is node=1.
I have lots of nodes around sending all kinds of data. There is no phantom messages from node 1 or anything like that. Browsing through the history just loops the LCD through the received messages, nothing strange. I will let it sit for a while but I dont think there's anything wrong.
I suggest checking everything on your side again. Make sure you got the latest of RFM69, last resort try IDE 1.0.6 which I have linked as a ZIP here (https://lowpowerlab.com/guide/moteino-programming/).