Project tutorial

Reset Arduino via Web © GPL3+

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

  • 3,777 views
  • 2 comments
  • 29 respects

Components and supplies

About this project

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

Arduino Dynamic Web Control

Project tutorial by phpoc_man

  • 34,769 views
  • 15 comments
  • 117 respects

Arduino - Web Oscilloscope (Support Trigger)

Project tutorial by phpoc_man

  • 6,145 views
  • 13 comments
  • 52 respects

Web Sketch (HTML5 Canvas)

Project tutorial by hmkim

  • 2,532 views
  • 1 comment
  • 23 respects

Controlling Arduino State Machine via Web

Project tutorial by phpoc_man

  • 1,768 views
  • 4 comments
  • 22 respects

Arduino - Control Arm Robot via Web

Project tutorial by phpoc_man

  • 10,555 views
  • 17 comments
  • 117 respects

Arduino - Set Schedule via Web

Project tutorial by phpoc_man

  • 1,268 views
  • 2 comments
  • 20 respects
Add projectSign up / Login