Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


mlew980

8 posts

Wannabe Geek


#229048 5-Feb-2018 10:58
Send private message

So I'm attempting on creating an irrigation system at home using an Arduino with Wireless + Solenoid valve and a few sensors. I wanted to create a small db to stores sensor data. The data would record at 1 min intervals so it wouldn't need to be a grunty server. My main question is, what would be the most cost effective, low power, small factor database server. I was thinking of using a Raspberry PI running Raspbian connected to a 1TB external HDD which would be under < $200, alternatively I could go for something more scale-able and get a small Celeron/i3 Intel NUC. Has anyone had a similar project/dilemma?


Filter this topic showing only the reply marked as answer Create new topic
jnimmo
1098 posts

Uber Geek
+1 received by user: 255


  #1951881 5-Feb-2018 11:12
Send private message

How long a history do you want to keep?

 

You could look at using Home Assistant on a Raspberry Pi, log to it using MQTT

 

Alternatively, various ways of getting the Arduino to log directly to a cloud based MQTT broker  (or something like ThingSpeak)




mlew980

8 posts

Wannabe Geek


  #1951887 5-Feb-2018 11:20
Send private message

I was actually thinking of connecting my Arduino to my wireless network (same with the db server) then using this library to connect to the MySQL server.

 

https://www.arduinolibraries.info/libraries/my-sql-connector-arduino


SumnerBoy
2079 posts

Uber Geek
+1 received by user: 306

ID Verified
Lifetime subscriber

  #1951889 5-Feb-2018 11:25
Send private message

+1 for MQTT. Probably not the simplest solution, but would be the most flexible IMHO. Your Arduinos can easily publish to a local MQTT broker (there are plenty of guides/tutorials about how to do this). Then once you have the data coming into your broker, which can happily run on a RPi, you have all sorts of options.

 

Personally I would run mqttwarn (https://github.com/jpmens/mqttwarn) which is a simple python script which will monitor MQTT topics and forward the messages onto different services. There are loads of options including multiple database options, even Google Docs Spreadsheet. 

 

Using this sort of architecture you can easily change the way you log your data without having to touch your Arduinos. 

 

Personally I run InfluxDB which is a database designed specifically for time series data, so is very efficient at storing regular (i.e. sensor) data. Not sure if it runs on a RPi tho, it didn't used to but that was a while ago.




mlew980

8 posts

Wannabe Geek


  #1951893 5-Feb-2018 11:35
Send private message

Looking further into your solutions, maybe it'll be more hassle free implementing an MQTT broker on the PI (using Mosquito) and then using mqttwarn to forward the data onto an InfluxDB rather than fiddling with the MySQL lib. The GitHub repo you mentioned has some superb instructions which should make configuring it a piece of cake. Now I guess it's time to look for a unwanted Pi


SumnerBoy
2079 posts

Uber Geek
+1 received by user: 306

ID Verified
Lifetime subscriber

  #1951895 5-Feb-2018 11:39
Send private message

I might be able to help you with that ;). I have a couple of RPi2s which have just become free, you are welcome to one of them for the cost of shipping if you are interested?


davidcole
6099 posts

Uber Geek
+1 received by user: 1465

Trusted

  #1951953 5-Feb-2018 12:13
Send private message

I'd be using influxdb as well (if for at home).  Another option is to use the http api on thingspeak and push your values there.





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


 
 
 

Shop now at Mighty Ape (affiliate link).
Masterpiece
247 posts

Master Geek
+1 received by user: 37


  #1953359 7-Feb-2018 22:39
Send private message

For what it is worth, In one of my lives, I build datalogging, control systems and environmental monitoring networks.
A couple of these are rainfall simulation with 200 nozzles, 32 valves and 48 relays.

The main problem for new players to this sort of thing is they focus on the end goal, "I want to see the data", and not on the basic operation and control.
My home system it has 4 zones, I purchased a off the shelf 4 way solenoid system and controller, why? Because running complicated systems that are automatic still require input, and if you don't keep an eye it when it breaks(and it will) you end up with a watery mess.

Concentrate on the irrigating system allowing for expansion, I'd even go so far to say start with an off the shelf system to work out what works for you and what doesn't. They are pretty limited, and frankly annoying when compared to advanced control systems however you learn what and how with them. Or if you are going Arduino get the control working first. Doing this allows you to understand what and how you want to record.

Data, everyone wants 1 minute data. Sounds fine, but I tell you now from someone who collects data for research, 1 minute period is really only good for short high resolution information because high resolution bogs databases files down, then retrieval can get just as bad. Noting that control at 1 minute intervals is a perfect period, but data for what is happening is perfect at 15 minute, hourly and daily. 15 minute works well, but even then you can get bogged down with data handling. I typically use daily and hourly these days, which bring me to a data handling problem.

Time stamps, one main problem for you to understand early is the time stamp. Daily time the value 12 midnight or 24 hours actually does not exist, neither does the top of an hour as this becomes the next hour, or for the day the next day.
What?? you say, just consider the time clock for a day is 0 to 23:59:59.9999, what does this mean?
Consider, Day 1, if you collect data for the day to take a total daily rain or irrigation volume, so at the end of the day output this total and midnight. This outputs Day 1 as Day 2 time stamp because midnight is zero which is the next day.
How you handle this is your choice, there is a few methods, just be aware of it when data doesn't appear to plot on the right day or hour as you expect.





Me:"I'm not a robot!"

 

ET: "Maybe; you have some freewill, but you chose your path by arrangement"

 

Me "That sounds like a program with no freewill?"

 

ET: "We will catch up when you end this cycle"

 

Me: "Sounds like a 'KPI'!"

 

ET: "Did you read the terms and conditions?"

 

Me: .....

bazzer
3438 posts

Uber Geek
+1 received by user: 267

Trusted

  #1953368 7-Feb-2018 22:58
Send private message

SumnerBoy:

 

I might be able to help you with that ;). I have a couple of RPi2s which have just become free, you are welcome to one of them for the cost of shipping if you are interested?

 

 

What were you planning to do with the other one? :D


SumnerBoy
2079 posts

Uber Geek
+1 received by user: 306

ID Verified
Lifetime subscriber

  #1953369 7-Feb-2018 23:00
Send private message

Planning to give it away, to someone worthy...

TwoSeven
1712 posts

Uber Geek
+1 received by user: 304

Subscriber

  #1953792 8-Feb-2018 18:39
Send private message


I would probably just write the data into a text file in csv format, then create a new file every day. The old files can be added to an archive to save space.





Software Engineer
   (the practice of real science, engineering and management)
A.I.  (Automation rebranded)
Gender Neutral
   (a person who believes in equality and who does not believe in/use stereotypes. Examples such as gender, binary, nonbinary, male/female etc.)

 

 ...they/their/them...


Filter this topic showing only the reply marked as answer Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.