Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to publish Arduino sensor data to a web page?

Tags:

arduino

I want to read sensor information from an Arduino Uno. I already have a Java program that connects to the serial port and reads the information from the Arduino.

I want to publish this information to a web page (currently my computer is running the Apache web server). I'm not that good at web development, however I can get by.

My plan is to save the sensor data that I've read in from the Arduino to a file. I would update this file about every 1 minute. Then using some server side scripting language (i.e. PHP) read the data from the file and generate a web page showing the sensor information when the page is requested.

However, this approach doesn't seem very "elegant". Is there a better way to perform this task?

(Also, I'm only using the Arduino Uno with a USB port, I don't have an Ethernet shield.)

like image 546
jos76 Avatar asked Dec 08 '11 00:12

jos76


People also ask

How do I show Arduino sensor data on a website?

Using the Arduino IDEGo to File >> Examples >> Basics >> BareMinimum then upload the sketch. This is to make sure that no program is running on the Arduino board. Next, open the serial monitor. Make sure to set the baud rate to default, which is usually 115200.

How does Arduino send data to web server?

sendwebdata( ) function is used for sending data to Local Server or Webpage. void sendwebdata(String webPage) { int ii=0; while(1) { unsigned int l=webPage. length(); Serial. print("AT+CIPSEND=0,"); client.

Can you connect Arduino to a website?

You will need to log into your router using a web browser and then set up and enable port forwarding. After setting up port forwarding, you will be able to load your Arduino web page from a device connected to the Internet and external to your own network.

How do I send an Arduino sensor data to the cloud?

Connect the Arduino to your computer through USB cable. Open Arduino IDE and flash the code. Open a serial terminal. You should see you Arduino handles AT commands with the ESP8266 which performs the connection to WiFi networks and sending data to the AskSensors cloud over HTTP requests.


1 Answers

I guess it really depends on how robust you want web page to be and how centralized you want your application to be.

If you are just looking for simple raw data, you could build a simple web server into your Java application to serve the contents of the file. This would centralize everything into one application. (Instead of apache + php + java)

If you are looking for live data, you could even fire off serial commands when something like http://localhost/getData is requested and respond with live data read through the serial. (Although, I would not recommend this if several simultaneous connections are going to be made to your web server. Arduino doesn't do multithreading and serial can be slow.)

The downsides of this, of course, is that you are manually coding the HTML output. There are some HTML libraries (here and here) that may help with this though.

like image 153
aus Avatar answered Sep 26 '22 17:09

aus