Microcontrollers Programming is difficult because usually engineers and students doesn’t have the required tools for debugging of their codes and electronic circuits, that the main reason, they got into trouble while designing projects. On the other hand, we are highly equipped withh all sorts of tools to deal with such problems and we not only design projects but also put our full effort in explaining these projects to engineers and students so that they also get technical knowledge and can easily debug or increase the projects’ technicality in future.
Note:
We have designed projects in almost every field. Embedded projects belong to different fields and if you are not master of all trades then you can’t complete in embedded fields. That’s the main reason, we have a batch of engineers in our research depart who continuously work on research new fields. We have worked on many different technologies taking from simple keypad, LCD to high complex modules such as WiFi, Ethernet etc. We have worked on many different technologies, such as:
In embedded projects, motors are normally used, especially in robotics. Without motors, its unable to drive robots. We have worked on many different motors, such as:
Apart from these motors, few motors are used in electrical projects for controlling purposes, such as:
Arduino Wifi Shield is used to connect Arduino board with Wifi. After connectivity with Wifi, one can perform many tasks using this shield. We can built a complete server on it and can also use it as a client. Server designed on an Arduino Wifi Shield are usually quite simple as it doesn’t have much processing power to support heavy server. Arduino Wifi Shield is mostly used in home automation projects where home appliances are controlled by Wifi or can also be used for security purposes. In short, it has numerous applications and is widely used.
In today’s project, we will use Arduino UNO board for programming purposes, and will interface two leds with it and then we will control these leds via an online web server. Using that online web server, we will ON and OFF these leds on command. For controlling leds from an online server, we have to design two things:
Their arrangement and pin configuration is shown in the Arduino Web Client section. We will arrange them in such a way that two leds will be mounted on the Arduino UNO shield. In web server, we will design a simple page, which will be having four buttons on it, which will be:
When someone will open this web page and will pres any of these buttons, respective task will be performed on the Leds. i.e. if someone pressed the LED 1 ON button then Led 1 present on the Arduino board will get ON and when someone press LED 1 OFF button, that Led will go OFF and same function will be performed for second led. There won’t be any connection between the hardware and that web server, the only connection will be the Wifi. The Arduino Shield must have a Wifi connection available and one sitting from across the world can control them. Now let’s discuss these two parts, one by one.
I have designed the online web server on my own site The Engineering Projects. This is a php page which I have uploaded on my web server. In order to make this page, simply follow the below steps:
Note:
#include <SPI.h> #include <WiFi.h> char ssid[] = “EvoWingle-12F3“; // your network SSID (name) char pass[] = “093B3453“; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key Index number (needed only for WEP) int status = WL_IDLE_STATUS; char server[] = “www.theengineeringprojects.com“; // name address for Google (using DNS) String location = “/Examples/data.txt HTTP/1.0“; char inString[500]; // string for incoming serial data int stringPos = 0; // string index counter byte statusLed = 0; char c; int led1 = 3; int led2 = 4; WiFiClient client; unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds boolean lastConnected = false; // state of the connection last time through the main loop const unsigned long postingInterval = 10*1000; // delay between updates, in milliseconds void setup() { //Initialize serial and wait for port to open: Serial.begin(9600); pinMode(led1,OUTPUT); pinMode(led2,OUTPUT); digitalWrite(led1, LOW); digitalWrite(led2, LOW); // check for the presence of the shield: if (WiFi.status() == WL_NO_SHIELD) { Serial.println(“WiFi shield not present”); // don’t continue: while(true); } // attempt to connect to Wifi network: while ( status != WL_CONNECTED) { Serial.print(“Attempting to connect to SSID: “); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } Serial.println(“Connected to wifi”); printWifiStatus(); Serial.println(“nStarting connection to server…”); // if you get a connection, report back via serial: if (client.connect(server, 80)) { Serial.println(“connected to server”); // Make a HTTP request: client.print(“GET “); client.println(location); client.println(“Host: theengineeringprojects.com”); // client.println(“Connection: close”); client.println(); //readPage(); }else{ Serial.println(“connection failed”); } } void loop(){ while (client.available()) { c = client.read(); Serial.write(c); CheckingStatus(); } if (!client.connected() && lastConnected) { Serial.println(); Serial.println(“disconnecting.”); client.stop(); } if(!client.connected() && (millis() – lastConnectionTime > postingInterval)) { PingRequest(); } lastConnected = client.connected(); } void PingRequest(){ if (client.connect(server, 80)) { // Serial.println(“connected to server”); // Make a HTTP request: client.print(“GET “); client.println(location); client.println(“Host: theengineeringprojects.com”); client.println(“Connection: close”); client.println(); //readPage(); lastConnectionTime = millis(); }else{ //Serial.println(“connection failed”); client.stop(); } } void CheckingStatus(){ inString[stringPos] = c; if(c == ‘*’) { statusLed = inString[stringPos - 1]; stringPos = 0; // Serial.write(statusLed); delay(500); UpdatingStatus(); // delay(500); // client.flush(); // delay(10000); //PingServer(); } stringPos ++; } void UpdatingStatus(){ if(statusLed == ’1') { digitalWrite(led1, HIGH); // Serial.write(‘OK’); } if(statusLed == ’2') { digitalWrite(led1, LOW); } if(statusLed == ’3') { digitalWrite(led2, HIGH); } if(statusLed == ’4') { digitalWrite(led2, LOW); } } void printWifiStatus() { // print the SSID of the network you’re attached to: Serial.print(“SSID: “); Serial.println(WiFi.SSID()); // print your WiFi shield’s IP address: IPAddress ip = WiFi.localIP(); Serial.print(“IP Address: “); Serial.println(ip); // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print(“signal strength (RSSI):”); Serial.print(rssi); Serial.println(” dBm”); }
That’s all for today, Stay Blessed, take care. :))