Need a sketch written

Hi all!

I have a project that I am trying to make happen.

  • I need a box with a card reader RFC522 and a NodeMCU.
  • We will be giving out cards for members to come in and tap the box, the card number goes over the internet via GET to my website, where I log it with a timestamp.
  • My website looks up and validates the card number and sends back a "Yes" or "No" (or 1/0, whatever) to the NodeMCU that triggers a red LED if it fails or a green LED if the card number is found.

That's it. A straight-forward attendance tracker sketch.

Some Bonus functionality would be:

  • if the owner can put the box into "read mode" and it sends a different code with the card number, so my site can add the number.
  • if the owner can enter his/her wi-fi password without me having to recompile the code.
  • if the whole thing can be handled through a web-enabled computer (no wi-fi), since the box won't be operational unless there is someone at the computer anyway. <- this one would be WONDERFUL!

I have the NodeMCUs coming this week, but the only one I had was fried. So I got pretty close on the Nano, but can't figure out how to send it across the internet to be recorded.

Does anyone want to help me bring this thing to reality? :slight_smile: That would be amazing!

I can put a flowchart or sequence diagram to show the functionality if it isn't clear. Please let me know! Thanks!

Why don't you start by posting what you have as it sounds like all you need is to add the web interface. That'd save a lot of work.

Racmaster:

  • if the whole thing can be handled through a web-enabled computer (no wi-fi), since the box won't be operational unless there is someone at the computer anyway. <- this one would be WONDERFUL!

In this case: how do you plan to do the web communication if not over WiFi?

What I was suggesting was that, since the computer is already connected to the internet, it doesn't seem like I need to go around it to his router wirelessly. I was wondering if there is be a way to open port 80 and get right to it, like hard-wired ethernet vs. wi-fi.

Maybe it doesn't work that way but I know that the wi-fi shields can be web servers just by being powered by a battery. I was thinking, since the device is connected to a PC that is already connected to an access point, it could allow this thing to connect to that access point through it, wherever the PC goes.

Make sense?

Also I've included my sketch. it's a lot of beeping and lights for feedback but you're right, I just need the web interface, which is something not straight-forward to me.

rfidCardSensor.ino (2.51 KB)

To use Ethernet you need an Ethernet adapter. That's extra code complexity and extra hardware, and doesn't make sense if you have WiFi connection working already.

A web interface is NOT straightforward.

  1. you have to do the html design, so your user has an at least halfway decent page to look at.
  2. you copy that into your sketch so you can create the complete html page, filling in the variables as you go.
  3. you serve up the page to the user when they point their browser to your ESP.

Then to receive data, that's actually easier:

  1. make sure there's a FORM in your page - both GET or POST do fine.
  2. read the form data in your sketch (quite straightforward as soon as you get the hang of it - the actual parsing is done for you, you just have to look for the expected field names and read the data that goes with it), and then handle the data as needed.

There's a WiFiManager library that will automatically set up the ESP as access point if no WiFi configured or WiFi is not available, allowing a user to connect to the access point, get a landing page served up and enter the network details.

I am a full-stack web developer by trade, PHP/MySQL back end. Serving up a decent page is the easy part. It's getting the little thing to reliably connect and stay connected that's the hard part (for me). My Nodes are arriving today so I will play around with them and see how straight-forward they are.

The problems I run into with these is that I add one library or board package, and then suddenly the IDE won't upload the sketch, so I spend hours trying to figure that out, just to end up at a different computer using its IDE. Things like that. Where [whatever] just suddenly stops doing [whatever] even if it was just doing [whatever], or whatever. :o

I've never used this forum so maybe I can feel better about finding help, or someone to pay if it comes to that. :slight_smile:
Thanks.

Holding the flash button while pressing reset helps a lot. It gets the device into program mode. USB is indeed not doing this reliably. Or hold the flash button until upload starts.

You seem to be using a lot of terms interchangeably that makes it hard to understand this part:

"- if the whole thing can be handled through a web-enabled computer (no wi-fi), since the box won't be operational unless there is someone at the computer anyway. <- this one would be WONDERFUL!"

Are you saying that your RFC522 & NodeMCU will always be connected to a computer? If so, why not use an off the shelf USB card reader and eliminate the Node?

I feel like I'm missing what I need to help you and I can't figure it out :frowning:

I can program it for you on website on internet. :slight_smile:
If you want to see my portfolio: https://arduino.php5.sk

Wow! Okay, I'm so excited! I had to do some research but now that I HAVE A BOARD THAT ACTUALLY WORKS, I was able to translate the pinout from the Nano to the NodeMCU, which means my card reader works on the NodeMCU. Also I was able to connect to internet using an entirely different sketch, but I picked the one that only sent back a response code (302) that it successfully connected to my webpage.

I am now to the part where I need to:

  • send the card number over WiFi from my Node to my webpage
  • let my webpage do it's thing and then send back a custom response to my Node.
  • I don't need any guidance on web page/server-side processing. Just the Node sketch.

Which example sketch will get me the closest to that? In other words, what would be the best sketch to make my Node send and receive custom responses (using GET)?

Thank you all for your help! I'm really enjoying this project. I would love to add an LCD display that says "Hi, Matt!" if the card is read successfully, but I'll take it one step at a time. I will pay to integrate that sketch later. LOL

A bit of time on Google and you'll have lots of example sketches and tutorials describing just that. It's a quite common use of that processor.

send me e-mail: martinius96@gmail.com
We can talk about project etc.