The Vera Community forums have moved!

Advanced => Plugins & Plugin Development => Programming => Arduino Sensor Plugin => Topic started by: hek on February 07, 2014, 05:02:24 pm

Title: EthernetGateway
Post by: hek on February 07, 2014, 05:02:24 pm
A new gateway option has been added. You can now use Ethernet instead of serial link. This means free placement of your gateway anywhere in your house (near ethernet connector) and that you can use any Arduino board (not just Nano) for your gateway (by adding Ethernet module).

You should be able to use both the WizNet or the ENC28J60 module (I have only verified with ENC28J60)

You will need to update the Vera plugin with a new "L_Arduino.lua"-file
https://github.com/mysensors/Vera/blob/master/L_Arduino.lua

Install the latest MySensors-library:
https://github.com/mysensors/Arduino/tree/master/libraries/MySensors

If your using ENC28J60-module install the provided UIPEthernet-library into Arduino-IDE.
https://github.com/mysensors/Arduino/tree/master/libraries/UIPEthernet

The gateway sketch can be found here:
https://github.com/mysensors/Arduino/tree/master/EthernetGateway

Vera Configuration:
Enter "ip-number:port" in the ip-field of the Arduino GW device(advanced tab). This will override any serial configuration for the Vera plugin.  E.g. If you want to use the default values in this sketch enter: 192.168.178.66:5003

Ebay:
ENC28J60 - http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=2&pub=5575069610&toolid=10001&campid=5337433187&customid=&icep_item=390686500452&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg

WizNET - http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=2&pub=5575069610&toolid=10001&campid=5337433187&customid=&icep_item=280924809892&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg

@A-lurker, thanks for providing your example-code!


Below is the header of EthernetGateway.ino (contains connect/compile-instructions)
Code: [Select]
/*
 * Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com>
 *
 * Contribution by a-lurker
 *
 * 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.
 *
 * 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.
 *
 * COMPILING
 * You must make sure to disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch won't fit in program space when downloading.
 * For UIPEthernet(ENC28J60) usage: Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which meas you ave to choose a static IP)
 * For WizNET usage: Do *not* install the provided UIPEthernet-library. Remove UIPEthernet-include below and uncomment the Ethernet.h. 
 *
 * VERA CONFIGURATION:
 * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
 * E.g. If you want to use the default values in this sketch enter: 192.168.178.66:5003
 *
 * LED purposes:
 * - 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 
 *
 *  ----------- Connection guide ---------------------------------------------------------------------------
 *  13  Radio & Ethernet SPI SCK         
 *  12  Radio & Ethernet SPI MISO (SO)
 *  11  Radio & Ethernet SPI MOSI (SI)
 *  10  Ethernet SPI Slave Select (CS)    Pin 10, the SS pin, must be an o/p to put SPI in master mode
 *  9   Radio TX LED using on board LED   (optional)  +5V -> LED -> 270-330 Ohm resistor -> pin 9.
 *  8   Radio RX LED                      (optional)  +5V -> LED -> 270-330 Ohm resistor -> pin 8.
 *  7   Radio error LED                   (optional)  +5V -> LED -> 270-330 Ohm resistor -> pin 7.
 *  6   Radio SPI Slave Select
 *  5   Radio Chip Enable
 *  3   Inclusion mode button             (optional), 10K pull down to GND, button to VCC)
 *  2   Radio IRQ pin                     (optional), W5100 Int, if linked to pin 2)
 * -----------------------------------------------------------------------------------------------------------
 * Powering: both NRF24l01 radio and Ethernet(ENC28J60) uses 3.3V
 */

 
Title: Re: EthernetGateway
Post by: korttoma on February 08, 2014, 01:49:00 am
Great work hek!
Title: Re: EthernetGateway
Post by: aPL on February 08, 2014, 06:30:45 pm
What would you say the advanges are of running ethernet versus serial? would serial be much faster? Could multiple vera talk to the ethernet gateway at one time? Or a vera talk to multiple ethernet gateways at one time?
Title: Re: EthernetGateway
Post by: MDoc on February 08, 2014, 06:58:24 pm
What would you say the advanges are of running ethernet versus serial? would serial be much faster? Could multiple vera talk to the ethernet gateway at one time? Or a vera talk to multiple ethernet gateways at one time?

