Things used in this project

Hardware components:
Phpoc blue per 100x1000 euk22wtv9i
PHPoC Blue
×1
SparkFun Force Sensor
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
Resistor 3.3k ohm
×1
Relay board t type jznmyjoo9g
PHPoC 4-Port Relay Expansion Board (T-type)
×1
Warning Lights & Electric Horns
×1

Schematics

Wiring
- Stack PHPoC Relay Board on PHPoC Blue
- Connect Force sensor to PHPoC Blue as below image.
- Connect Warning Lights & Electric Horns to port 0 of Relay Board
Phpoc wiring ygslrl6nqu
Real Wiring
Phpoc wiring real watxfj673y

Code

Main task (task0.php)PHP
<?php

if(_SERVER("REQUEST_METHOD"))
	exit; // avoid php execution via http request

include_once "/lib/sd_340.php";
include_once "/lib/sn_dns.php";
include_once "/lib/sn_esmtp.php";
include_once "/lib/sd_spc.php";

define("THRESHOLD", 50); // in ADC value

function send_gmail()
{
	esmtp_account("ypur_account@gmail.com", "PHPoC");
	esmtp_auth("your_account", "your_password");
	esmtp_msa("smtp.gmail.com", 465);
	
	$time = date("Y-M-d H:i:s", time());

	$subject = "Alert: Your treasure is being taken away";
	$message  = "Location: Planet Earth\r\n";
	$message .= "Time: $time\r\n";
	$message .= "Your treasure is being taken away\r\n";

	$msg = esmtp_send("receiver_account@gmail.com", "Boss", $subject, $message);

	if($msg == "221")
		return true;
	else
		return false;
}

spc_reset();
spc_sync_baud(115200);
adc_setup(0, 0); // adc0, channel 0

$obj_present = false;

while(1)
{
	$adc_in = adc_in(0, 30);
	
	if($adc_in < THRESHOLD)
	{
		
		if($obj_present)
		{
			//Alert
			spc_request(14, 4, "set 0 output high");
			// send notification
			while(!send_gmail())
				;
			
			$obj_present = false;
		}
	}
	else
	{
		$obj_present = true;
		spc_request(14, 4, "set 0 output low");
	}
}

?>

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

LED Roulette Game
Easy
  • 10
  • 2

Full instructions

A fun pocket-sized travel game for any age. Try your luck and make the light stop on the green LED.

Controlling Stepper Motor Precisely via Web
Easy
  • 235
  • 9

This project shows how to control the step motor precisely using micro-stepping method via Web.

Mask with Blinking Eye
Easy
  • 74
  • 3

Protip

Makes a great mask more eye-catching when one eye is blinking. Has an on-off switch, is powered by a cell , and driven by an ATtiny85.

PHPoC - Web-Based Two-Player Game
Easy
  • 269
  • 9

Have fun with a colleague during break time with this web-based game.

Safe City: A Device to Keep You Safe
Easy
  • 1,246
  • 9

Full instructions

The device will keep you safe. Just have to click a button and your precise location will be shared.

Scavenger Hunt Clues w/ Telephone Keypad
Easy
  • 1,117
  • 4

Full instructions

Type the correct code on the phone's keypad to hear the clue through the handset, then decode the message to finish before the other team.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog