Sensors spread over three houses => several RPIs, Can I still use one MariaDB on NAS for all installations?

I have three Raspberry PIs connected to 1-wire sensors in three houses on the same network. I intend to install HA on all of them. Can I let them all store sensor data on the same MariaDB on my Synology NAS?

I have understood that I can use the DB on my NAS as DB. What I have not figured out if there will be a problem to let all PIs connect and store data on the same DB.

The reason I would like to do this is to be able to use Grafana to present all sensors.

Or, is there a better way to do this which I have not understood?

/Niklas

For grafana, you would want to use influxdb. Influx is much more efficient at storing long term data (like 5mb or so per day) and it works well with grafana. You would still want to use mariadb in parallel for short term ha purposes (state persistence across reboots, lovelace history and logbook, etc… expect about 100mb per day with mariadb). Both dbs can be stored remotely on your network with relative ease. The typical use case is having a nas with both influx and maria, and direct all your ha instances to use it for storage. If a nas is overkill, with the new usb boot ability you can even run the dbs on one of the pis reliably using an ssd.

Why?

Why would you want to manage multiple instances of HA when you don’t have to?

Guessing because the 1 wire sensors… probably using gpio or similar so need a way to get those on the network (presumably all 3 homes connect to one central wifi router) to a pi if you just have one. I agree managing 3 instances doesn’t sound fun though. I personally would be looking into using esp8266 devices programmed to feed states to one pi via mqtt. That would be much easier to manage long term, and perhaps not much more work up front as well. I’m sure there are over the counter solutions along the same lines (I’m a maker type so have extra esp8266’s and stuff). I just mentioned esp, since they can be easily integrated with one wire sensors (now is that dallas 1-wire, or other? …curious).

Agreed.
I’m a firm believer in the power of the ESP

Thanks for all the comments!

Using InfluxDB sounds interesting due to what is described above. It does not seem to run directly on the NAS I have so I need to consider what to do.

Well, I do have sensors in three houses which I would like to have stored in the same DB to be able to visulize and examine them later.
Using mqtt from some PIs to the PI where I install HA sounds like a way forward.

There are plenty of sample scripts around to grab the data from a one wire sensor via python and publish that via mqtt. That may remove your need for multiple instances of HA.

I can provide you with a temperature sample if that helps.

I would really appreciate a code example it the need to have several HA installed would of course decrease.
Thanks!

Is this 3 homes on one wireless network? If so, adding 2 esps would be the simplest solution. The esp’s would be in the 2 homes that don’t house the router, and communicate data to ha through the router (the one pi can be wifi or wired to router, preferably wired). If you haven’t used esp’s before, there is a bit of a learning curve in coding and soldering to get it going… though there are plenty of step by step guides to follow.

The three PIs are connected via wired network today.
Do you propose that I get rid of the PIs and replace them with wireless ESPs? Or, do I completely misunderstand you?

I am pretty sure that’s the one I used.

1 Like

I would. ESPs are cheaper and you don’t waste SDCards and have an entire OS just to run some sensors.

What flamingm0e said, yes I think setting up so you only have one pi and ha instance is best (cheaper, simpler, easier to maintain, etc…). You would then have 2 spare pi’s that you could do some other cool stuff with (like a pihole whole network ad blocker, for example).

To be clear about your current setup: you have a wired LAN between homes, each home has it’s own pi, each home has a separate network of 1-wire sensors that connect to it’s own pi. Correct? does the network router have wifi capabilities? Would said wifi be strong enough across all 3 homes?

If yes to all 3, then yes I think replacing 2 of those pi’s with esp modules would be a better route. If no on q’s 2 or 3, esp’s won’t be the way to go… in this case I’d use an arduino unos with an ethernet adapters instead (keep it all wired as is, but much simpler with 1 ha/pi). The reason to prefer the wifi+esp method is it’s cheaper than most LAN capable embedded stuff (like a wemos d1 mini can be had for third the price of an ethernet shield + UNO).

Cool!

I say yes to all three questions you ask. I have my attention now with esp’s.
What do I need then? I looked in the web shops I usually buy stuff in for home automation and I see plenty of esp’s but I don’t really understand which one to buy. I would like to just disconnect the PI and replace it with another hw which I can program to read the sensors and send them via MQTT to my HA instance. What are the keywords for the esp I should look for?

Wemos D1 Mini would be perfect for a single onewire sensor, and can be purchased at a few dollars each.

You then have a number of options about how to get that data into HA.
Either write “arduino code” using Arduino IDE yourself.
Use esphome or one of the other equivalents (platform.io etc)

Personally i have a mixure of all of them, based on what was most fit for purpose!

Thanks!

For two of my PIs I have several sensors connected, both temperature and humidity. I saw a Wemos D1 mini Pro v2.0.0. Can that one handle several sensors or do I need something more advanced

A normal Wemos D1 Mini can handle several sensors. There is no reason to go after “pro” anything.

1 Like

I second what flamingm0e said… just a run of the mill d1 mini is perfect. Now there are some different flavors of d1 mini’s out there. You might prevent some headaches if you choose one that uses a “12f” or “12e” chip. The f is similar in performance to the e, but the f has the fcc stamp of approval. Older versions (lower than e) are going to have reduced wifi efficiency. They typically come in packs of X… get a couple extra for spares and rainy days (I enjoy spendig free time developing haunting halloween stuff, and esp’s are very useful there).

Other than the wemos d1 mini board, all you’ll really need is a 5V usb supply to power it (you can use your pi supply, but it’s way overkill… d1 needs no more than 1A) and some code to run on it. The code is relatively easy to do with all the libraries available; the onewire lib will make the sensors easy, and the arduinojson library makes it easy to format your data to work well with HA mqtt. You may also want to include OTA firmware upgrade ability; I like to use the secure http updater method… I send an OTA message to trigger ota mode on the device, then use a browser to upload new firmware. The code simplifies the operation by returning the exact OTA url in a message after ota is enabled.

Here is an example code for a few devices in my home. It does more than you need (it also has DHT, PIR, and beeper features), but it should help if you get stuck and possibly offer some insights for future projects :wink: :

1 Like

Hi again!
Now I have received a few Wemos D1 Mini 12f. I think it was $4 each. Quite ok.

I think the programming is ok for me but I really don’t understand the HW parts. I realized that I should have ordered a few 4k7 which I lack.
I see the pin layout in the link provided but I feel like a coward; do I really understand it correct?
Do you have a photo of how it looks like?

LOL, well it’s a good thing you were being a coward, because that pin list on my github is meant for a bare esp12 module (wemos d1 mini doesn’t need all of that). You may have read about esp8266 bootmodes and how they depend on pin state(s). Those additional 4k7 resistors are spec’d in order to enable a bare esp module to bootup for normal operation. That’s why we suggested you get a wemos d1 mini… it already has all the needed resistors, and even goes a step further and it has 2 buttons for reset and flash-mode. This makes the D1 mini ideal for beginners… experts even like 'em for certain situations (bare esp is better left for battery powered stuff where the D1 regulator quiescent is too much, and other more custom circuit/codes that require access to the bootmode pins… for example I have a PIR that lasts 3yrs on an 18650. This requires an LDO with very low Iq, and a custom circuit that manipulates CH_PD).

So all you really would have to do to play with my code is flash it, and probably plug in the sensors to the pins as stated on the table (been a while, but the code likely has some error checking built in where it may not operate normally without all the sensors wired up).

[edit: Please post if you need more assistance. Also regarding code, I just started playing with esphome (just added 4 new nodes over the weekend) and have to admit it’s a ton easier/faster to get esp modules talking to HA vs manual coding. You should have a look, esphome has board definitions for the d1 mini… also has OTA, and what I like most is compiling/upload is built in to HA with just some small bit of yaml to configure each device. If you go this route, for now use the dev branch, because the current release (1.14.x) is broken (so add
“esphome_version”: “dev” to your addon config). Esphome should be adequate for most applications since they have a big pallette of sensor drivers to choose from, and decent docs on how to setup. Of course, nothing can replace the power and flexibility of hard C code, but if you just need some DHT’s spread around to report to HA, why bother when you can just click a bit on esphome? ;D]

1 Like