There's no speed improvement.  In my case,  there are several advantages though  It allows me to locate the Gateway any place there's an Ethernet connection... I no longer have to tie the Gateway to the Vera.   I've also had occasional problems with the USB port loosing connection to the Gateway if Vera looses power  (I'm hoping the Ethernet connection will help this).
Title: Re: EthernetGateway
Post by: aPL on February 08, 2014, 07:04:40 pm
I have a few mr3020 lying around and was thinking of using their wifi to build a wireless mesh (2 mb/s speed are achievable with a mesh network), and the expose serial gateway over an ip port.

SoC: Atheros AR9330 rev 1
802.11 b/g/n 150 Mbps
Powered via USB B-Mini (5 Volts)
Tiny form factor
5.7 cm x 5.7 cm PCB
6.7 cm x 7.4 cm x 2.2 cm case

This would allow the nodes to be wifi-capable and only one node would have to be tied into the lan. It would make the WAF (wife acceptance factor) increase tenfold at least :). And i would rather spend 15-20$ for a mr3020 instead of 10-15$ for an ethernet module.

On the other hand, using an ethernet connection to the mr3020 and using the mr3020 as a bridge only would remove the need to write a serial-to-usb interface on the little router.

Darn, i've just finished making a pcb  to plug the nano and everthing else and bought a case... back to the drawing board again...
Title: Re: EthernetGateway
Post by: aPL on February 08, 2014, 07:11:29 pm
And i'm guessing using an ethernet gateway would allow me to use an arduino mega, uno or anything else as long as it's fast enough and has enough memory ? This would allow me to keep my nano and mini pro's for actual sensors...
Title: Re: EthernetGateway
Post by: MDoc on February 08, 2014, 07:15:02 pm
@hek & @a-lurker... Nice Job!

I've got everything switched over to Ethernet and all is working well.

I'm using the ENC28J60

For those who are switching over... There are two radio signals  (CE & CSN) as well as the LED's (if you use em') that are now different from the default USB sketch when adding the ENC28J60. 

If you used the default pins published in the USB Gateway Sketch, the changes are summarized below:

               Moves From                  To
CE           Pin 9                              Pin 5
CSN         Pin 10                            Pin 6
Rx LED     Pin 6                              Pin 8
Tx LED     Pin 5                              Pin 9
Err LED    Pin 4                              Pin 7
Title: Re: EthernetGateway
Post by: aPL on February 08, 2014, 07:30:45 pm
Using a wiznet 5100 arduino module and an arduino uno (assuming they are compatible with the arduino nano sketch), are these the correct pins? I'm trying to make sure i don't fry anything..

gnd /1 - gnd
vcc /2 - 3.3v
ce  /3 - digital 5
csn /4 - digital 6
sck /5 - digital 13
mosi/6 - digital 11
miso/7 - digital 12
irq /8 - digital 2

Thank you for your time!
Title: Re: EthernetGateway
Post by: MDoc on February 08, 2014, 11:09:54 pm
Using a wiznet 5100 arduino module and an arduino uno (assuming they are compatible with the arduino nano sketch), are these the correct pins?

You've got some radio signals and some Wiznet signals listed.  You'd connect as follows:

Radio       UNO
Gnd         Gnd
Vcc          3.3v
CE           Pin 5
CSN         Pin 6
SCK.        Pin 13
MOSI.      Pin 11
MISO.      Pin 12
IRQ.        Pin 2

Wiznet.    UNO
Gnd.         Gnd
3v3d         3.3v
MOSI        Pin 11
MISO        Pin 12
SCLK.       Pin 13
SCSn.       Pin 10


Title: Re: EthernetGateway
Post by: MDoc on February 09, 2014, 05:04:59 pm
I lost connection with the gateway today.  When I pinged the Gateway there was no response until I cycled the power.  I've been having problems with my cable modem resetting so I suspected the Gateway got lost when the network went down.  I recreated the problem by disconnecting the Ethernet cable from the Gateway for 30 seconds and trying to ping... no response until I cycle the power. 
Title: Re: EthernetGateway
Post by: hek on February 09, 2014, 05:09:25 pm
Ok, that is bad behavior.

