Kick off information for a newbie

Hello all,
Not sure I m in the right place but I will give a try.
I m looking to a solution to monitor 5 sensors reporting high low 24V signal.
I need to create a log of the 5 sensor to know what are they level with date and time stamp.
Is this possible with Arduino?
If yes what hardware should I look for?
Thanks for your help on the subject.

Welcome to the forum

Your topic has been moved to the Project Guidance category of the forum as it is more appropriate for your question

Yes, what you describe is possible to implement using an Arduino. What do you want to log the data to ? An SD card, perhaps, or a database of some kind ?

Thank you so much for responding so quickly !! you are my early santa claus :slight_smile:
Not really important, most easy will be the choice. I just need to be able to collect the data when needed. no need to have real time access to it.

It sounds like an SD card will fit the bill to record the data as long as it is accessible. Will the voltages be recorded at fixed intervals or only when they turn on or off ? How accurate does the time need to be and over what period will the data be recorded ?

Depending on your requirements in this area will determine whether you need to incorporate a Real Time Clock (RTC) in your project

I was not knowing that we could only record state change but this will be the prefered method.
Time need to be accurates at the minute level and the recording could need up to few weeks

It sounds like an RTC would be required.

If the data were to be recorded at regular intervals then the state of all 5 of the sensors would be recorded at the same time, perhaps in a Comma Separated Value (CSV) format.

However, if the data were only recorded on a change then presumably only that change and its time would be recorded. That might make analysis of the data more difficult. Do you have any ideas what should be recorded and in what format if on change logging were to be used ? Maybe a separate file for each input

All of what I am describing is possible using an Arduino, but there does need to be a specification of what is required

Since I m new I don t have the knowledge of the implication of such a choice.
I just need to know witch of the five has a change in state a certain time.
what solution is the most easy will be OK.
to have all sensor on a single file with time stamp and the state of each sensor in CSV would be fine.
One more requirement, the change of state can last only few seconds, would a such system would be ok to capture this or if check interval is too long it will miss it?

You can record whatever you want
state-change
or
state itself at pretty short intervals like 10 times per second.

Yes I second that. You should give an overview what the final purpose of these 24V signals is:
This will make it much easier to decide if it is sufficient to use an internal clock that will deviate from realtime for approx 2 to 120 seconds each day
or
if it is nescessary to use a real-time-clock module that will be accurate to the second over months

Same for how to record the data. It might be sufficient to just write a time-stamp each time a state changes it might be nescessary to record all 5 signals in a single file in a regular interval of 10 seconds or 30 seconds or 1 minute or once every 10 minutes of whatever interval you want.

It is possible to store this data on an SD-card as a textfile with CSV-formatting
comma separated values. Which can be very easily imported into spreadsheet software and ther ebe visualised in diagramms

best regards Stefan

The purpose of this is to check 5 interlocks state every 5 sec to know witch one is actually triggering an error. The probleme is right now any of those 5 interlocks would trigger the exact same error. I m trying to find a way to determine witch one is faulty.
So since the error are pretty rare I don t need the time to be very accurate. But the interlock state change can be very short so I need to check the 5 sensor on pretty high frequency (1 to 5 second I guess). the probleme is I don t really know what are the size of the file implication on a few weeks logging period and the hardware memory limitation.
Again thanks to all the people of this forum for your help! It s really appreciated.

Written properly the program will be monitoring state changes millions of times per second

The simplest data output format would be single CSV file with a row of state data for all of the inputs added to the file every time any of them changes.

Analysis of the data could then be done using Excel or another spreadsheet

That would be exactly my need.

An Arduino with a suitable program can do what you want with just an RTC added for accurate timekeeping and voltage dividers to drop the 24V to a level that the Arduino can handle. Arduino boards are easy to use for prototyping using a breadboard and jumper wires but if this is a serious industrial installation that is not a suitable method of interconnecting the components and a printed circuit board (PCB) or a matrix board onto which the components are permanently mounted should be considered. A power supply will also be needed but the requirements for this project are modes and 5V at 2A would be more than adequate

What are your programming and electronic skills like ?

Electronics wise is not an issue.
For the programming part, I have knowledge in C++ and also SQL scripting. But I m willing to learn for this project.
Matrix Bd would be my first choice.

So, a solution might involve the following process. We won't write your code (though, someone might throw in a ready-to-hand example they've got, or written, for you to model yours on).
You will need to find/buy an Uno, RTC, and an SD card, as well as some form of interface hardware to bring in your 24V signals. I'd recommend something with optical isolation, so you're not connecting your Arduino directly to your process power.

While waiting for hardware to arrive,
Learning:

  • Go look at blink without delay examples/tutorials, for a leg up on an important coding practices

  • Think about your needs. Easiest to change/add features when it's a few words on paper...

  • draw yourself a schematic. You'll need to do that if you want anyone here to help with debugging it, and besides, you'll want it 'down the road', so do it now. Pen on paper will do. You can show just one input example, and a table of pins representing the others. Show all your power connections, Arduino and other pin names, etc. Thorough is best.
    When you want to post it here, take a picture.

  • Learn about Wokwi - it's a most useful tool for developing at the level you'll need for this project. I've now done two projects of a similar level of complexity for others, and it turned out very well as a collaborative tool. (Those examples are, unfortunately, the property of their respective owners, so I won't post a link to either.)

Coding:
In Setup

  • initialize inputs
  • initialize Serial Monitor, for debugging*
  • initialize RTC*
  • initialize SD card(put this in later, when you have your chosen hardware)

In Loop

  • utilize what you've learned in BWOD to set up a loop that simply
    • monitors your inputs,
    • watches for a change of state
      • gets the time
      • sends a status string to Serial Monitor when any input changes.
        (make sure that string contains exactly what you want to see in the SD output)
    • and returns to monitoring
    • Serial monitor is an incredibly useful tool, once you get used to it's quirks. You can not only send information to your PC, you can trigger changes in your code based on keyboard input, which makes debugging easier.

That should do it.

Then use interrupts to detect when and error occurs. No need to constantly check all the states all the time. A 1Gbyte SD card could store years of data.

Hardware wise, an Adafruit Feather and a Feather Datalogger will suit the bill for recording data. You'll probably want a few optoisolators for your 24V signal and of course, a power source. That's about it. A Feather Datalogger fits in a small 1.x2.5" box like this:
https://www.cedarlakeinstruments.com/contact/recent-work#DataLogger

Thank you so much on all your input!
This sounds like a nice start for my project.
One more question, interface hardware to bring the 24V signal: is this a arduino module or a complet separate device?

Something like this should work:
https://www.amazon.com/24V-Optocoupler-Voltage-Level-Converter/dp/B06XKSFGXX/?th=1

So many of these cheap I/O boards have poor documentation so it's not always clear what they do. I'm really surprised that the majors like Sparkfun and Adafruit haven't come out with a simple multi channel high voltage -> logic level converter board after all this time.

If you are using an UNO then connect INT to pins 2 or 3
Connect D1, D2, D3, D4, D5 to any of the Digital I/O pins except 0 and 1
Anytime one of the five Sn inputs goes from 0V to 24V, INT will go HIGH and cause an interrupt.
Now you need to learn about interrupts.

@fd13

what do you think will be the minimum time length of the shortest fault?

0,5 seconds?
0,01 seconds?
0,001 seconds?

if the shortest fault endures longer than 0,5 seconds interrupts can be used but me personal I would not recommend it as interrupts add a new level of complexity to the project.

best regards Stefan