Check if electrical switch is working during 5000 on and off cycles

Hello everyone, i am very new to the concept of ardruino board and hoping someone could give me insight to the task at hand.

I wanted to do a task as follows,

For an one way electrical switch if i can turn it on and off (Giving power supply to it) with the help of a pneumatic piston (with the help of an switch tester instrument), How can i just take the reading from the switch during each on and off cycle and also keep track of each cycle via the data logger board.

Also if there is a defect in switching the switch, like its in On condition but no supply goes through, can Arduino record that as well and still continue with the set number of cycles.

I know the task seems small but i would really would like to find out more on this.

Your post was MOVED to its current location as it is more suitable.

No problem so far, you can monitor the on/off state e.g. using an optocoupler. For the code see BlinkWithoutDelay example.

A bit harder to monitor the performance of the piston.

Hi DrDiettrich,

Thanks for the reply, actually in simple terms i wanted to carry out these functions when the instrument is running,

  1. to keep data log of the number of cycles done (One On and OFF as 1 cycle)
  2. record errors if the Light switch is in ON condition and no supply passes through it.

What have you tried so far?

Well at the moment its just a thought if I could figure out to get the datalog via an arduino board.
Also since i new to this i wanted to know if Arduino Uno could be used in this.

Hoping to hear your thoughts on this.

Yes. See Serial.print() for the log.

How to record only the errors if the switch is in ON position and no signal is obtained?

Use an if statement.

I know it sounds silly but can you help me write the code,

I might be super easy for you but i am a newbie to Arduino, can you help me out.

Did you start the design of the sketch already?
if yes, than post your current edition.

Hi Paulpaulson,

to be frank i have no idea regarding the coding part

Well, I think in this case you may drop your request here:

Have a nice day and enjoy coding in C++.

1 Like

Whether you or someone else writes the sketch more details are needed, for instance what is the voltage being switched, what exactly is the data logger that you refer to and is the Arduino required to activate whatever controls the pneumatic piston ?

1 Like

loop thusly

initiate or see piston starting
wait for piston

read the switch under test

if failure, print the test number and say so.

count one more test done

if not 5000 (?) tests, repeat

One the PC side, you could use a better serial monitor. I like CoolTerm, def not overpriced at free.

A good terminal program can be set up to dump all traffic into a text file. You could use millis() or overkill it with a RTC module for time stamping each failed test.

That text file could then be used for any subsequent processing.

Code writes itself. Take a look at a few simple examples available in the IDE and see if you can muddle your way to anything yourself.


1 Like

The voltage could range since i am supplying an external power supply, since most used is 120v, that what i would set.

The term data logger i used was the data logger sheild i saw as an accessory for the Ardruino Uno.

Ardruino would just need to handle the sitch only since the pneumatic piston is operated by another instrument.

Easy to read the switch. But the Arduino must somehow be informed that the piston is activated or up or down or whatever.

Can you get a signal from the external equipment that you can exploit for determining the piston activity?

A data logger shield would be nice, add it after you do it quickly just using a PC terminal program. You may find you never get the time or energy to fuss with a data logger shield &c.

If you do have your heart set on using an SD card on a little device, just get an " Openlog Serial Data Logger Open Source Data Recorder" and wire it to the serial output pin. Done and done.



for the piston activation it is done via Digital Counter / Timer / Tachometer
CTT Series from automation [link removed] I think i can take the signal from there.

@ajaymohan1990 I have removed the link from your post as it had no connection to the subject of this topic

Why did you post the link ?

Maybe since they are going to try to get a signal from it to inform the operation of the Arduino program that will monitor and record the tests the thought was we’d all like to take a look at whatever it is.

Anticipating the inevitable what sensor? post your code! draw a schematic not a Fritzthing! posts that usually come when we are getting up to speed a half a fact at a time.