Anyone up for debugging Ethernet?
Title: Re: EthernetGateway
Post by: a-lurker on February 09, 2014, 05:46:04 pm
This is the down side of using the luup io module to communicate with a device. If the power fails on the remote device, then the link cannot be re-established once power is restored, unless Vera is restarted. This is a major Vera problem. More here:

http://forum.micasaverde.com/index.php/topic,18469.msg155683.html#msg155683

Due to this limitation, users may be better off having the Arduino Gateway act as a web server? You would command with GETs or POSTs and receive data in say json. However it requires polling be used. I have taken this approach here:

http://forum.micasaverde.com/index.php/topic,23079.msg156151.html#msg156151

The ow server plugin also acts in this manner and works perfectly.

@MDoc I was a bit surprised to read that just unplugging the cable and plugging it back in caused a failure. Have you the latest firmware and which Ethernet interface are you using? Also worth a look at:

http://bugs.micasaverde.com/view.php?id=2282

In summary however, their is no doubt that if the power is lost to your gateway, you need to restart the Vera Luup engine once power is restored. Otherwise you're hosed.

Title: Re: EthernetGateway
Post by: MDoc on February 09, 2014, 06:05:02 pm
Thanks @a-lurker,

I'm using the ENC28J60 and running the code hek put up yesterday.
I'll do some more testing to see if I can track down what's happening and post back.

Thanks,
Mike
Title: Re: EthernetGateway
Post by: mikewop on February 11, 2014, 08:54:47 am
I recreated the problem by disconnecting the Ethernet cable from the Gateway for 30 seconds and trying to ping... no response until I cycle the power.

@MDoc,

did you mean cycle the power of the Gateway (Arduino + Ethernet module) or power cycle the Vera itself?
Sorry that wasn't clear to me since a-lurker seemed to talk about having to restart the Vera.

Title: Re: EthernetGateway
Post by: a-lurker on February 11, 2014, 02:50:53 pm
No need to power off anything. Just hit the reset button on the gateway and then restart the Luup engine.
Title: Re: EthernetGateway
Post by: MDoc on February 11, 2014, 04:52:47 pm
Yeah... I'm having problems with my cable modem and loosing the internet several time a day.  Since I've switched over to Ethernet, I've not gotten though a  day without loosing contact with the Gateway.  As @a-lurker said,  I just need to cycle power to the Gateway (because it's in an enclosed box) or hit the reset button to re-sync with the Vera.

Title: Re: EthernetGateway
Post by: hek on February 11, 2014, 05:17:18 pm
Yeah... I'm having problems with my cable modem and loosing the internet several time a day.  Since I've switched over to Ethernet, I've not gotten though a  day without loosing contact with the Gateway.  As @a-lurker said,  I just need to cycle power to the Gateway (because it's in an enclosed box) or hit the reset button to re-sync with the Vera.

Weird that your local network is affected by fluctuating internet access.

Is it possible to detect loss of connectivity from the gateway itself somehow?

In that case we could probably just update booloader to one that support WDT (Watch Dog Timer).
I.e. http://code.google.com/p/optiboot/
With WDT we could to make the arduino automatically reset when it loses contact.
Title: Re: EthernetGateway
Post by: a-lurker on February 11, 2014, 05:29:39 pm
@MDoc  After restarting the gateway, do you also have to do a Luup restart or is the the gateway restart alone sufficient to get the comms going again?
Title: Re: EthernetGateway
Post by: MDoc on February 11, 2014, 08:27:02 pm
Nope... If I ping the gateway there's no response (obviously, also if I scan the network there the gateway IP is not present). Once I reset the Gateway (without restarting Luup) I'm reconnected and start getting sensor updates. 

@hek, I agree about the cable modem... Don't see why the modem should affect network devices.... But at this point it's the only thing I can hang my hat on. I replaced my modem tonight so I should know by tomorrow if it makes a difference.  I'll let you know. 
Title: Re: EthernetGateway
Post by: MDoc on February 12, 2014, 10:25:47 am
I lost connection with the gateway today.  When I pinged the Gateway there was no response until I cycled the power.

