What's new
Carbonite

South Africa's Top Online Tech Classifieds!
Register a free account today to become a member! (No Under 18's)
Home of C.U.D.

Noobie has a question about a project.

Zaggermeister

Well Known Member
Rating - 100%
13   0   0
Joined
Sep 3, 2015
Messages
497
Reaction score
53
Points
2,035
Age
26
Location
Potchefstroom
Hey everyone. Hope you're all having a fantastic day.

So currently I'm tasked with receiving an input from the GPIO on a Raspberry Pi, then I need to update a MySQL DB and have my Angular site reflect the changes.

RPi is working great, got my input working correctly but I had a recent change of scope for my project. My lecturer wants me to not host everything on my RPi, he wants me to host the Webservice (Node.js) on a separate PC and just let my RPi make some kind of a callback to the Webservice and update the DB over the interwebs. At first this seemed like a rather simple thing but my lack of knowledge regarding everything web-related is posing a problem.

At the moment my DB is set up, I have some members of my team setting up the front-end and I've got another group setting up the webservice. As far as I know both of these components should be done together but we're pushed for time at this stage.

My questions are the following:

How would I send the signal that a button has been pushed on my RPi to the webservice?
When working with an API, is it fine to only have CRUD methods if my website is solely responsible for displaying data from the DB in a pretty fashion?
So let's assume the user needs data displayed in a different measurement unit, would it be okay to just simply convert my data in the DB to the required format in the API or on the front-end once it receives data, instead of changing the data in my DB?
Is my stack a good combination, or are there simpler ways to do this?
 
As with any programming, there is multiple ways to approach this:
Since there is a DB, you can just make a MEMORY database and update that whenever the button is pressed. Service the call and reset the button to zero.
Not the most elegant manner, but you already have all the components set up.
 
As with any programming, there is multiple ways to approach this:
Since there is a DB, you can just make a MEMORY database and update that whenever the button is pressed. Service the call and reset the button to zero.
Not the most elegant manner, but you already have all the components set up.

Do you think it'd be easier to let the RPi host the DB and let the DB relay the changed record to the API? That way I have no worries about the DB's integrity taking a hit. My Pi literally just runs a script to subtract X from a specific field in my DB.
 
Do you think it'd be easier to let the RPi host the DB and let the DB relay the changed record to the API? That way I have no worries about the DB's integrity taking a hit. My Pi literally just runs a script to subtract X from a specific field in my DB.
Depends how critical the button press is. If you just update a MEMORY table remotely with a datetime when the button was pressed, it will not work with no internet connection. But you do not have to worry about database sync'ing.
I would just set up a table on the server and remotely update an entry.
Since it is a memory table, there it is relatively robust since all data is discarded on reboot anyway.

Of course a better way would be to use something like MQTT as a protocol to send the information to the server, but really if you are already pressed for time ...
 

Users who are viewing this thread

Back
Top Bottom