fredilarsen / ModuleInterface

Easy config and value sync between IoT modules, database and web pages
Other
70 stars 12 forks source link

Memory footprint and dependency to Arduino? #10

Closed rainerschoe closed 4 years ago

rainerschoe commented 4 years ago

Hi, I am planning a private home automation project (Multi-Master ThroughSerial via RS484 using AVR Atmega328 and AVR Atmega1284). I will use PJON as a communication protocol. However I will not use Arduino bootloader/core libs (custom hardware and custom bootloader). Hence I already ported the PJON Interface to support bare metal AVR controllers.

ModuleInterface seems to match my requirements quite neatly, but I see you have some dependencies on Arduino core libs/headers. Could you comment on how easily ModuleInterface could be adapted to bare metal AVR with only PJON running?

Also In your README you specify that the Master node should be some bigger controller. Is Atmega1284 sufficient? (No GUI or Webserver, just Broker)

fredilarsen commented 4 years ago

Hi. Sorry for the delayed response. A lot going on.

The master will keep an object for each of its slave modules, mirroring the settings, outputs and inputs. This increases the RAM requirements, depending on the number of slaves and the total count of variables used by all modules.

Then add a Http connection with JSON encoding/decoding (and/or a MQTT client) and it grows too big (both storage and RAM) to fit in an Arduino Nano (2kB RAM). I have previously been running it on a Mega2560 (8kB RAM) with an Ethernet shield and lots of margin for 10+ modules.

But as I have a server (Windows, could just as well be Linux/RPI) with a web server and database running continuously, I did replace the Mega master with a SoftwareBitBang-DualUDP switch (on a Nano) and I run the master (using DualUDP) as a program on the same server as the web server. This allows me to remotely log in and upgrade and test new features in an easier way, and it also handles the HTTP + MQTT transfers faster.

Regarding dependencies on Arduino libs/headers, it also builds on Windows and Linux. There are some system dependent defines, mostly located in the header files in the platforms directory. Notably the POSIX define which should avoid Arduino specific stuff.

gioblu commented 4 years ago

Ciao @fredilarsen sorry for going a little off-topic, @rainerschoe would you contribute the PJON bare metal AVR interface with a pull-request? I am sure many users would love that :)

rainerschoe commented 4 years ago

Thanks for the reply.

OK, I think I can then modify those "system" headers with bare-metal implementations for AVR :-)

I plan on having a network split into two zones:

  1. Reliable subsystem (entirely composed of AtmegaXXX components, always on)
  2. Unreliable subsystem (Raspi / Linux servers for internet connectivity and user-interface). Hence I plan to have MI master in the reliable subsystem. but HTTP/ MQTT transports could be moved to the Unreliable subsystem on Linux based machines (not sure if this can be separated).

Regarding contributing to PJON: I already have this in mind, however I think it still needs some polishing and testing. Right now I only tested it on Atmega328PB with ThroughSerial and it is a little bit controller specific due to Serial implementation and IO/Pin mapping. But once my project goes on I will create a pullrequest for sure :P

gioblu commented 4 years ago

Thank you very much @rainerschoe