House domotic project : Arduino MEGA + Node Red on dedicated Debian server

Hi everyone,

I'm planning a complete domotic project for ou house (under construction at the moment).

The goal is to have several sensors (PIR, DHT-22, CO, smoke, thermoresistance, ..) in each room + relays to control lights, warming and a few other things (air extraction, shutters, ...) + DIY alarm system.

I really appreciate NODE RED so far but am struggling using it to both retrieve data from the sensors AND control relays on the same arduino board.

If I do use StandardFirmata on the Arduino, NODE RED receives incorrect values that can't be used (from DHT-22 for example).

If I do use DHT library in the Arduino code and format the output in JSON format, I do retreive it correctly in NODE RED but don't know how to control relays and other devices that need to be controlled by NODE RED through Arduino.

I have 'lots' of sensors to get data from (15x DHT-22, 15x PIR, 15x photoresistance ...), which means that I will probably have to use more than 1 arduino (? maybe a solution to use only 1 ?).

How should I proceed ?

Taking a step back, how do you anticipate communicating between the arduino and NR? If you intend to use the MEGA as a central unit and then distribute wiring to all those sensors I am not sure that will be easy to achieve. But there are a number of design models you could use for the overall architecture.

For something like this I prefer a decentralised model that would use multiple micro-controllers all reporting back to the NR server. Each mcu would be responsible for just 1 or a couple of sensors. If you use an mcu like a esp8266 then you can eliminate all of the wiring except short runs from each mcu to each sensor.

I have a similar model to what you are proposing and am slowly moving away from that to a more distributed solution.

I will give you some background so you can understand

I started with Picaxe microcontrollers to control my whole house heating and cooling system - i had a live and a backup/development system with approximately 20 DS18B20 sensors and another 15 or so relays

When i migrated this to an Arduino environment i went with an Arduino Mega (actually in Australia we have a product called an Ethermega - which is a Mega with Ethernet Inbuilt - expensive but a very nice solution) and i deployed a single one of these in a live environment and a backup/dev system in case of failure

I moved into NR initially to build a dashboard to visual and control the system outside of the parameters i had built into the Arduino code and without having to visit a phsyical control panel and LCD screen etc.

I wrote my own code on the Arduino and utilised @knolleary excellent MQTT library to interface back to the MQTT broker. I run my NR environment on an Virtual machine under VMware ESXi - it is running on Ubuntu.

As i have progressed over the last two years i have gradually moved away from a centralised Arduino to ESP8266 (and now ESP32) units with localised functionality - such as a Temp/Humidty sensor and a relay control etc - i typically use either ESPEasy or Tasmota depending on the situation.

I briefly flirted with using Firmata but found it to be quite restricting

I would suggest you get an ethernet shield for the Mega and then just to make it easier to visualise and control break out the relays onto one rmega and the Temperature sensors onto another one. THen move into using Native Arduino code - once you have this running you can then simplify things (if you choose to) by introducing discrete modules and starting to distribute the funcionality

Craig

1 Like

Your planned setup sounds a bit like mine (but on a bigger scale) with multiple sensors and actuators, and as already mentioned it might be simpler to have separate devices. I've gone down the ESP8266 route, as they're very easy to work with, and cheap enough that I can put them everywhere.

My approach is very similar to @craigcurtin's above, using MQTT and with a central server running Node-RED controlling it all. If any single device fails, it's not going to affect anything else, and the only key node is the server which is running on a small Linux box - so hopefully a bit more reliable than the home-made widgets.

Although I can see some attraction in a centralised, single system, I think the distributed approach will give you a lot more flexibility, and better overall reliability.

Hi !

I don't want to use wifi (at least for domotics as I shut it down by night).

As I have the opportunity to cable the all house before finishing the walls, I will place some ethernet cabling to each and every 'interesting' locations.

So far, I'm making tests with 2 arduinos. I did prototype a board with every sensors I will use, cable it to the first arduino that reads the values every second, formats it to JSON then pushes it to NR.

A second arduino, with firmata, is then controlled by NR to open and close relays (mainly connected to a latching relay to control lights circuits or directly to relays for ventilation .. etc).

I will probably add some 433Mhz in the play ... :slight_smile:

I did this too, but in the end found wireless a lot easier to work with, especially the nrf24l01 modules.

So for me I have cat5e (and rg6) throughout the house but purely for standard network and video. All the iot stuff is now wireless (of some sort).

Hi Bobo,

I don't plan to use rf24 modules as my system will act both as alarm and domotics system. Thieves nowadays do use jammers to block communication between devices which could 'deactivate' the alarm :frowning:

I don't 'close the door' to the possibility anyway but will try to use cabling as much as possible (STP Cat6 minimum).