jos76
jos76

Reputation: 141

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

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.)

Upvotes: 5

Views: 17769

Answers (5)

mkocabas
mkocabas

Reputation: 733

Have you ever heard about SensorMonkey... This website helps you to publish your sensor data from arduino or other devices like Shimmer or xBee.. You can login it by using your facebook account. It is very easy to use it hence it doesn't require web development knowledge...

Upvotes: 2

Abdallah Hodieb
Abdallah Hodieb

Reputation: 31

Well since you don't have an Ethernet shield then the only option for you is use the serial read port.

reading the data from the serial port and saving it to a file , you can try to format your data in json or xml format . this will let you easily manipulate the data using jQuery for exmple.

if you know how you can create an create an ajax page to display the data in an elegent way . you can check out backbone.js and some jQuery .

if your not that good in web development and/or web design . you can depend on pre-built websites for this purpose . i liked the UI of the cosm website

and you might consider having an Ethernet or WiFi shield . having your Arduino directly connected to the internet can be very powerful and will enable you to create neat hacks

you also might like this tutorial

Upvotes: 2

jdMiami
jdMiami

Reputation: 51

You can create an account on SensorMonkey.com and then create an API to use your sensor data on another website.

Upvotes: 1

ViennaMike
ViennaMike

Reputation: 2337

To add, if you don't expect to get many hits in a short period, generating the page dynamically, triggered when a request comes in (as you describe) works fine. If you expect to get many hits per minute (your specified update rate for the data), you'd want to generate the page once per minute when the data updates, then serve it out to each requester, rather than regenerate the page each time there's a request.

Upvotes: 0

aus
aus

Reputation: 1434

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.

Upvotes: 2

Related Questions