Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Home-Made Twitter and Gmail Notifications with PHP and Arduino
Jan 16, 2017 @ 16:48:54

On the SitePoint PHP blog Christopher Pitt is back with another tutorial showing you yet another "odd" use of PHP. In this latest post he shows you how to integrate PHP and an Arduino to relay Twitter and Gmail notifications.

I am a little obsessed with Twitter. It’s how I communicate with most of the developers I’m not fortunate to live in the same city as. I’m a little less obsessed with IoT projects, but then it’s harder to find the time to work on them than it is to check Twitter.

Unless I can do both at the same time.

Ever since the IoT week, I’ve been meaning to work on a project that will let me know when someone wants to speak to me. Something that looks cool, and is at the same time non-invasive. This is what I’ve come up with...

He connects the Arduino with a RBG LED and a a proximity sensor to a PHP script that will change the LED color based on the notification type. The sensor would allow some "hand waving" to dismiss the notification as "read". He then starts in on the hardware side of things including some illustrations of the Arduino board and how things connect. With that simple setup in place he moves over to the software side, creating a Notifier service interface and using the "endroid/twitter" package to connect over to Twitter. He then walks through the creation of the Gmail and Twitter applications, grabbing the related OAuth credentials and dropping them into the script's configuration file. He builds out notifier classes for each service and hooks it into the Arduino with the Firmata and Carica libraries. Finally he hooks it all together with a bit of SPLQueue functionality to loop and listen for new alerts to relay to the Ardunio.

tagged: arduino twitter gmail notifications tutorial proximity sensor led

Link: https://www.sitepoint.com/home-made-twitter-and-gmail-notifications-with-php-and-arduino/

SitePoint PHP Blog:
PHP, Arduino, And… Minecraft? Connecting an Arduino to PHP!
Jul 12, 2016 @ 15:39:38

The SitePoint PHP blog has continued their series looking at connecting the real world with the online world via Minecraft and an Arduino. In this new post author Christopher Pitt picks up where he left off in part one and brings the Arduino in to the picture.

In the first part of this series, we learned a bit of Minecraft and the circuitry we can make inside it. We also made a circuit to alert us when the door to our mansion was opened. We then hooked this virtual alarm to a listening PHP script, so we can know when the door is opened in the context of a PHP script.

In this part, we’ll build a small Arduino-based alarm circuit. We’ll learn how to trigger the alarm, using the the official IDE and programming language, and then using something called Firmata. We’ll round the series out by connecting the alarm circuit to the Minecraft circuit, so we hear a real alarm for Minecraft mansion.

He takes some time at the beginning of the post introducing the Arduino hardware and what they have to offer. He lists the parts you'll need for this setup to work and how they need to be set up. He then gets into the code for the Ardunio side and how to get it over to the board. He presents another option to the potentially painful change-reupload cycle of debugging Arduino code: using the PHP "carica/firmata" library to connect to and add listeners to hook into the board. He uses this to then set up a PHP script to watch for changes in the Minecraft log files and fire an event to the waiting Arduino board.

The final item in this part of the tutorial series talks about bringing in the "Gorilla" extension for Carica Firmata to help prevent issues with too fast connections to the board interrupting the boot sequence.

tagged: tutorial series part2 minecraft arduino alarm connecting event loop

Link: https://www.sitepoint.com/php-arduino-and-minecraft-connecting-an-arduino-to-php/

SitePoint PHP Blog:
PHP, Arduino And… Minecraft? Combining Minecraft with PHP!
Jul 07, 2016 @ 18:35:15

On the SitePoint PHP blog author Christopher Pitt has a new tutorial posted about combining PHP, Arduino and Minecraft and combine the physical and software worlds in an interesting IoT combination.

Some of the most interesting programming I’ve done has been in Minecraft. It’s an open-world, sandbox game developed by Mojang, (recently acquired by Microsoft). Minecraft began as a canvas for creative expression, and while I do very different things in it these days, it still is that for me.

I’m going to take you on a journey, as we build a Minecraft mansion, and then secure it with a real-world alarm system. There’s quite a bit of ground to cover, and though I plan for this to be a two-part series, I’m going to have to leave some of the tangential details for you to discover!

For those not familiar with "programming" in Minecraft (not the backend language, but using things like redstone) he gives a brief introduction. He then sets up the situation - the creation of a "sprawling mansion" in your Minecraft world and a need to secure the front door. He includes the command to set up the "door open" test on a command block. He then shows how to hook this into a loop to continuously test if a door is open or not. With this open/closed door check system in place he then brings PHP into the mix, having it check log files for the "whispers" when the door actions happen. He then creates a watcher for these events and has it respond with a chat message back to the user. That's all in this tutorial but a future part of the series will add on the physical aspect - the Arduino.

tagged: tutorial physical arduino minecraft notification watcher series part1

Link: https://www.sitepoint.com/php-arduino-and-minecraft-combining-minecraft-with-php/

Thomas Weinert:
Carica Chip 101 - Controlling An LED With PHP
Nov 05, 2013 @ 16:18:40

Every once and a while someone uses PHP for something interesting and different than the usual web application. In this post to his site Thomas Weinert shares an example - he uses PHP to control a LED via Carica Chip.

Some time ago, in this blog post, I explained the basic stuff about Arduino, Firmata and PHP. Now it is time for the next step. Carica Io and Carica Firmata have grown and got a third layer called Carica Chip. [...] Carica Chip provides an easy way to control a device. So let's start with an "Interactive LED" example.

He uses the Carica Chip library and the "skeleton" application command from Composer to make a basic application. A simple HTML page with on and off links is made and and basic Carica Chip server is set up and executed. It's a simple example, but it gives you an idea of how to set it all up. The Carica Chip package also allows for other interactions including working with servos and motors.

tagged: carica chip introduction led arduino tutorial package control

Link: http://www.a-basketful-of-papayas.net/2013/11/carica-chip-101-controlling-led-with-php.html

Thomas Weinert:
Basics: Using Arduino From PHP
Jun 21, 2013 @ 14:33:52

In his latest post Thomas Weinert talks about using an Ardiuno board from inside of PHP (most people seem to use Python instead).

This is the version mostly described on the net. For example on Instructables. Basically you write an Arduino Scetch that listens and send plain text data on the serial port. A PHP Script triggered by a webserver request opens the port communicates with the Arduino board an outputs some HTML. The major downside of this approach is that many Arduino boards reset if the serial port is opened. So the startup and configuration has to be done any time the PHP scripts reads some data or triggers an action.

He talks about the Firmata software and an alternative to trying to call it through PHP - using one of a few non-blocking I/O libraries like React PHP. He's created his own non-blocking library that's made to work more specifically with the Firmata protocol, though. Some code samples are provided showing how to use it to make a light blink ("Hello world" for Arduino) and working with the data from a dimmer.

tagged: arduino library nonblocking caricaio firmata tutorial

Link: http://www.a-basketful-of-papayas.net/2013/06/basics-of-using-arduino-from-php.html


Trending Topics: