Hi all. Is it possible to use more than 1 Arduino. I’ve connected one Arduino Mega (standard firmata using port USB) with Rpi and it works flawless. During my brainstorming process about my home automation I’ve discovered that i need to have more PINs to control all sensors. I thing the best way for me is to use 3 arduino’s mega. Is it possible? Maybe I need to connect them in different way than using usb? Please help
Why not use an esp8266 and mqtt. No physical connection needed.
Perhaps you should describe what you’re trying to do. What kind of sensors? Why do they all have to go into one Mega? I have a bunch of sensors around the house and each has a $1 esp8266-01 that publishes an MQTT message every few minutes.
if i recall, the mega has 54? digital IO pins… and 16 analog inputs… how many sensors are you using !?
Ill second the suggestion of using ESP8266 MCUs over MQTT, it will make your life much easier in the future.
No to mention that it seems unlikely, in the absence of a lucky break on your wiring, that it is going to be really easy to wire that many sensors back to your pi.
I will try to explain what´s my idea. Yesterday I´ve spoke to one guy who use this method in domoticz. I would like to have Rpi as central unit and arduinos. Arduinos pins should be connected using rj cables in patch panel. From patch panel i could use FTP or UTP cables (ftp better) and wire all house. Each ftp wire can connect up to 7 sensors. Lighting is another ftp cable that goes to each wall can (sorry i don’t know proper eng name for that) + 2 relays to control each light cirquit. This way i can use standard installation + control all using HA. I’m affraid that I will need to use more than 54 pins. I think i can get around 60-70 sensors for my whole house and yard. The guy who shown me this method has 4 arduinos and rpi installed. Maybe there is a better way to do that? I want to wire everything for safety and maintain “not inteligent” installation also (in case somethin go wrong) and leave esp8266 as a second choice (i wil use sonoffs also. Right now I have one with tasmota and works great)
To summorize: on 1 Arduino Mega i can get up to 24 relays + switches for ssr (or 1 arduino Mega for 13 window blinds). One FTP cable can connect up to 7 sensors, but the wires for Light and wires for sensors needs to go on separate cable (1 ftp wire for each can for lightning + 1 ftp for 7 sensors)
If you want to run all those cables, then fine. What you describe is one way of running a home automation system. A pi has four USB ports so you can attach 4 arduinos, more if you want to use a USB hub. But you only need one relay per lighting circuit of course. You are also going to need to be very careful about mains/low voltage isolation.
Take a look at the Shelley products which allow an independent old fashioned light switch as well as home automation control.
I don’t know if this is the best solution but my focus is to have my home wired as much as possible (to avoid internet connection problems like wifi / internet provider errors) + to have standard lightning system also (in case something goes wrong like eg. system / hardware crash).
Luckily I have 2 months to think about it because I will wire my new home in autumn / winter time.
Shelly 1 is a good option also I’ve dscovered it a week ago and I will read about it a little bit more (maybe this will be a better idea than FTP cable for lightning. This way I can have less FTP cables and - less Arduinos, maybe one will work).
Today I will try to connect Arduino Mega and Arduino Yun and give you feedback how this works.
Another thing to consider is voltage drop over the distance. Depending on how large your house is or how you run your cables you might not end up with enough voltage at the wire to switch anything.
But flashed with the Sonoff-Tasmota firmware that way you are not reliant on the internet and you can still use them as normal wall switches.
This is possible (voltage drop) but for sensors this should be no problem (they overall don’t need much voltage. One FTP cable will charge up to 7 sensors or will be attached to can with 2relays only ). My house will have 150m2 living space plus small yard. I was thinking about other possibilites, but I spoke with guys who use this method for their houses (using Domoticz, I personally don’t like this system), and they are very happy how it works
I was thinking about Shelly 1 or Sonoff and whet it comes to the price - the idea of using FTP cables will be at cheaper (1000ft / 305m of FTP cat 6 cable cost 200 - 300 dollars plus additional hardware like patch panel and other rj cables for connecting this panel to arduino (s)
That seems like a lot of money for Cat6 FTP unless you are referring to S/FTP or non US $
Have you ever made up patch leads before?
Using normal Cat5e/6 is a big enough pain in the arse, anything shielded is a pig to work with especially S/FTP if you don’t get the shielding terminated in the connectors correctly there is no point in using shield wire at all.
Unfortunately it seems that using more than one Arduino is impossible because in configuration.yaml you can use only one “arduino:” entrance
Maybe I am able to copy arduino.py file and hard coded Home Assistant core (add arduino2.py and use this in configuration.yaml) but after update I will have crash or other kind of problems.
Is there a way to add more arduinos in configuration.yaml?
I was not made patches yet. This should be my first attempt…
How are you configuring them?
If you are doing the following that’s why it’s complaing:
arduino: port: /dev/ttyACM0 arduino: port: /dev/ttyACM1
Try this instead
arduino: port: /dev/ttyACM0 port: /dev/ttyACM1
Why don’t you use I2C IO expanders?
Such as the MCP23017
Or for ADC
I’ve tried this way and this gave me no error
but in switches I can use only one platform Arduino:(example below)
- platform: arduino
name: Arduino PIN11
name: Arduino PIN12
name: Arduino PIN13 - Led
#Arduino MEGA clone
doesn’t work (only the first switch is shown)
for expanders I2C IO
I need to read about them. I’m still new this is my first Home Automation implementation and I would like to learn as much as I can and choose the best way to create my HA experience…
Have you also tried
arduino: port: /dev/ttyUSB0 port: /dev/ttyUSB1
which is mentioned in the docs?
Also have you confirmed the second one is ttyACM1?
Try deleting ttyACM0 from your config, can you then see ttACM1 ok?
Before spending too much money on Arduino or cabling parts I would start off simple and make a test rig. I would still recomend having a look into the Sonoff-Tasmota firmware all you need to install is Mosquitto and setup WiFi and it is pretty much set and forget after that.
Thanks for your patience and time.
I made a test and put in configuration.yaml my second Arduino only
arduino: port: /dev/ttyACM1
and works (Led blinks in Port 13 after switching on). That means that my first and second Arduinos are connected ok.
When I try to use
arduino: port: /dev/ttyACM0 port: /dev/ttyACM1
I get only a switch for first connected Arduino…
… and using Configurator an error shown
- When I conncect using Putty (“dmesg” command) i see ATM0 and ATM1 so there is no connection error.
For sonoff Tasmota - I have one configured myself couple of days ago and it work flawless using MQTT. This is a good method, but I still would like to have everything wired and controlled by Rpi / Arduinos because this way I can avoid problems like password change issue / sonoff crash / wifi signal problems / new software update errors / security issues. When I use method with FTP’s I don’t need to deal with so much problems that can occurs during some years of using HA, plus maintain standard installation up and running even when something bad happen.
I appreciate your wish to avoid wifi and envy your ability to wire your home from scatch.
Another approach perhaps: set up each arduino with an ethernet shield and get it communicate with home assistant via mqtt.
Thanks nickrout, I don’t have experience with shields but I think it will be not so easy to control Pin inside Shield using Home Assistant (MQTT will work but setup will be hard).
I will try to create some custom components like arduino2.py today. Maybe this helps.
I also created a topic in future requests (More than one Arduino board).
If nothing works - maybe I will wire my lightning only (24 pins will be enough) and control the rest of sensors using Sonoff or Shelly over MQTT,