I want to send a sensor value to a web server using Wi-Fi. Will Arduino Uno, WiFi shield and the sensor be feasible for this project?
Need guidance. Any tutorials to start with?
Sounds promising, but of course it matters a lot what sort of web server you're talking about (especially whether it implements any security) and what sort of sensor.
Its an sensor which gives analog values. I haven't decided on the web server yet. I want the arduino to send the value of the sensor via WiFi and store it in the server online. What's the best way to achieve this? Php,mysql?
piyushkul1:
Its an sensor which gives analog values. I haven't decided on the web server yet. I want the arduino to send the value of the sensor via WiFi and store it in the server online. What's the best way to achieve this? Php,mysql?
Why do you want the Arduino to send the sensor values via wifi? Do you mean via wirelessly instead of wifi? There's a big difference. If the sensor Arduino has to be on wifi, it has to implement the whole TCP/IP stack, plus whatever encryption your wifi has. If you just need the sensor Arduino to send sensor data wirelessly to some kind of base station, that's much easier. There are a few examples of wireless modules that can send data wirelessly, and the receiving Arduino can use a wifi shield to act as the internet gateway for this data.
Some systems use a Raspberry Pi as the gateway, because it's better at logging data and presenting graphs of historized data.
piyushkul1:
Its an sensor which gives analog values. I haven't decided on the web server yet. I want the arduino to send the value of the sensor via WiFi and store it in the server online. What's the best way to achieve this? Php,mysql?
You would need to get the input signal into the 0 .. 5V range for the Arduino to be able to read it with an analog input pin.
You need to decide when to read and save the input signal. Perhaps you want to do it at regular intervals, or when it changes by some amount.
You need to decide whether there are any security requirements. If not, it would be very simple to write a sketch that acted as a web client and carried out an HTTP POST request to submit the data to a webapp that saved it to a local database.
Event based client code that sends a GET request to a web server.
//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields
//remove SD card if inserted
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
char serverName[] = "web.comporium.net"; // zoomkat's test web page server
EthernetClient client;
//////////////////////
void setup(){
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
while(true);
}
Serial.begin(9600);
Serial.println("Better client test 9/22/12"); // so I can keep track of what is loaded
Serial.println("Send an e in serial monitor to test"); // what to do to test
}
void loop(){
// check for serial input
if (Serial.available() > 0) //if something in serial buffer
{
byte inChar; // sets inChar as a byte
inChar = Serial.read(); //gets byte from buffer
if(inChar == 'e') // checks to see byte is an e
{
sendGET(); // call sendGET function below when byte is an e
}
}
}
//////////////////////////
void sendGET() //client function to send/receive GET request data.
{
if (client.connect(serverName, 80)) { //starts client connection, checks for connection
Serial.println("connected");
client.println("GET /~shb/arduino.txt HTTP/1.1"); //download text
client.println("Host: web.comporium.net");
client.println("Connection: close"); //close 1.1 persistent connection
client.println(); //end of get request
}
else {
Serial.println("connection failed"); //error message if no client connect
Serial.println();
}
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read(); //gets byte from ethernet buffer
Serial.print(c); //prints byte to serial monitor
}
Serial.println();
Serial.println("disconnecting.");
Serial.println("==================");
Serial.println();
client.stop(); //stop client
}
I don't want the Arduino to send data wirelessly to a base station. Instrad I want to send the data to an online web server, hence I need WiFi for this.
The sensor reading and algorithms have been created. Now the thing remaining is connecting Arduino to WiFi and sending the data to the web server.
piyushkul1:
the thing remaining is connecting Arduino to WiFi and sending the data to the web server.
Using WiFi to access a web site is the 'hello world' of WiFi library examples.