I'm doing a project which I want to send sensor's data to Firebase database. This connection must be via GPRS. To set or to push any data to Firebase database, it should be done using javascript and HTML, but the Arduino can't use javascript directly. Is there any way to make the connection?
I have a website. Would it be helpful to do the connection?
I will be really thankful if someone gave me a simple steps to follow.
Thank you in advance.
You could request web site links ( http request) from the arduino.And in this request you can pass details to the database.This is how the data is stored to the database from Arduino.
I am bit back about firebase database.
But let me tell what we did for storing data to a normal database.We made a PHP script such that if its link is requested with data ,it would store the data to the database.Then we made Arduino code in such a way as to request that link each time with the corresponding value to be stored.So if you can do PHP scripting for firebase data entry then its easier ( just request that link from Arduino).I think PHP insertion to firebase database is available.
You can also pass data to a website too using the above method ( simple modification in url would do that ,pass data to be stored).But the problem is how you would store it to the database from that webpage.If you have a way for that you can try it too.
Related
I'm creating an IoT project to send some commands to my Arduino board and receive some details through the internet.
After a lot of search, I recognized that the best solution for me is to convert arduino to a web-server and send requests to it.
I designed the showing page by:
GSMServer server(80);
serer.begin();
GSMClient client = server.available();
client.println("HTML CODE HERE");
but I want to use javascript to parse receiving GET or POSTs and assign them to values in my code.
What should I do?
You will have to build upon GSMServer further so that it can handle different requests and respond different information based on the call.
Have you seen https://www.arduino.cc/en/Tutorial/GSMExamplesWebServer
It shows how different calls can be made as well as how a http request can be responded with a html page.
I am trying to make a webpage and server where a user can enter in recipes and have them sent to (using JSON) the server and have the server store them in a file so that if the server is closed and reopened the user can request for something they've entered previously and can get it. I know how to send the JSON object both to the server and how to send the JSON object back to the client. I should note this can't use jquery.
What I need help with is how to store it in a file server side and get the contents from it later using a node.js server. They should all be stored in the same directory and I need to know how to get a list of the recipes in that directory. I've tried looking around but I can't seem to find the answer :(.
Example:
user makes a recipies
{ name:"cheese n waffles"
time:90,
ingredients:"cheese, eggs and waffles",
equipment:stove
};
Browser sends the JSON object to the server.
Client asks for a list of the recipes stored.
user asks for the recipe for spaghetti.
what I need help with:
server gets a list of the recipes it has stored
server takes the JSON object and stores it in /serverRootDir/recepiesStorage
server accesses /serverRootDir/recepiesStorage and gets the spaghetti recipe
You should be using a JSON based database such as MondoDB
It takes some learming however implementing with a text file will eventually become much more work and will function poorly
(Posted on behalf of the OP).
I have solved the problem. I will be using:
To read a file (access a recipe): fs.readFileSync() or fs.readFile().
To save a file (update a recipe): fs.writeFileSync() or fs.writeFile().
To get an array of files in a directory (retrieve the list of recipes): fs.readdirSync() or fs.readdir().
I want to create a chart where I can select a time period and query mongodb accordingly. I want to use Java to query MongoDb. I know how to connect MongoDb and Java but I'm not so clear about linking the java to my webpage(i.e. To pass the data from that java file to my webpage/javascript).
I know Ajax calls can be used to link to servlets, but I'm sort of lost. Please help.
You use the Java MongoDB driver to connect to and query MongoDB from within your Java application. https://docs.mongodb.org/getting-started/java/client/
You would make that data available to the browser (D3/JavaScript) the same way you would make any server-side data available to the browser. You could either add that data to the page as you are rendering the actual webpage, or you could return the data in response to an AJAX request.
I am trying to write my first chrome extension. The workflow goes something like this -When the extension is installed and active if a user hovers over a specific product/ID displayed on the page, the extension retrieves related vendor data about the product with the ID.
This is how I thought about this:
Use jQuery attr to access the ID on mouse over.
Post this ID to a retrieve.php file with .post() method
The retrieve.php file retrieves the data from database
Display the data in a tool tip on the web page.
I have some queries for the above process:
I am able to get this working on a local XAMPP server but how will it work online as the chrome extension will not have access to server. What is the way around to retrieve data without using PHP?
I am able to get the logic working but am unable to place these in respective files - Will all my logic reside in background.js ?
Any suggestions on getting this started will be much appreciated.
You could build a very simple API on your server that responds with JSON to any request it receives after processing it. Like this:
{"firstVar":"foo","secondVar":"bar" }
Your chrome extension can then make an xmlhttp request to this server and and process the returned data.(You could also use JSONP and wrap the response in a callback function which will execute as soon as you have the reponse)
The JS extension will be able to deal with the JSON nicely as it can understand that format so you can then choose to display the data in whatever way you want.
Essentially, what you want is a server that can take an ID posted to it and return the corresponding date in a nice and readable format. And a chrome extension that can make an request to a server and then process the response. Build and test them separately (keep positing an ID to the server and see the response and for your JS side at first instead of making requests to your unfinished API just set a static response to begin with which will be the same as an expected response.
I am trying to make an html app for local use, consisting of an HTML page using Google Maps API V3, a SQLite database, and a SimpleHTTPServer script.
The workflow is the following:
User starts the server and opens the page, which contains a map with a set of markers, and a form with filters similar to those of Google Fusion Tables;
User interacts with form, which sets some parameters for a query;
When the user clicks "Submit", page sends a request to HTTPServer, whose request handler queries the SQLite database and returns the result as JSON/JSONP/something-else;
Some function takes back the data and map is updated;
My doubts are more conceptual than anything else, and specifically I would like to know (how/where to look for):
How should I send a request for the server in javascript, and how to listen back to it?
How should the server send data to the request, in order to update its value instead of refreshing the page?
Sorry if my questions seem obvious, but HTTP is something very new to me, and so is client-server communication.
Thanks for reading!
I think you can use CGIHTTPServer.
ref:
http://pydoc.org/2.5.1/CGIHTTPServer.html
Q:How should I send a request for the server in javascript, and how to listen back to it
A:Please google "ajax". "jquery" is one of the most convenient javascript library for ajax.
Q:How should the server send data to the request
A:just use "print" in python script which is called by CGIHTTPServer.
In this case, the output of "print" will be the response to http client(web browser).
In the script mentioned above, you should extract request parameter sent by http client,
with "do_Get()" or do_Post() function.