Project tutorial

Reset Arduino via Web © GPL3+

This shows two ways to reset Arduino via web, by software and hardware.

  • 5,482 views
  • 2 comments
  • 32 respects

Components and supplies

About this project

If you are new to Arduino, you can get started with Arduino Tutorials for newbie.

There are two ways to reset Arduino using Arduino code:

  • By Arduino code only (called software reset): by this way, Arduino code wil be run from the beginning. But Hardware peripherals are not reset. For example, states of IO pin is not set set to default.
  • By Arduino code in combination with hardware (called hardware reset): by connecting an IO pin to RESET pin. When we set this pin to LOW, Arduino will be reset as when we press RESET button. All peripherals are reset to default.

I used PHPoC Shield, which has the built-in web application, called Web Remote Control / Push. When pressing web button A, Arduino will blink a LED some time and then reset.

Demonstration


Code

WebSoftwareResetArduino
/* arduino web server - remote control (push button) */

#include "SPI.h"
#include "Phpoc.h"

PhpocServer server(80);

int LED_PIN = 8;

void(* resetFunc) (void) = 0;//declare reset function at address 0

void setup() {
	Serial.begin(9600);
	while(!Serial)
		;

	//Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
	Phpoc.begin();

	server.beginWebSocket("remote_push");

	Serial.println("Arduino started");
	Serial.print("WebSocket server address : ");
	Serial.println(Phpoc.localIP());

	pinMode(LED_PIN, OUTPUT);
}

void loop() {
	// wait for a new client:
	PhpocClient client = server.available();

	if (client) {
		if (client.available() > 0) {
			// read the bytes incoming from the client:
			char thisChar = client.read();

			if(thisChar == 'A') {
				Serial.println("resetting...");
				// blink LED before reseting
				for( int i =0; i < 5; i++) {
					digitalWrite(LED_PIN, LOW);
					delay(100);
					digitalWrite(LED_PIN, HIGH);
					delay(100);
				}

				resetFunc();  //call reset
			}
		}
    }
}
WebHardwareResetArduino
/* arduino web server - remote control (push button) */

#include "SPI.h"
#include "Phpoc.h"

PhpocServer server(80);

int RESET_PIN = 9;
int LED_PIN = 8;

void(* resetFunc) (void) = 0;//declare reset function at address 0

void setup() {
	Serial.begin(9600);
	while(!Serial)
		;

	//Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
	Phpoc.begin();

	server.beginWebSocket("remote_push");

	Serial.println("Arduino started");
	Serial.print("WebSocket server address : ");
	Serial.println(Phpoc.localIP());

	// MUST change state of RESET_PIN to HIGH before changing its mode to OUTPUT. if not, Arduino is infinitely reset
	digitalWrite(RESET_PIN, HIGH);
	pinMode(RESET_PIN, OUTPUT);

	pinMode(LED_PIN, OUTPUT);
}

void loop() {
	// wait for a new client:
	PhpocClient client = server.available();

	if (client) {
		if (client.available() > 0) {
			// read the bytes incoming from the client:
			char thisChar = client.read();

			if(thisChar == 'A') {
				Serial.println("resetting...");
				// blink LED before reseting
				for( int i = 0; i < 5; i++) {
					digitalWrite(LED_PIN, LOW);
					delay(100);
					digitalWrite(LED_PIN, HIGH);
					delay(100);
				}

				digitalWrite(RESET_PIN, LOW);  //call reset
			}
		}
    }
}

Schematics

software_reset_schematic
Software reset baghcespbd
hardware_reset_schematic
Hardware reset cav0vdolqq

Comments

Similar projects you might like

Web Sketch (HTML5 Canvas)

Project tutorial by hmkim

  • 3,376 views
  • 1 comment
  • 25 respects

Arduino Dynamic Web Control

Project tutorial by phpoc_man

  • 45,795 views
  • 21 comments
  • 154 respects

Arduino - Web Oscilloscope (Support Trigger)

Project tutorial by phpoc_man

  • 8,741 views
  • 13 comments
  • 54 respects

Controlling Arduino State Machine via Web

Project tutorial by phpoc_man

  • 2,212 views
  • 4 comments
  • 23 respects

Arduino - Control Arm Robot via Web

Project tutorial by phpoc_man

  • 18,266 views
  • 23 comments
  • 163 respects

8X8 Matrix LED Snake Game (HTML5 Web Socket)

Project showcase by hmkim

  • 8,362 views
  • 1 comment
  • 19 respects
Add projectSign up / Login