I believe the problem is that I'm using a 3.3V 328P Nano as my Gateway.  I've got the ENC28J60 connected to the 3.3V output.  The FDTI output (FT233RL) can only supply 50ma while the ENC28J60 pulls 160ma when transmitting and 125ma at idle.  I'll switch over to a separate 3.3V source and re-post. 

Hey... at least the new cable model fixed my resetting problems   ;)
Title: Re: EthernetGateway
Post by: Salmoides on February 13, 2014, 11:33:15 pm
I'm feeling stupid. I know it's probably right in front of my face, but I can't see it. The current Arduino-dev1.4 gives me this:

In file included from /Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:12:
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.h:22:25: warning: avr/progmem.h: No such file or directory
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp: In member function 'boolean Sensor::sendData(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, const char*, uint8_t, boolean)':
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:180: warning: unused variable 'ok'
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp: In member function 'boolean Sensor::sendWrite(uint8_t, message_s, int)':
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:248: warning: statement has no effect
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:226: warning: unused variable 'retry'
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp: In member function 'char* Sensor::get(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)':
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected `while' before '*' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected `(' before '*' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected primary-expression before 'childId'
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected primary-expression before 'variableType'
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected `)' before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:365: error: expected `;' before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:369: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:375: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:379: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:383: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:388: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:392: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:397: error: a function-definition is not allowed here before '{' token
/Users/salmoides/Documents/Arduino/libraries/MySensors/Sensor.cpp:514: error: expected `}' at end of input
Title: Re: EthernetGateway
Post by: hek on February 14, 2014, 02:18:03 am
I'm feeling stupid. I know it's probably right in front of my face, but I can't see it. The current Arduino-dev1.4 gives me this:


I guess you mean that you've checked out 1.3dev (or master). 1.4dev is not in a working state right now.

A few people have reported problems on linux with progmem.h. After some googling I've found that I should include pgmspace.h instead. This has been updated and check in now.  Please try again and report back.

What compiler are you using? I see some warnings I'd  like to have a closer look on.
Title: Re: EthernetGateway
Post by: Salmoides on February 14, 2014, 08:00:09 am

What compiler are you using? I see some warnings I'd  like to have a closer look on.


I'm using the standard Arduino IDE on Mac OS X. I turned on verbose logging during compilation to get those results.

I'll recheck what I've downloaded. Thanks, Hek.
Title: Re: EthernetGateway
Post by: MDoc on February 22, 2014, 03:03:51 pm
I lost connection with the gateway today.  When I pinged the Gateway there was no response until I cycled the power.

I believe the problem is that I'm using a 3.3V 328P Nano as my Gateway.  I've got the ENC28J60 connected to the 3.3V output.  The FDTI output (FT233RL) can only supply 50ma while the ENC28J60 pulls 160ma when transmitting and 125ma at idle.  I'll switch over to a separate 3.3V source and re-post. 

Sorry for the delay in posting... In re-wiring I shorted my Uno and fried it and had to order another:(

Since supplying its own 3.3V, it has been two days without problems.  It appears the FTDI ship will supply 160ma for some period but will eventually go into thermal shutdown.  This will probably vary from chip to chip.
Make sure if you use a discrete 3.3V Regulator, you add a pretty large cap (100uf) to filter the spikes created by the  ENC28J60.

Hek... in your picture, it looks like you were powering the ENC28J60 off the FTDI 3.3V .  Did you see any problems in your testing?
Title: Re: EthernetGateway
Post by: hek on February 22, 2014, 03:23:37 pm
Hopefully you'll learn something new every time you feel the smell of fried Arduino. :)
(two of them have left for aruduino-heaven over here)

On the picture you can see a Pro Mini with the microscopic SOT23 regulator soldered to the 3 wires sticking out. I have not made any long time testing but I saw no problems with my setup.
   
Title: Re: EthernetGateway
Post by: MDoc on February 22, 2014, 04:42:22 pm
(two of them have left for aruduino-heaven over here)

Yeah.. I'm sure it would be the last.
OK... Glad to hear you're not having problems with an External Reg, Thanks!

Mike

Title: Re: EthernetGateway
Post by: veravance on February 23, 2014, 11:29:24 am
Hi,
very good job :-)
Does the gateway could work with a wifi shield ?
Title: Re: EthernetGateway
Post by: hek on February 23, 2014, 04:01:56 pm
Sorry, I don't own any wifi shield to test on.

Title: Re: EthernetGateway
Post by: p3tter on February 26, 2014, 01:28:16 pm
compiler error

windows8/mac os x  arduino 1.3Beta 2

I have a problem when trying to compile the ethernet gateway.
it gives me this error:

no matching function for call to 'Gateway::begin(uint8_t, void (&)(char*))'

Code: [Select]
EthernetGateway.ino: In function 'void setup()':
EthernetGateway:96: error: no matching function for call to 'Gateway::begin(uint8_t, void (&)(char*))'
C:\Users\user\Documents\Arduino\libraries\Vera/Gateway.h:44: note: candidates are: void Gateway::begin(uint8_t)

could someone help me?
thanks
Title: Re: EthernetGateway
Post by: hek on February 26, 2014, 01:48:06 pm
compiler error

windows8/mac os x  arduino 1.3Beta 2

I have a problem when trying to compile the ethernet gateway.
it gives me this error:

no matching function for call to 'Gateway::begin(uint8_t, void (&)(char*))'

Code: [Select]
EthernetGateway.ino: In function 'void setup()':
EthernetGateway:96: error: no matching function for call to 'Gateway::begin(uint8_t, void (&)(char*))'
C:\Users\user\Documents\Arduino\libraries\Vera/Gateway.h:44: note: candidates are: void Gateway::begin(uint8_t)

could someone help me?
thanks

I don't think you have installed the latest MySensors library in your Arduino IDE.
Title: Re: EthernetGateway
Post by: coachclass on March 10, 2014, 02:05:59 pm
I know I'm way late on this thread.  Since you don't need to use the Nano anymore, has anyone tried using one of the Arduino Uno variants that can supply higher currents on the 3.3 and 5V lines?  Like the Arduino Buono?


Sorry for the delay in posting... In re-wiring I shorted my Uno and fried it and had to order another:(

Since supplying its own 3.3V, it has been two days without problems.  It appears the FTDI ship will supply 160ma for some period but will eventually go into thermal shutdown.  This will probably vary from chip to chip.
Make sure if you use a discrete 3.3V Regulator, you add a pretty large cap (100uf) to filter the spikes created by the  ENC28J60.

Hek... in your picture, it looks like you were powering the ENC28J60 off the FTDI 3.3V .  Did you see any problems in your testing?
Title: Re: EthernetGateway
Post by: hek on March 10, 2014, 02:43:13 pm
Most Arduino boards should work fine if they have the same amount of memory as atmega328 .
Title: Re: EthernetGateway
Post by: MDoc on March 12, 2014, 09:46:37 pm
I know I'm way late on this thread.  Since you don't need to use the Nano anymore, has anyone tried using one of the Arduino Uno variants that can supply higher currents on the 3.3 and 5V lines?  Like the Arduino Buono?

I don't know about the Wiznet... But the ENC28J60 pulls 160ma when transmitting and 125ma at idle so any board you use would need to supply at least that...otherwise... You'd need an external regulator.
Title: Re: EthernetGateway
Post by: Dagwood08 on April 04, 2014, 08:44:59 pm
I recently built a serial gateway but didn't have any luck getting it to recognize any of my sensors so I built an ethernet gateway to see if I would have any better luck.  I was able to add the gateway to Vera and set the IP address, but when I press the start button to put it in inclusion mode nothing happens.  At least before when I was using the serial gateway and started the inclusion mode it would say something like "0 devices added" while it was waiting for communication from the sensors.  The ethernet gateway doesn't give any indication it is actually waiting for sensors.  Is this normal behavior or is there something that I might have not set up correctly?
Title: Re: EthernetGateway
Post by: j.hoekstra on August 22, 2014, 03:44:47 am
I've build the ethernetgateway and it works fine for about a day(or 2?) and then stops responding and IP is gone.
I've used the ENC-module and used the sketch from mysensors uploaded it with Arduino-IDE 1.05-r2.
Version of library according to Vera: 1.3b3 (67f4ca1) and I was able to add 2 nodes.
Powersupply of the nano is a 5V/2A tablet-charger.
So besides stability, it seems to work.

Since it takes a while to happen troubleshooting is not easy and my guess is that some timer gets over run or something. However I don't see a timer in the sketch itself, anyone have a clue where the error might be?
Title: Re: EthernetGateway
Post by: RexBeckett on August 22, 2014, 04:25:25 am
Quote
I've build the ethernetgateway and it works fine for about a day(or 2?) and then stops responding and IP is gone.

Has it gone or has your router issued it a different IP address? You can configure most routers to always issue the same IP address to a given MAC.
Title: Re: EthernetGateway
Post by: j.hoekstra on August 22, 2014, 05:40:57 am
Quote
I've build the ethernetgateway and it works fine for about a day(or 2?) and then stops responding and IP is gone.

Has it gone or has your router issued it a different IP address? You can configure most routers to always issue the same IP address to a given MAC.
It doesn't respond to pings after that. I got the IP reserved for this device in my router and it's 'hardcoded' in the sketch. Other devices setup same way don't 'loose' IP.
Title: Re: EthernetGateway
Post by: hek on August 22, 2014, 06:22:25 am
Try switching power supply. Did you mount capacitor on radio?
Title: Re: EthernetGateway
Post by: j.hoekstra on August 24, 2014, 03:09:45 pm
Try switching power supply. Did you mount capacitor on radio?
Tried several: 850mA, 1.2A and 2A.
Capacitor I didn't try just yet, will give that one a go :)
Title: Re: EthernetGateway
Post by: macrho on August 30, 2014, 01:45:28 pm
This is my first foray into trying to work with arduino uno v3. I picked up the modules noted here: http://mysensors.org/build/ethernet_gateway

I hooked the radio up according to the pins shown and then moved onto the ethernet shield w5100 and here is where I become confused: the 3.3v and 10, 11, 12 and 13 pins already have been used by the radio.

I'm missing something very basic..  :(
Title: Re: EthernetGateway
Post by: korttoma on August 30, 2014, 02:07:46 pm
I think it is supposed to share the pins with the radio module some other pin lets the modules know who the arduino is talking to. About the 3.3V, I must warn you to not overload the pin on the arduino. A separate regulator is probably to prefer in this case. On some arduinos the 3.3V is barely enough for the radio module and is causing bad communication.
Title: Re: EthernetGateway
Post by: macrho on August 30, 2014, 02:14:53 pm
How does one share the pins? It seems like each one of these Dupont wires takes up the hole pinhead; perhaps I'm missing appropriate wires
Title: Re: EthernetGateway
Post by: gregl on August 30, 2014, 05:53:39 pm
You plug the Ethernet shield on top of the arduino, then put the radio Dupont wires into the top of the Ethernet shield.
Title: Re: EthernetGateway
Post by: macrho on August 30, 2014, 06:09:27 pm
You plug the Ethernet shield on top of the arduino, then put the radio Dupont wires into the top of the Ethernet shield.

just to make sure, this is the shield i bought: http://www.ebay.com/itm/280924809892?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649
and this is the uno:


http://www.ebay.com/itm/181202760333?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

will this work?
Title: Re: EthernetGateway
Post by: hek on August 31, 2014, 03:52:09 am
In your case you might need a breadboard (if you don't want to solder).

http://www.ebay.com/itm/5pcs-SYB-170-Mini-Breadboard-Colorful-Breadboard-Small-Plates-/380883191528?pt=LH_DefaultDomain_0&hash=item58ae6846e8
Title: Re: EthernetGateway
Post by: macrho on August 31, 2014, 07:09:07 am
Are there other options for a cleaner install?
I thought I had purchased the recommended hardware from eBay

[one funny note: most of the packages from China came with generic labels, funniest one was "plastic fun toy"]

EDIT:

I found this on amazon, would it work: http://www.amazon.com/Sunfounder-Ethernet-Starter-Arduino-Mega2560/dp/B00JB2Z74W/ref=sr_1_13?ie=UTF8&qid=1409484505&sr=8-13&keywords=arduino+ethernet+shield+uno
Title: Re: EthernetGateway
Post by: hek on August 31, 2014, 07:51:08 am
Yep, that would make a cleaner ethernet gateway.
Title: Re: EthernetGateway
Post by: macrho on August 31, 2014, 07:56:20 am
Yep, that would make a cleaner ethernet gateway.

Thanks! Ordered and will post once received and set up
Title: Re: EthernetGateway
Post by: macrho on September 08, 2014, 04:38:56 pm
Finally received the uno along with the ethernet shield, followed all the directions and was able to successfully compile and upload the sketch to ardunio, however, it appears to never get an IP address

I used the deadbeeffeed MAC address, created a static on my router and nada.

<EDIT>

Of note, the LINK, 100M and FULLD LEDS flash yellow on the ethernet shield
</edit>

Any suggestions on a way to troubleshoot? Perhaps a bad shield or perhaps I somehow caused it.

Code: [Select]
// Use this fo WizNET module and Arduino Ethernet Shield
#include <Ethernet.h>


#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button

#define RADIO_CE_PIN        5  // radio chip enable
#define RADIO_SPI_SS_PIN    6  // radio SPI serial select
#define RADIO_ERROR_LED_PIN 7  // Error led pin
#define RADIO_RX_LED_PIN    8  // Receive led pin
#define RADIO_TX_LED_PIN    9  // the PCB, on board LED

#define IP_PORT 5003        // The port you want to open
IPAddress myIp (192, 168, 1, 108);  // Configure your static ip-address here

// 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.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED

Title: Re: EthernetGateway
Post by: hek on September 09, 2014, 01:29:30 am
You configure the static ip address in the sketch. DHCP does not work.
Title: Re: EthernetGateway
Post by: macrho on September 09, 2014, 08:16:26 am
You configure the static ip address in the sketch. DHCP does not work.

I thought I had with the 192.168.1.108?
I reserved a static with the MAC address noted in the sketch
Title: Re: EthernetGateway
Post by: macrho on September 09, 2014, 09:54:34 am
turned out to be a crappy power supply, the gateway is now up
Title: Re: EthernetGateway
Post by: macrho on September 09, 2014, 09:55:41 am
I also picked up a nice enclosure for the arduino and shield:

http://www.amazon.com/gp/product/B00N53W22I/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1
Title: Re: EthernetGateway
Post by: macrho on September 09, 2014, 05:29:06 pm
I'm wondering where my error might be as I can't include any sensors

* I wired up my ethernet shield according to directions here (http://mysensors.org/build/ethernet_gateway) using the radio NRF24L01

The gateway device shows up in Vera, does that mean that the radio is functional as well?

* I wired up an Uno R3 with the above radio along with a temperature/humidity sensor [http://mysensors.org/build/humidity]

When I click Start on the MySensors Plugin and startup my uno with the sensor, it never shows up.

I tore apart both the gateway and the sensor to make sure I had my cabling right (which I think I do)

What is my next step for troubleshooting? Should this be posted in a separate thread?
Title: Re: EthernetGateway
Post by: hek on September 09, 2014, 06:13:05 pm
I'm still waiting for a WizNet (5100) module and a 5100-uno-shield to do some renewed tests on the 1.4 code. 

Tried the ENC-module tonight and it failed miserable due to low memory instabilities.




Title: Re: EthernetGateway
Post by: macrho on September 10, 2014, 06:27:43 am
I'm still waiting for a WizNet (5100) module and a 5100-uno-shield to do some renewed tests on the 1.4 code. 

Tried the ENC-module tonight and it failed miserable due to low memory instabilities.

would it make sense to try 1.3 code or just wait? I'm fine with either
Title: Re: EthernetGateway
Post by: hek on September 10, 2014, 07:25:40 am
The gateway device shows up in Vera, does that mean that the radio is functional as well?

Not necessarily.

When I click Start on the MySensors Plugin and startup my uno with the sensor, it never shows up.

Reset the senor after include mode has been activated. Sensor sends presentation messages at startup.

Next step is to activate debug mode on gateway and sensor and watch Serial Monitor while connected to you computer.
Title: Re: EthernetGateway
Post by: macrho on September 13, 2014, 08:46:02 am
Reset the senor after include mode has been activated. Sensor sends presentation messages at startup.

Next step is to activate debug mode on gateway and sensor and watch Serial Monitor while connected to you computer.

It appears that DEBUG was enabled by default, after I set the correct speed, I see:

Code: [Select]
check wires

on my temp/humidity sensor. The gateway says [note, I didn't hook up ethernet, just straight USB to my mac]

Code: [Select]
0;0;3;0;14;Gateway startup complete.

I checked my wires on the temp/humidity sensor and when it starts up, no text goes to the Serial Monitor window and when I start inclusion, the sensor is never found. I've done a rest and a power cycle and still nothing

Title: Re: EthernetGateway
Post by: macrho on September 13, 2014, 03:01:39 pm
My gateway is up with the text I displayed previously via debug.

I have my sensor working, however, it doesn't appear to be talking to the gateway:

Code: [Select]
sensor started, id 1
send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=8,st=fail:Humidity
send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
send: 1-1-0-0 s=0,c=0,t=7,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=fail:19.8
send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
T: 19.80
send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=fail:50.6
H: 50.60
sensor started, id 1
send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=8,st=fail:Humidity
send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
send: 1-1-0-0 s=0,c=0,t=7,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=fail:19.8
send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
T: 19.80
send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=fail:48.9
H: 48.90
sensor started, id 1
send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=8,st=fail:Humidity
send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
send: 1-1-0-0 s=0,c=0,t=7,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=fail:19.8
send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
T: 19.80
send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=fail:48.2
H: 48.20
sensor started, id 1
send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=8,st=fail:Humidity
send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
send: 1-1-0-0 s=0,c=0,t=7,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=3,st=fail:1.4
send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=fail:20.0
send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
T: 20.00
send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=fail:50.2
H: 50.20
send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=fail:50.1
H: 50.10

temp and humidity update every couple of seconds
are the "st=fail" indicating a failure to connect to the gateway?

I powered the gateway off my mac and now am seeing:

Code: [Select]
0;0;3;0;9;version mismatch
0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
0;0;3;0;9;version mismatch
0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
0;0;3;0;9;version mismatch
0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
0;0;3;0;9;version mismatch
0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0:
Title: Re: EthernetGateway
Post by: macrho on September 13, 2014, 04:06:10 pm
Hopefully all this is helpful for someone:

I dumped the regular radio module for an antenna one I had purchased off of the mySensors store:

http://www.ebay.com/itm/310781092103

once I wired it up and restarted, all was good. My temp and humidity devices were added though right now it shows in metric though I chose imperial. Will look at this a bit more

If i'm motivated enough, I might put together a step by step instruction set
it was fun for a rainy saturday afternoon
Title: Re: EthernetGateway
Post by: icare on September 01, 2015, 07:13:30 am
I'm trying to make the ethernetgateway to work with my vera and was following the instructions on page 1. Unfortunately, I hit a 404 error on the topic "The gateway sketch can be found here:
https://github.com/mysensors/Arduino/tree/master/EthernetGateway". Anyone who can give me a lead where to find this?
Title: Re: EthernetGateway
Post by: akbooer on September 01, 2015, 07:53:10 am
I always access from here http://www.mysensors.org/download/
Title: Re: EthernetGateway
Post by: akbooer on September 01, 2015, 09:04:25 am
This is the down side of using the luup io module to communicate with a device. If the power fails on the remote device, then the link cannot be re-established once power is restored, unless Vera is restarted. This is a major Vera problem.
This still seems to be a problem with the Ethernet Gateway in its current form?

Quote
Due to this limitation, users may be better off having the Arduino Gateway act as a web server? You would command with GETs or POSTs and receive data in say json.
I'm presuming that the actual constraint is that you can't change the implementation of the gateway on the Arduino... this should be controller independent.

That being the case, I would suppose that a re-implementation using the LuaSocket library can go around the luup.io.open (or, rather, lack of luup.io.close problem.)

Also, does the MQTT gateway approach offer another way around this?

(New to MySensors, so much catching up to be done.  Hence the interest in an old post.)