Hi,
I have trouble with my ethernet shield.
I tried different methods and there where different publications on how to connect, but in the end I was not able to get it running.
I tried: CE and CS pin on 6 and 5 with and without changing MISO/MOSI/SCK to A0 to A2, but the best result I got was an error free start of the gateway but not receiving any data from nodes so far (connection to ip network seems to be fine, at least the ip is declared via dhcp). The same setting was doing great without ethernet shield. Tried it also on a Mega but without success...
To sort out the power issue I put an extra 3.3 power regulator together with a big 470 microF capacitor which should do the trick.
Any ideas? I will post the exact wirings in a few minutes.
If you have one working in this setting, can you send me the exact sketch together with the wiring information?
Thank you!
Here are the details:
Gateway Debug Print:
0 MCO:BGN:INIT GW,CP=RNNGAS--,VER=2.3.0
48 TSM:INIT
49 TSF:WUR:MS=0
56 TSM:INIT:TSP OK
58 TSM:INIT:GW MODE
60 TSM:READY:ID=0,PAR=0,DIS=0
62 MCO:REG:NOT NEEDED
8695 GWT:TIN:IP=192.168.178.45
9698 MCO:BGN:STP
9700 MCO:BGN:INIT OK,TSP=1
Gateway code:
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
// Enable gateway ethernet module type
#define MY_GATEWAY_W5100
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4
// Enable Soft SPI for NRF radio (note different radio wiring is required)
// The W5100 ethernet module seems to have a hard time co-operate with
// radio on the same spi bus.
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
#endif
#define MY_SOFTSPI
#define MY_SOFT_SPI_SCK_PIN 14
#define MY_SOFT_SPI_MISO_PIN 16
#define MY_SOFT_SPI_MOSI_PIN 15
#define MY_RF24_CE_PIN 5
#define MY_RF24_CS_PIN 6
// When W5100 is connected we have to move CE/CSN pins for NRF radio
// Enable UDP communication
#define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
//#define MY_IP_ADDRESS 192,168,178,66
// If using static ip you can define Gateway and Subnet address as well
//#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
//#define MY_IP_SUBNET_ADDRESS 255,255,255,0
// Renewal period if using DHCP
//#define MY_IP_RENEWAL_INTERVAL 60000
// The port to keep open on node server mode / or port to contact in client mode
#define MY_PORT 5003
// Controller ip address. Enables client mode (default is "server" mode).
// Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, XYZ
// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Arduino examples use "DEAD BEEF FEED" for the MAC address.
#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
//#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
//#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 9 // Transmit led pin
#if defined(MY_USE_UDP)
#include <EthernetUdp.h>
#endif
#include <Ethernet.h>
// Singing issues:
#define MY_SIGNING_SOFT
#define MY_SIGNING_SOFT_RANDOMSEED_PIN A5
#define MY_SIGNING_REQUEST_SIGNATURES
#include <MySensors.h>
void setup()
{
// Setup locally attached sensors
}
void presentation()
{
// Present locally attached sensors here
}
void loop()
{
// Send locally attached sensors data here
}
Gateway Wiring:
GatewayArduinoUno - nRF24L01
A2 - MISO
A1 - MOSI
A0 - SCK
6 - CSN/NSS
5 - CE
Node:
Node Debug Print:
__ __ ____
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| | | | |_| |___| | __/ | | \__ \ _ | | \__ \
|_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
|___/ 2.3.0
16 MCO:BGN:INIT NODE,CP=RNNNAS--,VER=2.3.0
73 TSM:INIT
74 TSF:WUR:MS=0
81 TSM:INIT:TSP OK
83 TSM:INIT:STATID=10
86 TSF:SID:OK,ID=10
87 TSM:FPAR
123 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2131 !TSM:FPAR:NO REPLY
2134 TSM:FPAR
2169 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
4178 !TSM:FPAR:NO REPLY
4180 TSM:FPAR
4216 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
6225 !TSM:FPAR:NO REPLY
6227 TSM:FPAR
6263 TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
8271 !TSM:FPAR:FAIL
8272 TSM:FAIL:CNT=1
8274 TSM:FAIL:DIS
8276 TSF:TDI:TSL
Node Code:
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
// Singing issues:
#define MY_SIGNING_SOFT
#define MY_SIGNING_SOFT_RANDOMSEED_PIN A2
//#define MY_SIGNING_REQUEST_SIGNATURES
#include <MySensors.h>
#define SKETCH_NAME "Binary Sensor"
#define SKETCH_MAJOR_VER "1"
#define SKETCH_MINOR_VER "0"
#define PRIMARY_CHILD_ID 3
#define SECONDARY_CHILD_ID 4
#define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch
#define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
#if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3)
#error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
#endif
#if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3)
#error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
#endif
#if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN)
#error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same
#endif
#if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
#error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
#endif
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
void setup()
{
// Setup the buttons
pinMode(PRIMARY_BUTTON_PIN, INPUT_PULLUP);
pinMode(SECONDARY_BUTTON_PIN, INPUT_PULLUP);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
// Register binary input sensor to sensor_node (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
present(PRIMARY_CHILD_ID, S_DOOR);
present(SECONDARY_CHILD_ID, S_DOOR);
}
// Loop will iterate on changes on the BUTTON_PINs
void loop()
{
uint8_t value1, value2;
static uint8_t sentValue=2;
static uint8_t sentValue2=2;
// Short delay to allow buttons to properly settle
sleep(5);
value1 = digitalRead(PRIMARY_BUTTON_PIN);
if (value1 != sentValue) {
// Value has changed from last transmission, send the updated value
send(msg.set(value1==HIGH));
sentValue = value1;
Serial.print("Sensor1: "); Serial.println(value1);
}
value2 = digitalRead(SECONDARY_BUTTON_PIN);
if (value2 != sentValue2) {
// Value has changed from last transmission, send the updated value
send(msg2.set(value2==HIGH));
sentValue2 = value2;
Serial.print("Sensor2: "); Serial.println(value2);
}
// Sleep until something happens with the sensor
sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-3, CHANGE, 0);
}
Node Wiring:
Arduino Nano Breakout Board with Connector (was working fine before).