No luck with ethernet Gateway
-
Hello, i'trying to move from a working serial GW to ethernet GW but can not get it to work.
Please have a look at my code./** The MySensors Arduino library handles the wireless radio link and protocol between your home built sensors/actuators and HA controller of choice. The sensors forms a self healing radio network with optional repeaters. Each repeater and gateway builds a routing tables in EEPROM which keeps track of the network topology allowing messages to be routed to nodes. Created by Henrik Ekblad <henrik.ekblad@mysensors.org> Copyright (C) 2013-2015 Sensnology AB Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors Documentation: http://www.mysensors.org Support Forum: http://forum.mysensors.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. ******************************* REVISION HISTORY Version 1.0 - Henrik EKblad Contribution by a-lurker and Anticimex, Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> Contribution by Tomas Hozza <thozza@gmail.com> DESCRIPTION The EthernetGateway sends data received from sensors to the ethernet link. The gateway also accepts input on ethernet interface, which is then sent out to the radio network. The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program. LED purposes: - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly - ERR (red) - fast blink on error during transmission error or recieve crc error See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. */ /* added by sigolhi * Hardware used * UNO r3 * Ard Eth Shield with ws5100 * NRF with ext. antenna +10uf on 3.3V * 2 pcs DS18B20 * 1 light sensor */ // 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 // 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) #define MY_SOFTSPI #define MY_SOFT_SPI_SCK_PIN 14 #define MY_SOFT_SPI_MISO_PIN 16 #define MY_SOFT_SPI_MOSI_PIN 15 #endif // When W5100 is connected we have to move CE/CSN pins for NRF radio #ifndef MY_RF24_CE_PIN #define MY_RF24_CE_PIN 5 #endif #ifndef MY_RF24_CS_PIN #define MY_RF24_CS_PIN 6 #endif // 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,2,66 // If using static ip you can define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,2,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, 254 // 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 Ardunio 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 // Button pin with external pullup 4.7kohm to +5V //#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 red //#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin green //#define MY_DEFAULT_TX_LED_PIN 9 // Transmit led pin yellow #if defined(MY_USE_UDP) #include <EthernetUdp.h> #endif #include <Ethernet.h> #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #define CHILD_ID_TEMP_IN 1 // Temperatur child-ID #define CHILD_ID_TEMP_OUT 2 // Temperatur child-ID #define CHILD_ID_LIGHT 3 // Lightsensor child-ID #define ONE_WIRE_BUS 8 // Arduino Digital I/O pin where dallas sensor is connected with 4.7kohm pullup to +5V #define MAX_ATTACHED_DS18B20 2 // Number of tempsensors #define LIGHT_SENSOR_ANALOG_PIN A3 // Arduino Analogue I/O pin0 for lightsensor OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors = 0; MyMessage msgTempIN(CHILD_ID_TEMP_IN, V_TEMP); //CHILD_ID_TEMP_IN 1 Temperatur ID MyMessage msgTempOUT(CHILD_ID_TEMP_OUT, V_TEMP); //CHILD_ID_TEMP_OUT 2 Temperatur ID MyMessage msgLL(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //CHILD_ID_LIGHT 3 Lightsensor ID unsigned long previousMillis = 0; // will store last time data was sent unsigned long timetoWait = 300000; // time to wait 300000=5min, 30000=30sekunder float Tempsensor1; //store value to send float Tempsensor2; //store value to send int lightLevel; //store value to send void before() { sensors.begin(); // Startup OneWire } void setup() { Serial.println(__FILE__); // print filename to serialport at startup Serial.println(__DATE__); // print date to serialport at startup Serial.println(__TIME__); // print time to serialport at startup Serial.println(); sensors.setWaitForConversion(false); // request temperature() will not block current thread numSensors = sensors.getDeviceCount(); // Fetch the number of attached temperature sensors Serial.print("Number of temp sensors = "); Serial.println(numSensors); } void presentation() { sendSketchInfo("Gateway", "2.1.1"); present(CHILD_ID_TEMP_IN, S_TEMP, "InneTemp", 1); present(CHILD_ID_TEMP_OUT, S_TEMP, "UteTemp", 1); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "Ljusstyrka", 1); #ifdef MY_DEBUG Serial.println("DEBUG IS ACTIVE "); #endif } void loop() { unsigned long currentMillis = millis(); // Send locally attached sensor data here sensors.requestTemperatures(); // Fetch temperatures from Dallas sensors if (currentMillis - previousMillis >= timetoWait) { // create a delay between transmissions previousMillis = currentMillis; // save the last time you measured the values // Read temperatures and send them to controller for (int i = 0; i < numSensors && i < MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal //float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.; float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric ? sensors.getTempCByIndex(i) : sensors.getTempFByIndex(i)) * 10.)) / 10.; if (i == 0 && temperature != -127.00 ) { Tempsensor1 = temperature; } else { //Tempsensor2 = 12; } } lightLevel = map(analogRead(LIGHT_SENSOR_ANALOG_PIN), 0, 1023, 0, 100); //light in percent sendValue(); } } void sendValue() { #ifdef MY_DEBUG Serial.print("Temp_in = "); Serial.println(Tempsensor1); Serial.print("Temp_out = "); Serial.println(Tempsensor2); Serial.print("Lightlevel = "); Serial.println(lightLevel); #endif wait(200); send(msgTempIN.setSensor(1).set(Tempsensor1, 1)); wait(200); send(msgTempOUT.setSensor(2).set(Tempsensor2, 1)); wait(200); send(msgLL.setSensor(CHILD_ID_LIGHT).set(lightLevel, 1)); }
this is the console output which repeat itself
also the debug does not seem to work0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,18-4-0,s=16,c=1,t=0,pt=7,l=5,sg=0:9.0
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;MCO:BGN:BFR
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 192.168.2.66
0;255;3;0;9;MCO:BGN:STP
D:\Olle\Documents\Arduino\Eth_tGw\Eth_tGw.ino
Oct 4 2017
21:16:11Number of temp sensors = 2
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,3-16-0,s=2,c=1,t=2,pt=2,l=2,sg=0:0
0;255;3;0;9;!TSF:MSG:LEN,11!=9
0;255;3;0;9;TSF:MSG:READ,16-16-0,s=11,c=1,t=0,pt=7,l=5,sg=0:25.0
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;MCO:BGN:BFR
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 192.168.2.66
0;255;3;0;9;MCO:BGN:STP
D:\Olle\Documents\Arduino\Eth_tGw\Eth_tGw.ino
Oct 4 2017
21:16:11best regards sigolhi
-
Try latest mysensors development library, then if problem persists try a different UNO or downgrade boards definitions to 1.6.11 or 1.6.13 and see if it still has problems. Did you try to remove code for each of the sensors at a time in order to figure out if it's a specific sensor?
-
No luck!
The node keeps resetting all the time
But it can be seen in Domotics so it is connected to the netse below
2017-10-07 20:46:03.960 (MySensor) Temp (Gateway Kontoret UteTemp)
2017-10-07 20:46:04.179 (MySensor) Lux ( Gateway Kontoret Ljusstyrka)
2017-10-07 20:46:07.694 (MySensor) Temp (Relä_17 Temp i Garaget)
2017-10-07 20:46:07.804 (RFLink) Temp + Humidity (Väderstation Växthuset)
2017-10-07 20:46:14.585 (RFLink) Wind (Väderstation Vind)
2017-10-07 20:46:15.695 MySensors: trying to connect to: 192.168.2.66:5003
2017-10-07 20:46:16.695 MySensors: connected to: 192.168.2.66:5003
2017-10-07 20:46:25.695 MySensors: Connection reset!
2017-10-07 20:46:25.695 TCP: Reconnecting in 30 seconds...
2017-10-07 20:46:30.039 (MySensor) Humidity (Källare Hum in IROXbox)
2017-10-07 20:46:47.758 (RFLink) Wind (Väderstation Vind)
2017-10-07 20:46:52.821 (RFLink) Temp + Humidity (Väderstation Växthuset)
2017-10-07 20:46:55.696 TCP: Reconnecting...
2017-10-07 20:46:56.696 MySensors: connected to: 192.168.2.66:5003
2017-10-07 20:47:05.696 MySensors: Connection reset!
2017-10-07 20:47:05.696 TCP: Reconnecting in 30 seconds...
2017-10-07 20:47:07.962 (MySensor) Temp (Relä_17 Temp i Garaget)
2017-10-07 20:47:20.587 (RFLink) Wind (Väderstation Vind)
-
What did you try?
-
@gohan said in No luck with ethernet Gateway:
Try latest mysensors development library, then if problem persists try a different UNO or downgrade boards definitions to 1.6.11 or 1.6.13 and see if it still has problems. Did you try to remove code for each of the sensors at a time in order to figure out if it's a specific sensor?
take heed to this advice... did you modify the boards definition in your Arduino IDE?
-
@sigolhi do you have enough power? It seems USB does not be sufficient for me
-
There's an issue with Atmega2560 and Wiznet 5100, are you using an Arduino Mega?
https://forum.mysensors.org/topic/4680/mysensors-2-0-ethernet-gateway-atmega-w5100-restart-all-time
-
Hi frits and others,
In your link i finally found out how to downgrade to 1.6.11 and behold!
Now it works.
Thanks to all of you for being patient with me.
Regards Sigolhi