[Logo] Anarduino and HopeRF Community Forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics     [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Arduino ethernet with RFM69W 915Mhz  XML
Forum Index » Anarduino
Author Message

Joined: 05/05/2015 15:15:44
Messages: 2

Hi all,

I'm working on a project I found in Instructables (http://www.instructables.com/id/Uber-Home-Automation-w-Arduino-Pi/step2/Parts-List-and-Initial-Prep/). Great project and everything was working fine using an Arduino, a generic Ethernet shield with an RFM69HW 915Mhz module piggybacked on it as the gateway. The various sensors are using RFM69W 915Mhz modules to communicate with the gateway.

After upgrading my router from a DLink to a Motorola SBG6580 the gatway will no longer get the DHCP address from the router as long as the RFM69W module is attached. If I remove it, the gateway will connect to the router just fine and returns the IP address.

Any thoughts as to why it worked ok with the DLink router but not the Motorola. Because it worked previously I'm doubtful that there is a conflict with the h/w. Below is the relevant code. It gets stuck at the while loop in the setup().

Any input would be appreciated.

Based on work from author: Eric Tsai
Gateway ncorporating both the RFM69 and the ethernet part
Revised by Alexandre Bouillot

License: CC-BY-SA, https://creativecommons.org/licenses/by-sa/2.0/
Date: 10-23-2014
File: Gateway.ino
This sketch receives RFM wireless data and forwards it to Mosquitto relay

Modifications Needed:
1) Update encryption string "ENCRYPTKEY"
2) Adjust SS - Chip Select - for RFM69
3) Adjust MQTT server address

RFM69 Pinout:
MOSI = 11
MISO = 12
SCK = 13
SS = 8

Ethernet Pinout:
MOSI = 11
MISO = 12
SCK = 13
SS = 10

//general --------------------------------
#define SERIAL_BAUD 115200
#if 0
#define DEBUG1(expression) Serial.print(expression)
#define DEBUG2(expression, arg) Serial.print(expression, arg)
#define DEBUGLN1(expression) Serial.println(expression)
#define DEBUG1(expression)
#define DEBUG2(expression, arg)
#define DEBUGLN1(expression)
//RFM69 ----------------------------------
#include <RFM69.h>
#include <SPI.h>
#define NODEID 1 //unique for each node on same network
#define NETWORKID 100 //the same on all nodes that talk to each other
//#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!
#define ACK_TIME 30 // max # of ms to wait for an ack
#define RFM69_SS 8
RFM69 radio(RFM69_SS);
bool promiscuousMode = true; //set to 'true' to sniff all packets on the same network

#include <Ethernet.h>
bool conn_ok;
bool mydebug = false;

byte mac[] = {
0x90, 0xA2, 0xDA, 0x0D, 0x11, 0x11
byte server[] = {192, 168, 0, 134 }; //Linux server address

IPAddress ip(192, 168, 0, 4); //address of gateway device
EthernetClient ethClient;
#define DHCP_RETRY 500

// Mosquitto---------------
#include <PubSubClient.h>
PubSubClient client(server, 1883, callback, ethClient);
#define MQTT_CLIENT_ID "arduinoClient"
#define MQTT_RETRY 500
int sendMQTT = 0;
unsigned long MQTT_reconnect = 0;

void MQTTSendInt(PubSubClient* _client, int node, int sensor, int var, int val);
void MQTTSendULong(PubSubClient* _client, int node, int sensor, int var, unsigned long val);
void MQTTSendFloat(PubSubClient* _client, int node, int sensor, int var, float val);

//use LED for indicating MQTT connection status.
int led = 13;

typedef struct {
int nodeID;
int sensorID;
unsigned long var1_usl;
float var2_float;
float var3_float;
Payload theData;

volatile struct
int nodeID;
int sensorID;
unsigned long var1_usl;
float var2_float;
float var3_float; //
int var4_int;

void setup()
Serial.println("Rebooting Ethernet_RFM_Gateways_Combinedv1.0");

//Ethernet -------------------------
//Ethernet.begin(mac, ip);

// //wait for IP address
while (Ethernet.begin(mac) != 1) { //<<<--- gets stuck here--->>>
Serial.println("Error getting IP address via DHCP, trying again...");

Serial.println("ethernet OK");
// print your local IP address:
Serial.println("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);

// Mosquitto ------------------------------
while (client.connect(MQTT_CLIENT_ID) != 1) {
DEBUGLN1("Error connecting to MQTT");
Serial.println("Connected to MQTT: ");

//RFM69 ---------------------------
#ifdef IS_RFM69HW
radio.setHighPower(); //uncomment only for RFM69HW!
Serial.println("setHighPower ok ");
char buff[50];
sprintf(buff, "\nListening at %d Mhz...", FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);

Serial.println("setup complete");
} // end of setup

byte ackCount = 0;
long watchdogInterval = 2000;
long watchdog = 0;

void loop() {

Forum Index » Anarduino
Go to:   
Powered by JForum 2.1.9 © JForum Team