Programming a sketch to accept activation codes

OK I have a device I want to activate via a relay (120vac). The device is used Mon thru Saturdays during the year.

I want to add a nuneric keypad to a Nano and have it control access to the relay. Only a certain code will activate the relay from 6am to 7pm for that day.

Im trying to envision the process. I was thinking I could generate 365 unique codes such that they are hard coded into the nano. The codes will be used, 1 per day, to activate the machine. I'll need a timer of course to keep track of time such that the the relay, once activates during that day, can remain active for the remainder of the day in case the device gets unplugged and replugged.

There are some issues there but for now I want to think of the idea of hard coding "codes" into a sketch. They would be numeric only since the user can only input numbers thru the numeric keypad. I guess they could be made unique enough if I use, say, 8 digits.

So I would store the 365 8-digit codes in the nano memory.

Your comments up to this point would be appreciated.

Then I would move on to powering the unit and coding the "activation code" duration based on time and date from the timer.

Thanks in advance

OK I found this on the forums right here. I've never sed one and I'm not entirely clear how it works but I understand it's a function that takes a date and processes it in a way that it gives you a code or takes a code and gives you the date, right?

However I would need one that only produces 8 digit results. And definitely no letters allowed, nor symbols.

https://forum.arduino.cc/index.php?topic=226686.0

Third might seem like overkill

Yeah I did think that would be easier. Thanks

ok, before i go on, im drawing up the sketch and i realize the user will enter a code which i gave him in order to input it and validate it. Lets say for the first day of the year, 01012020, i could give him 12123131. So he enters the code, the sketch reads the day from the timer unit, it then adds 1 to each digit and if it matches the entered code, it validates, right?!

Delta_G:
Something like that, except that if it is that simple it won't take long for someone to realize how to figure out their own code. You gotta make it look random enough that people can't put it together easily.

Why? The authorized user of the codes must have all 365 of them handed to them on a sheet of paper. Or is this 365 different people?

It seems strange to have a lock that stays unlocked for a whole day. I'm waiting to find out more.

Marciokoko:
Only a certain code will activate the relay from 6am to 7pm for that day.

Never mind, for a moment, how you would implement the code within your Arduino. Start by considering how the user can operate a system like this without making mistakes.

Unless you want to be able to input the permission for Friday on the the previous Tuesday (for example) I don't see why each day needs a different code.

I suspect there are important aspects of your proposed system that you have not yet told us. Full disclosure makes it much easier to give useful advice.

...R

Ok aure. It's a vacuum cleaner for a company that provides cleaning services to clients. The employees carry the equipment with them and even take it home but the owner doesn't want the employees using the vacuum for other jobs that are not the legitimate ones.

Marciokoko:
Lets say for the first day of the year, 01012020, i could give him 12123131. So he enters the code, the sketch reads the day from the timer unit, it then adds 1 to each digit and if it matches the entered code, it validates, right?!

As noted, say the “user” gets a code for the next day as well.
So now he has
12123131 and 12133131 by time they “buy” the 3 code, it will be very obvious they won’t need to “buy” codes anymore.

Without going into vastly more complicated methods, one way could be to have a “seed” value, multiply it by the date value, then only used a portion of the result as the “code”.
It would be non-intuitive to decipher and simple to implement.

Marciokoko:
...The device is used Mon thru Saturdays during the year.

...Only a certain code will activate the relay from 6am to 7pm for that day.

If it is only to be used from 6AM - 7PM, what's that got to do with a unique code? Just make the device not work outside of hours. I don't really understand why one needs a code at all if it's the hours of operation that is being controlled.

Marciokoko:
...It's a vacuum cleaner for a company that provides cleaning services to clients. The employees carry the equipment with them and even take it home but the owner doesn't want the employees using the vacuum for other jobs that are not the legitimate ones.

Is it required that the vacuum only works Mon - Sat; 6AM - 7PM?

Is the only requirement that employees are detered from using the vacuum outside of legitimate jobs for the owner of the vacuum?

If the second is the only requirement, I would instead of preventing the vacuum from turning on, I would give each employee an ID number and track the usage of the vacuum by who is using it and when.

Then you tell the employees that the vacuum is monitored by their ID and when it is being used and they are not to use it outside of work hours.

Or rent the machine to the cleaners. They get paid $20 per hour to do authorized jobs but they pay back $10 per hour that the machine logs as usage. If they want to charge their friends $15 per hour for off-the-books jobs then they still pay $10 to the owner of the machine.

Very quickly the customers and employees will work out that it is in their best interest to convert those unauthorized jobs into authorized, if you set the prices right.

What about a device that has to be attached to the vacuum cleaner to enable the machine to work. Each device (and vacuum) has a unique code. The device controls the times and dates at which the machine can operate based on data that was input by the employer. At the end of each week the device must be returned to the employer who resets the device for the next usage period.

To be honest I don't like this "big brother is watching" stuff. If the employer pays his staff properly they won't be moonlighting.

...R

Robin2:
...
To be honest I don't like this "big brother is watching" stuff. If the employer pays his staff properly they won't be moonlighting.

Yes, I do see that limiting the actual time that the vacuum can be powered on feel less intrusive than an "honor system" with my computer logging all your actions.

I was also thinking about it from the perspective of IOT and that you just have authorized users and the server would determine if the user is authorized at time X, but that complicates the system more than what the OP has proposed.

It seems more of a needs a key to start the car type of problem. Again, if all the problem is that the vacuum can operate Mon - Sat 6AM - 7PM: No codes necessary, just kill the relay outside hours. What keeps employees from passing out codes if there is a code for that day?

hey guys thanks for all the great feedback. I understand a lot of the doubts that you have about this set up but it’s interesting because I believe it has a lot to do with the difference in cultures between our countries. I had actually suggested to the owner of this company that he should instead add the logging functionality in order to be able to monitor his employees instead of the restrictive methodology. However he appears to favor the restrictive methodology over the monitoring one but I did not suggest the possibility of extra income which might be incentive enough for him to actually change his mind. So this is definitely something that I will be taking up with him.

Asked to a lot of the details of how his restriction will fit into the day-to-day operations I am not entirely sure. I have just recently started talks with him and the brief description of what he wants was simply to make the machines operate from 6 to 7 during work days which in my country includes Saturdays. I do not know if different employees use the same machines however I doubt it. as I get more information from him I will try to clear up what these peculiarities are. Again thank you for the comments and I will post back soon.