wifi access control using arduino

Hi guys

I am trying to make the arduino control wifi user access.

The idea is:

The user enters a coin in the coin acceptor connected to arduino
The arduino then generate an access token using certain and display it on a screen

The user connects to the wifi router, a webpage opens and ask for an access token

The user enters the access token in the access webpage

Then the router sends the code to the arduino and check if its valid or not
If valid, the gets limited access to the internet (limited amount of data or limited access time)

And when the time, or data is consumed, the user will be asked again to access new token

This is the idea of my project but i need guidance about how to do it

Hi, morheb and welcome!

What you are describing with WiFi is the same technique used at hotels to trap you until you enter your name/room number or provide a CreditCard for WiFi payment.

The technique is called captive portal and essentially traps ones in a DNS sandbox until the user performs some magic authentication. Then, the lock is released and the real DNS lookup can occur.

I have an ESP8266 project that explains a bit more of how all of this works in code.

https://www.hackster.io/rayburne/esp8266-captive-portal-5798ff

Ray

Thank you so much for replying
You gave me hope again :slight_smile:

So from what i know i should buy an ESP8266 and it can do it for me?

When the user enters a coin he gets a code generated using an algorithm on the arduino

And then he enters it in the webpage for limited access, and after that the code will be unusable?
the ESP8266 is programmable on an algorithm that i choose to be able to decide which code is correct and unused before?

I am trying not to be a total noob but i have been searching for the last 2 days and its a bit hard to concentrate now

morheb:
<...>
So from what i know i should buy an ESP8266 and it can do it for me?

I am trying not to be a total noob but i have been searching for the last 2 days and its a bit hard to concentrate now

The ESP8266 is quiet a bit different from the UNO family, more like the Due in architecture, 32-bit and 3.3Volts.

The ESP8266 WiFi Ethernet library is similar to the Arduino WiFi shield library in functionary. So, I see no reason a Due and WiFi shield could not be used if you are more comfortable with that hardware.
https://www.arduino.cc/en/Main/ArduinoWiFiShield

Arduino Due compatible
Connection via: 802.11b/g networks
Encryption types: WEP and WPA2 Personal
Connection with Arduino on SPI port
on-board micro SD slot
ICSP headers
FTDI connection for serial debugging of WiFi shield
Mini-USB for updating WiFi shield firmware

You must be comfortable with your choice.

The ESP8266 is incredibly cheap, under $4 direct or under $10 from Adafruit as the Huzzah.

Ray

I know the ESP8266 is cheap but isn't this a project more suited to a Raspberry PI or even a cheap laptop?

...R

Robin2:
I know the ESP8266 is cheap but isn't this a project more suited to a Raspberry PI or even a cheap laptop?

...R

Robin,
It could be nicely accomplished on a Raspberry or a laptop or even some advanced scripting on OpenWRT.

But, since the ESP8266 can act as a WiFi client/server/AP and since the ESP8266 can host a Captive Portal, then I do not see why it could not be done on the ESP8266. Now, I personally have only concocted the Captive Portal code and that works.... but is less than half of the complete solution. The ESP8266 would need to host a sandboxed webpage (accomplished) and would need to reroute the connected client outside the sandbox when some analyzed token is input... this has not been tested... and obvious is critical to the project.

The rPi project is available online for the Op to consider: HERE

Thanks for bringing up that option ... I should have considered it in my response initially.

Ray

mrburnette:
Thanks for bringing up that option ... I should have considered it in my response initially.

I'm just lazy. It seems to me far easier to program an RPi or a PC :slight_smile:

...R

Robin2:
I'm just lazy. It seems to me far easier to program an RPi or a PC :slight_smile:

...R

I suspect that the magic is to know what one is looking for, say "captive portal" and then find a working example for the selected platform. I'm not an R-Pi'er but maybe I'll ask the wife for one as a holiday gift. But, I do not know when I would find to play around with it... I'm having a blast with STM32 and ESP8266 ... There is only so much time available, even for a retired person. And I want to do FPGA before I get too old to see the LCD monitor :o PSoC really wetted my appetite for reconfigurable logic elements.

Ray

Thanks again sir

I will buy ESP8266 and try it

Just let me make sure of something
Do i have to use uno or just the ESP or does the esp need another type or arduino?

And i can program it using c to release the user on after doing algorithm on the code entered, right?

One last thing to make sure i understand
It broadcast wifi and needs Ethernet shield to get the connection from a router? How many users can it handle?

morheb:
Thanks again sir

I will buy ESP8266 and try it

Just let me make sure of something
Do i have to use uno or just the ESP or does the esp need another type or arduino?

And i can program it using c to release the user on after doing algorithm on the code entered, right?

One last thing to make sure i understand
It broadcast wifi and needs Ethernet shield to get the connection from a router? How many users can it handle?

You can use the ArduinoIDE go program the ESP8266

The ESP8266 WiFi can consume over 500mA during RF output, I have personally measured 700+mA ... So your power supply must be rock solid 3.3V @ 1A minimum.

Arduino on the ESP8266 is not magic. There is a task switcher built into the native code called NON-OS and if must get returned from the Arduino code not longer than every 50mS. Failure to "pet" the RF section will cause very ugly problems such as reboots or stale TCP stack.

The ESP8266 max connections == 4: see this article

I am unsure of the connection logic required to "jump" out of the captive portal - that is, you will need Internet connection which typically means a "new" DHCP needs to be provided. There may be other options, but I have not seen examples. This could be a showstopper for the ESP8266.... Or any system design.
See this Google query ..........

This too may help.

Good luck.

Ray

Can i program the arduino to talk to mikrotik router?
Mikrotik routers can do what i need, they print out username and password, and the user enters them in the browser and get a limited internet
But it needs a pc software to tell it to generate the users, can i replace that software with an arduino?