@MasMat : I just forgot, that I reconfigured rsyslogd to log mysgw to a different file. syslog is correct.
I do not use mqtt for mysensors yet, but the syslog seems good?
@MasMat : I just forgot, that I reconfigured rsyslogd to log mysgw to a different file. syslog is correct.
I do not use mqtt for mysensors yet, but the syslog seems good?
@MasMat : what does your mysgw.log show?
Yesterday I cloned the latest version on a recent raspbian (9.3) and I applied the first patch of @marceloaqno .
We will see. So long there were no problems. I will send an update in a few days...
As a last help I could switch to mqtt and do a restart after a defined amount of time (if no events are received)....
Cheers,
Otto
@marceloaqno :
Hi, unfortunately the latest patch did not work for me.
Still the gw stops receiving, but without high cpu usage
Fortunately I can restart the gw now using a button and this udp-scripts
Of cource I could give dietpi a try, but I would think, that a general solution would be better (for other users as well)
cheers,
Otto
@marceloaqno :
THANKS! Just applied your patch.
I will report in a few days when I can see if the problem is solved...
Cheers,
Otto
@gohan :
dietpi looks interesting! did not know about this yet.
what hardware are you using? and what version of mysgw?
@marceloaqno :
Thank you!!! Should this patch be applied together with your first patch?
Interesting:
After some days without problems on the newest raspbian packages the gw hung again, but WITHOUT high cpu usage (and WITHOUT your first patch applied). There were just no more reads from the sensors in the log, only the re-connects of fhem. After restarting the service, everything is fine again.
Unfortunately I did see your post after that
But I checked the log and could not find the words "too" or "Too" in the log (running service with -d).
Some minutes after restarting I checked how many open files there were with the command you supplied: 21
In the meantime I have created a small udp listening service which restarts the service if a certain string is received, so I can restart the service by double-clicking one of my switches without the need of login to the gw (also for the wife)....
@gieljnssns : I think you are experiencing exactly the same problem we are discussing
Thanks again!
Cheers,
Otto
@marceloaqno : Thank you!
Just a notice: I do NOT disconnect, I just connect every 30 minutes. Has been working for me since more than 2 years (ancient ms-gw version on RPi).
Yesterday I did a dist-upgrade to stretch on the "problematic" gw (as mentioned above) - without your patch but with my monitoring-script running. It is a little bit to early I presume, but no high cpu problems so far. I will report back here in a few days. Maybe this problem is really related to old libraries or something?! If this is running stable for a few days I will apply your patch and see what happens.
Thanks again!
Cheers,
Pula
@marceloaqno : This is strange. I am using a RPi 1 on this gateway with raspbian Jessie. Beside the GW-service there is only a small python programm which listens on an UPD-Port and plays an mp3 if it receives suitable data (for doorbell). Since March 4, 20:15 there were several restarts due to high cpu usage (after dis-applying your patch):
2018-03-04 23:01:03 cpu (99.7) very high! --> restarting service
2018-03-05 07:31:03 cpu (99.7) very high! --> restarting service
2018-03-05 11:01:03 cpu (98.7) very high! --> restarting service
2018-03-05 13:31:04 cpu (94.7) very high! --> restarting service
2018-03-06 11:31:03 cpu (99.7) very high! --> restarting service
2018-03-06 12:31:03 cpu (98.7) very high! --> restarting service
2018-03-07 06:01:03 cpu (94.8) very high! --> restarting service
2018-03-07 22:31:03 cpu (99.8) very high! --> restarting service
With this "auto-restarts" the sensors are working fine, I did not notice any problems.
However, I just upgraded to the recent Stretch (what takes a LONG time on RPi 1 and made me struggle a little bit with the new network names). I also rebuilt the GW of course and will report here what will happen....
@Nick-Willis : did you apply the patch of marceloaqno or not? Did you enable debugging? (see here )
Cheers,
Otto
At first, THANKS for your help. CPU usage does not rise anymore.
But unfortunately no more node READs after the same situation:
Mar 4 07:00:09 raspiez mysgw: TSF:MSG:READ,14-14-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
Mar 4 07:00:09 raspiez mysgw: TSF:MSG:READ,12-12-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0
Mar 4 07:00:09 raspiez mysgw: GWT:RFC:C=1,MSG=14;255;3;0;6;M
Mar 4 07:00:09 raspiez mysgw: !TSF:MSG:SEND,0-0-14-14,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
Mar 4 07:00:09 raspiez mysgw: TSF:MSG:READ,11-11-0,s=255,c=0,t=18,pt=0,l=3,sg=0:1.5
Mar 4 07:00:09 raspiez mysgw: GWT:RFC:C=1,MSG=12;255;3;0;6;M
Mar 4 07:00:09 raspiez mysgw: TSF:MSG:SEND,0-0-12-12,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=OK:M
Mar 4 07:00:13 raspiez mysgw: TSM:READY:NWD REQ
Mar 4 07:00:13 raspiez mysgw: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
Mar 4 07:00:13 raspiez mysgw: TSF:SRT:OK
Mar 4 07:00:13 raspiez mysgw: TSF:SAN:OK
Mar 4 07:00:37 raspiez mysgw: Ethernet client disconnected.
Mar 4 07:00:37 raspiez mysgw: New connection from 192.168.1.11
Mar 4 07:00:37 raspiez mysgw: GWT:TSA:C=0,CONNECTED
Mar 4 07:00:37 raspiez mysgw: GWT:TSA:C=1,DISCONNECTED
After this point (again after a reconnect from the controller) no more messages from any node PLUS the cpu usage stayed normal (what makes it even worse at this moment, as I would have to create a script which monitors the logfile and restarts the mysgw service in this situation). As soon as the service is restarted, everything is working fine again.
What happens after this point in the log:
Mar 4 07:00:37 raspiez mysgw: GWT:RFC:C=0,MSG=0;0;3;0;2;
Mar 4 07:15:13 raspiez mysgw: TSF:SAN:OK
Mar 4 07:20:13 raspiez mysgw: TSM:READY:NWD REQ
Mar 4 07:20:13 raspiez mysgw: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
Mar 4 07:30:13 raspiez mysgw: TSF:SRT:OK
Mar 4 07:30:13 raspiez mysgw: TSF:SAN:OK
Mar 4 07:30:37 raspiez mysgw: GWT:TSA:C=0,DISCONNECTED
Mar 4 07:30:37 raspiez mysgw: Ethernet client disconnected.
Mar 4 07:30:37 raspiez mysgw: New connection from 192.168.1.11
Mar 4 07:30:37 raspiez mysgw: GWT:TSA:C=0,CONNECTED
Mar 4 07:30:37 raspiez mysgw: GWT:RFC:C=0,MSG=0;0;3;0;2;
Mar 4 07:40:13 raspiez mysgw: TSM:READY:NWD REQ
Mar 4 07:40:13 raspiez mysgw: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
Mar 4 07:45:13 raspiez mysgw: TSF:SAN:OK
Mar 4 08:00:13 raspiez mysgw: TSM:READY:NWD REQ
Mar 4 08:00:13 raspiez mysgw: TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
Mar 4 08:00:13 raspiez mysgw: TSF:SRT:OK
Mar 4 08:00:13 raspiez mysgw: TSF:SAN:OK
Mar 4 08:00:37 raspiez mysgw: GWT:TSA:C=0,DISCONNECTED
Mar 4 08:00:37 raspiez mysgw: Ethernet client disconnected.
Mar 4 08:00:37 raspiez mysgw: New connection from 192.168.1.11
Mar 4 08:00:37 raspiez mysgw: GWT:TSA:C=0,CONNECTED
and so on....
It seems that the increasing cpu usage is only a symptom for the real problem.
As I am using this in production I will dis-apply the patch and use the daemon as before (beacuse using the python script for cpu-usage-monitoring makes the situation somehow controllable for me).
Maybe you could have an additional eye on this please? Could I help you with further information? Maybe I could add some additional logging somewhere in the code?
Thanks again and cheers,
Otto
@marceloaqno : Wow, you are fast! Thanks!
Just applied the patch and recompiled. I will report in a couple of days while my monitoring-script is still running (and logging)...
Cheers,
Otto
@marceloaqno : of course, thanks for the hint!
I had the following configure:
./configure --my-transport=nrf24 --my-rf24-irq-pin=15 --my-gateway=ethernet --my-port=5004
(The high CPU problem also occured before I connected PIN 15 to IRQ without the corresponding config option. I hoped to solve the Problem using IRQ, but this did not help. And I have a second GW with default port 5003 in my network. This is running an ancient version of Raspi GW Software and this is working fine -but slower). I am using current fhem as controller and I have it connecting every 30 minutes to the gateways due to stability issues in the past. There are only about 6 nodes (just motion, humidity & temp and lux) connected to this gateway.
In addition to that I changed the default channel in MyConfig.h (because I have two different MySensor networks):
#ifndef MY_RF24_CHANNEL
#define MY_RF24_CHANNEL (82)
#endif
I am pretty sure, that this is not important, but I also set up rsyslog to write gw logs to an own file instead of syslog....
Maybe this helps.
Cheers,
Otto
@rejoe2 :
Thanks a lot!
I am having some unusual sketches (washing mashine monitoring, entry-system with fingerprint) where I am using self-written sketches with mysensors). Maybe I should wait. It is just annoying that the radio-stuff is not always working as it should. Indeed, esp with mqtt could be a solution too. But I do not know yet about the stability of esp-stuff
Cheers,
Otto
@Nick-Willis:
I do run the gateway in debug mode, but I could not see anything special.
Yesterday the service was auto-restarted by my script:
2018-02-27 13:31:03 high CPU-usage! --> restarting service```
On the same time in the "normal" mysgw.log (debugging enabled) (should be syslog normally, but I changed the logfile location for better investigation):
Feb 27 13:30:36 raspiez mysgw: TSF:MSG:READ,14-14-0,s=1,c=1,t=23,pt=7,l=5,sg=0:0.11
Feb 27 13:30:36 raspiez mysgw: TSF:MSG:READ,14-14-0,s=3,c=1,t=0,pt=7,l=5,sg=0:21.9
Feb 27 13:30:36 raspiez mysgw: TSF:MSG:READ,14-14-0,s=4,c=1,t=1,pt=7,l=5,sg=0:31.4
Feb 27 13:30:38 raspiez mysgw: New connection from 192.168.1.11 <-- fhem re-connects
Feb 27 13:30:38 raspiez mysgw: GWT:TSA:C=1,CONNECTED
Feb 27 13:31:04 raspiez mysgw: Received SIGTERM <-- AUTO-Restart
The only thing that is a little bit unusual is the re-connect of my controller (fhem) - but this happens every 30 minutes for stability reasons.
This should not happen, but I can not find out what the problem is.
Maybe you could also enable debugging by changing the following file (maybe we can find a pattern why this is happening):
/etc/systemd/system/mysgw.service
from
ExecStart=/usr/local/bin/mysgw
to
ExecStart=/usr/local/bin/mysgw -d
Please do not forget to issue a
sudo systemctl daemon-reload
followed by
sudo systemctl restart mysgw.service
to enable the change.
My restarting-script might help until someone with better knowledge finds a solution...
I also will have an eye on the logs for findig out how often this is happening...
Cheers,
Otto
Hi,
I am running the current version (2.2.0) on a RPi 1.
I noticed that sometimes the cpu usage of the service is increasing dramatically (around 90% and more) - and then the service stops working.
As I am not a C-Pro, I wrote a little python-script, which is called every minute by cron and restarts the service, if it uses more than 50% cpu.
Maybe someone will find it useful:
# -*- coding: utf-8 -*-
import psutil, sys, os, datetime
PY3 = sys.version_info[0] == 2
LOOKFOR = u"mysgw"
for proc in psutil.process_iter():
if proc.name() == "mysgw":
dt = str(datetime.datetime.now()).split('.')[0]
#print(proc)
cpu = proc.cpu_percent(interval=1)
#print(cpu)
#print(proc.cpu_times())
if cpu > 50:
print(dt + " high CPU-usage! --> restarting service")
os.system("/bin/systemctl restart mysgw.service")
else:
if datetime.datetime.now().strftime('%M') == "45":
print(dt + " everything OK, cpu: " + str(cpu))
and the crontab-entry (as root):
* * * * * /home/pi/pstest.sh >> /var/log/mysgw-logger.log
Cheers,
Pula
I am thinking about changing my Mysensor-Nodes from NRF24L01+ to RS485 because of stability. But while reading this, I am not sure anymore, if this is a good idea
Anyone has this up & running successfully already?
Hi again,
and thanks again. signing seems to work now, unfortunately the sketch is too big for an UNO and I am right now struggling with the pinout and code adaptions to get it working with my W5100 shield and a mega...
/edit: got it working.
MyConfig.h:
#ifdef SOFTSPI
// Define the soft SPI pins used for NRF radio
//MEGA
const uint8_t SOFT_SPI_MISO_PIN = 15;
const uint8_t SOFT_SPI_MOSI_PIN = 14;
const uint8_t SOFT_SPI_SCK_PIN = 16;
#endif
EthernetGateway.ino:
#define RADIO_CE_PIN 35 // 5 // radio chip enable
#define RADIO_SPI_SS_PIN 34 // 6 // radio SPI serial select
And exactly those pins I connected from radio to the mega... (just in case that anyone else is in need of this)
Might be a little OT, but maybe someone here knows a solution for a strange problem:
Whenever I am using an UNO or MEGA with my W5100 shield, I have to reset after every power-on to make the sketch run. Does anyone know this? Is there a solution? I am trying to adapt optiboot to wait additional 500ms when powering on, but no luck so far...
Cheers,
Otto
Did someone get the GW with mega and W5100 working????
@tomkxy Thanks, that helped! I seemed to have two problems:
2)Regarding my problems from above (error: 'DEFAULT_CE_PIN' was not declared in this scope): I removed the whole libraries/MySensors dir and copied it again from the recent devel branch - this helped, error is gone and everything is compiling fine now
Thanks again and cheers,
Otto
Hi,
this might be a little OT, cause it is not directly related to mysensors, so sorry.
But maybe someone knows this problem or even a solution.
I got some UNO R3 boards and W5100 ethernet shields on ali.
Uploaded some sketch and everything worked fine as long as I was using the USB cable connected to my pc.
But then I wanted to go in production and used different power sources:
A 9V adaptor connected to the power plug, even with a DC-DC module with voltage from 5V up to 9V, 5V directly to the USB port of the arduino, but nothing worked.
What the arduino does when I turn power on or connect it to the already plugged in power source: The power led is on and the TX LED is blinking several times. Until I press the reset button on the ethernet shield - then the arduino is booting the sketch and everything is fine.
Does anyone know this problem? Some hints would be really fine!
Cheers,
Pula
Hi,
I seem to be too stupid (or drunk ) to get this working with MySigningAtsha204Soft
Is anyone willing to provide a working MyConfig.h and EthernetGateway.ino for this?
There seemed to be some changes and I am sure, I am just too dumb...
Thanks a lot for the hints, especially @treb0r
I will have a closer look at it as soon as I have the wind sensor
Hi,
I am thinking about buying one of those http://www.aliexpress.com/item/WIND-SPEED-SENSOR-JRFS-01-Aluminum-alloy-manufacture/1490853251.html
for shutter control.
It is working with reed contacts and gives 10 pulses for a wind speed of 1m/s.
Does anyone know how something like this could be implemented with mysensors?
Thanks in advance,
Otto
@AWI: Thanks for your hint. I am also thinking about switch buttons with long press. BTW: how did you implement the long press in mysensors?
Thanks!
What I want to do is pretty simple: Just have a rotary dimmer connected to an arduino - the controller should get the values and dim the lights (connected to different devices) according to the rotary switch. But it should be a wall switch (to get a reliable WAF)....
Sorry, this should work:
http://www.rev.de/dzo/artikel/201/007/7494_201.pdf?t=1342180610
Unfortunately it is German only...
Hi,
yes, I have a REV Dimmer Typ 13623 (http://www.rev.de/dzo/artikel/201/0077494_201.pdf?t=1342180610)
Just connected it to an arduino with some "configurable firmata" and as controller I am using fhem. This sketch is just reporting the status of the pins directly to the controller. I am using pin A0 for instance - if I connect it directly to GND, this is immediately reported to the controller. If I am connecting the dimmer, nothing happens. I hope I could explain what I am trying to do...
Yes, thank you. Unfortunately this is not really useable. I have one wall rotary switch and connected it to an arduino directly. But the analogue in does not detect anything I am trying on the switch. I think the rotary encoder is working absolutely different to usual wall switches
Hi,
as I am already rebuiding my house, there is a question on how to implement a rotary dimmer wall switch with mysensors? This switch should only be connected to an analogue in of the arduino and send the status (or changes) to the controller. But it should be a standard wall dimmer switch. I tried one, but no success on changing analogue in level. Has anyone done something like that? How?
Thanks and regards,
Otto
Thanks for the hints
Yes, RS485 would be a very interesting option, but is not implemented yet - and I am modifying my house right now. I think I will add some pins to the power wires for future use...
Hi,
while planning my house re-design I am also thinking about RFID.
I think some kind of presence-recognition and car-approaching sensor could be implemented using RFID.
My thoughts:
If I place some RFID-tags in the house shoes, I could check if someone is at home (no house shoes at usual place --> someone at home).
And if I had some chips in the car, the door of the carhouse could open when I drive through the driveway.
As RFID is a completely new technology for me:
How could this be implemented? Which kind of tags and readers could be used?
Thanks and regards,
Otto
Think, I will try with a computer power supply + regulator for 3.3v....
Thanks anyway! I will try again without signing. Maybe there is a problem in the recent devel-branch. With stable 1.4 it compiled without any issues...
/update: does not compile with the "standard" ethernet-gw sketch too.... not related to signing...
I used the latest devel-branch from github.
This is the error:
In file included from /home/otto/sketchbook/libraries/MySensors/MyTransportNRF24.h:26:0,
from /home/otto/sketchbook/libraries/MySensors/MySensor.h:28,
from ms_gw_neu.ino:42:
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:11: error: 'SOFT_SPI_MISO_PIN' was not declared in this scope
SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
^
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:30: error: 'SOFT_SPI_MOSI_PIN' was not declared in this scope
SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
^
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:49: error: 'SOFT_SPI_SCK_PIN' was not declared in this scope
SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
^
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 1 is invalid
SoftSPI<SOFT_SPI_MISO_PIN, SOFT_SPI_MOSI_PIN, SOFT_SPI_SCK_PIN, SPI_MODE> spi;
^
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 2 is invalid
/home/otto/sketchbook/libraries/MySensors/utility/RF24.h:51:75: error: template argument 3 is invalid
In file included from ms_gw_neu.ino:43:0:
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:28: error: 'DEFAULT_CE_PIN' was not declared in this scope
MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
^
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:59: error: 'DEFAULT_CS_PIN' was not declared in this scope
MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
^
ms_gw_neu.ino:80:31: error: no matching function for call to 'MyGateway::MyGateway(MyTransportNRF24&, MyHwATMega328&, MySigningAtsha204Soft&)'
ms_gw_neu.ino:80:31: note: candidates are:
In file included from ms_gw_neu.ino:43:0:
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note: MyGateway::MyGateway(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
MyGateway(uint8_t _cepin=DEFAULT_CE_PIN, uint8_t _cspin=DEFAULT_CS_PIN, uint8_t _inclusion_time = 1, uint8_t _inclusion_pin = 3, uint8_t _rx=6, uint8_t _tx=5, uint8_t _er=4);
^
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:39:3: note: no known conversion for argument 1 from 'MyTransportNRF24' to 'uint8_t {aka unsigned char}'
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note: MyGateway::MyGateway(const MyGateway&)
class MyGateway : public MySensor
^
/home/otto/sketchbook/libraries/MySensors/MyGateway.h:20:7: note: candidate expects 1 argument, 3 provided
and this is the sketch - I am not sure, if everything is right (I am not deep into mysensors yet):
/*
* 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 WIZNET (W5100) ETHERNET MODULE
* > Edit RF24_config.h in (libraries\MySensors\utility) to enable softspi (remove // before "#define SOFTSPI").
*
* COMPILING ENC28J60 ETHERNET MODULE
* > Use Arduino IDE 1.5.7 (or later)
* > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading.
* > Remove Ethernet.h include below and include UIPEthernet.h
* > Remove DigitalIO include
* Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
*
* 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 defualt 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
*
* See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
*
*/
#include <DigitalIO.h> // This include can be removed when using UIPEthernet module
#include <SPI.h>
#include <MySensor.h>
#include <MyGateway.h>
#include <stdarg.h>
#include <MyConfig.h>
#include <MySigningAtsha204Soft.h>
// Use this if you have attached a Ethernet ENC28J60 shields
//#include <UIPEthernet.h>
// Use this fo WizNET W5100 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, 66); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
// 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[] = { 0xCE, 0x0D, 0xBE, 0xEF, 0xFE, 0xED }; // DEAD BEEF FEED
// a R/W server on the port
EthernetServer server = EthernetServer(IP_PORT);
MyTransportNRF24 radio; // NRFRF24L01 radio driver
MyHwATMega328 hw; // Select AtMega328 hardware profile
MySigningAtsha204Soft signer(false); // Select ATSHA204A software signing backend
MyGateway gw(radio, hw, signer);
// No blink or button functionality. Use the vanilla constructor.
// old MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);
// Uncomment this constructor if you have leds and include button attached to your gateway
//MyGateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
int inputPos = 0;
void setup()
{
Ethernet.begin(mac, myIp);
// give the Ethernet interface a second to initialize
delay(1000);
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
gw.begin(RF24_PA_LEVEL_GW, RF24_CHANNEL, RF24_DATARATE, writeEthernet);
// start listening for clients
server.begin();
}
// This will be called when data should be written to ethernet
void writeEthernet(char *writeBuffer) {
server.write(writeBuffer);
}
void loop()
{
// if an incoming client connects, there will be
// bytes available to read via the client object
EthernetClient client = server.available();
if (client) {
Serial.print("bytes");
// if got 1 or more bytes
if (client.available()) {
// read the bytes incoming from the client
char inChar = client.read();
if (inputPos<MAX_RECEIVE_LENGTH-1) {
// if newline then command is complete
if (inChar == '\n') {
// a command was issued by the client
// we will now try to send it to the actuator
inputString[inputPos] = 0;
// echo the string to the serial port
Serial.print(inputString);
gw.parseAndSend(inputString);
// clear the string:
inputPos = 0;
} else {
// add it to the inputString:
inputString[inputPos] = inChar;
inputPos++;
}
} else {
// Incoming message too long. Throw away
inputPos = 0;
}
}
}
gw.processRadioMessage();
}
Thanks for your help in advance!
Otto
@Anticimex:
Thanks, but I am trying to compile it for an UNO R3?! That should do it. Nevertheless: Using nanos only for nodes should work with sw signing, shouldnt it?
Hi @all!
First off all: thanks for your great work
I am about to compile the ethernet gw with software signing, but unfortunately I am getting some compile errors.
Does anyone maybe have a sketch handy and would up it here?
Thanks in advance and best regards,
Otto
do you have any suggestions how to do this?
I am new to arduino stuff and dont know if fhem supports stuff like this?
oh no - got it
I bought some 4.7 uF capacitors today and now everything works fine arghhhh
but thanks for your help!
Hi forum,
I am planning my new house right now and I am thinking about using mysensors along with fhem.
As I have the possibility to completely wire the house, I think some kind of power-bus-wire (eg CAT7) would be nice to power all the arduinos and hardware along itΒ΄s way. Im am considering to have 3.3V, 5V and 12V plus 3 x GND in that wire.
What kind of power supply would you use? I think that it will about 20 arduinos (mainly minis) within the next year...
Thanks for advice!
ahm... just to understand it:
I have connected the gateway to the controller (fhem), but did not define any sensors yet in fhem.
Shouldnt the sensor connect to the gateway nevertheless?????
Oh sorry - I am using fhem...
The gateway is recognized by fhem already, but obviously no connection between gateway and sensor
/a controller? I am using two UNOs R3 if you mean those?
Hi forum,
I am just trying to build up my first ethernet gateway and first test sensor and I am kind of desperated....
What I did:
I built an ethernet gateway using this tutorial: http://www.mysensors.org/build/ethernet_gateway
I am using a W5100 shield (which I just stuck onto the arduino) and a UNO R3.
Terminal message when starting the gateway:
0;0;3;0;14;Gateway startup complete.
My fhem instance looks fine connecting to the gateway.
Then I build a sensor using a second UNO R3, but all i get is:
send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
sensor started, id 1
send: 1-1-255-0 s=255,c=0,t=17,pt=0,l=5,st=fail:1.4.1
send: 1-1-255-0 s=255,c=3,t=6,pt=1,l=1,st=fail:255
send: 1-1-255-0 s=3,c=0,t=0,pt=0,l=5,st=fail:1.4.1
send: 1-1-255-0 s=3,c=1,t=16,pt=2,l=2,st=fail:1
This is the sketch I used:
// Simple binary switch example
// Connect button or door/window reed switch between
// digitial I/O pin 3 (BUTTON_PIN below) and GND.
#include <MySensor.h>
#include <SPI.h>
#include <Bounce2.h>
#include <MyConfig.h>
//int node_id = 1;
#define CHILD_ID 3
#define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
MySensor gw;
Bounce debouncer = Bounce();
int oldValue=-1;
// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);
void setup()
{
// gw.begin(NULL, node_id);
gw.begin();
// Setup the button
pinMode(BUTTON_PIN,INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN,HIGH);
// After setting up the button, setup debouncer
debouncer.attach(BUTTON_PIN);
debouncer.interval(5);
// Register binary input sensor to gw (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.
gw.present(CHILD_ID, S_DOOR);
}
// Check if digital input has changed and send in new value
void loop()
{
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue) {
// Send in the new value
delay(100);
gw.send(msg.set(value==HIGH ? 1 : 0));
oldValue = value;
}
}
What else to tell? I am using Fedora Linux and have both arduinos connected using USB. I am using NRF24L01+ transceiver module which I wired according to the tutorials. I do not use any external resistors or capacitors....
Help would be VERY appreciated...
Thanks in advance!
Otto