RS485 & ENC28J60 gateway
-
Hello MySensor friends;
I have made a RS-485 tot ethernet gateway with a ENC28J60 Ethernet adapter, and it is working good.
Only when i load it to the Arduino i got a warning that 97% of the dynamic memory is used.
Is it a problem for a good working gateway?All the not direct needed parts i comment out, including the debug.
The message: It is in dutch....
De schets gebruikt 27498 bytes (85%) programma-opslagruimte. Maximum is 32256 bytes. Globale variabelen gebruiken 1998 bytes (97%) van het dynamisch geheugen. Resteren 50 bytes voor lokale variabelen. Maximum is 2048 bytes. Weinig geheugen beschikbaar, er kunnen zich stabiliteitsproblemen voordoen
The sketch:
// Enable debug prints to serial monitor //#define MY_DEBUG // Enable RS485 transport layer #define MY_RS485 // Define this to enables DE-pin management on defined pin #define MY_RS485_DE_PIN 2 // Set RS485 baud rate to use #define MY_RS485_BAUD_RATE 9600 // Enable this if RS485 is connected to a hardware serial port //#define MY_RS485_HWSERIAL Serial1 // Enable serial gateway #define MY_GATEWAY_SERIAL // Enable gateway ethernet module type //#define MY_GATEWAY_W5100 #define MY_GATEWAY_ENC28J60 // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,0,14 // If using static ip you can define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,0,1 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode / or port to contact in client mode #define MY_PORT 5003 #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x59 //#define MY_NODE_ID 01 //#include <Ethernet.h> #include <SPI.h> #include <UIPEthernet.h> #include <MySensors.h> void setup() { // Setup locally attached sensors } void presentation() { //sendSketchInfo("RS 485 Gateway", "1.0"); // Present locally attached sensors here } void loop() { // Send locally attached sensors data here }
-
I'm not sure, but I think it depends on whether or not the code is using large local variables. At some point it's no longer possible to claim a space on the heap, because the free heap space is to fragmented
I have one Arduino that has a sketch with the same warning, but it's been running for a long time. No problems so far. But I've declared most of the variables global.
This is AdaFruits article on the topic:
https://cdn-learn.adafruit.com/downloads/pdf/memories-of-an-arduino.pdf
-
thank you for your response and the link to the interesting document!
The gateway has only run a few hours with 3 node's, so do not know if it goes well after days.
As far as I could see, I turned off all unnecessary lines in the sketch.
However, I notice the W5100 library is a lot less used, but I only have that for a UNO ....
-
I have now been running the gateway for more than half a year, and unfortunately the gateway runs regularly (about once every 2 weeks), so I am going to replace the gateway for a W5100 ethernet adapter.
I used it in a second gateway, and this gateway is stable, I haven't had any crashes in about 4 months.