6

How can I run a webserver in a Arduino Uno? I want to use my Arduino to monitor things in my home such as temperature. I want to be able to access this data through the internet.

2

You'll need something like the Ethernet Shield to connect your Arduino Uno to a LAN.

As for webserver functionality, the Webserver Example sketch does the bulk of what you need.

enter image description here

For the "access this data through the internet" part, assuming you want access beyond your LAN; you'll need to perform Port Forwarding on your local router (i.e. allow the "Internet" to see your Arduino).

If you need wifi, then personally I prefer the CC3300 to the Arduino Wifi shield.

  • 7
    it's easier to let the arduino just emit periodic UDP packets with the relevant data and have another computer do the heavy lifting of hosting the webserver (and it can do logging) – ratchet freak Mar 5 '14 at 14:10
  • 1
    It's important to note that many new users to Arduino don't realise quite how small it is, and how limited a web server you can build. Don't even expect anything near to a home router's config pages in complexity. – Cybergibbons Mar 5 '14 at 15:09
  • UDP is great, but don't forget that UDP is open to packet loss. If you need each and every sample you'd need to make sure you send it multiple times. Then you'd also need to timestamp or identify it. So UDP can become cumbersome. The Original Poster requested info on implementing a Server. The data sent can be as little as just the temperature value. We shouldn't assume a fancy Webpage is required. – akellyirl Mar 5 '14 at 17:39
  • @akellyirl with a direct connection and one-way traffic (or connected to a switch with store-and-forward) there will be no packet loss unless the cable is bad – ratchet freak Mar 6 '14 at 12:42
2

The Arduino Yún has been made with this use case in mind. The Bridge library allows your sketch to publish data such as sensor readings: this data is available through a REST api.

Say you want to publish the temperature of your living room: you'll write something like

Bridge.put("living_room", String(19)); //celsius

You can then access the data via web with a URL like

http://arduino.local/data/get/living_room

You can get all sensor readings without specifying the key name, with

http://arduino.local/data/get

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.