PHP

Sensorbase datalogger

Sensorbase.org is an open data repository run by the Center for Embedded Networked Sensing at UCLA. It’s a database of sensor databases. You can upload datasets to it, and you can browse other datasets as well. If you’ve never set up a database before but are interested in logging sensor data, it’s a good tool to get started. If you know what you’re doing already and you need to log a lot of sensor data, or compare it to similar work from others, it’s a convenient tool.

Since I like working with sensors and microcontrollers connected directly to the Internet, I thought it would be useful to be able to put data directly into Sensorbase from sensors connected to a microcontroller, without a personal computer in between.

Continue Reading »

Lantronix
PHP
arduino/wiring

Permalink

Browser Sniffer

Here’s a short PHP script that gathers info about the browser and the IP address of the client and returns it via email. I used it to gather data on cell phone browsers, and got the results seen at the bottom over the course of a day. Thanks to all those folks who hit it.

Technorati Tags: , ,


Continue Reading »

PHP

Permalink

Phone calls to a Microcontroller, though Asterisk

Kate Hartman has written a set of PHP examples that allow you to connect to a microcontroller via a phone call using Asterisk. Her examples use the Arduino microcontroller. Thanks to Kate for the link.

Technorati Tags:

PHP
arduino/wiring

Permalink

Web Scraping using a Microcontroller

This program connects a Wiring or Arduino module to the internet through a Lantronix serial-to-ethernet converter (Xport, WiPort, or Micro). The microcontroller makes a TCP connection to a web server first. Once it’s got a connection, it sends an HTTP request for a web page. When the web page comes back, it parses the page for < and > symbols, and takes the string between them. Then it converts the string to an integer. It assumes the string is made only of numeric ASCII characters (0 - 9).

This program couldn’t parse an entire web page very easily, so it’s best used in conjunction with a web scraper PHP script like this one, which reads the AIRNow site and extracts the Air Quality Index into a single string like this:

< AQI: 54>

This program was written to make an air quality index meter out of an analog voltmeter.

The electrical connections to the microcontroller are as follows:

  • disconnected LED: Arduino digital I/O 6
  • connected LED: Arduino digital I/O 7
  • connecting LED: Arduino digital I/O 8
  • requesting LED: Arduino digital I/O 9
  • Lantronix module reset: Arduino digital I/O 10
  • Voltmeter: Arduino digital I/O 11. The voltmeter is controlled by using pulse width modulation (analogWrite() command on the Arduino).

The web scraper is written in PHP. Its code follows below the Arduino code.

Technorati Tags: ,


Continue Reading »

Lantronix
PHP
arduino/wiring

Permalink

Network Data Logging Suite

This suite of programs takes data from a sensor and saves it to a text file on a network. Each sensor reading is time stamped. The suite illustrates the basic principles involved in sending sensor data to a networked file or database.
The first program involved is a microcontroller program, written in PicBasic Pro, tested on a PIC18F258. It waits for serial input from an external program. Then it reads its analog sensor, and sends the result out in two bytes.
The second program is the same microcontroller code in Wiring/Arduino, thanks to Jamie Allen for the cleanup.
The third program involved is a desktop computer program, written in Processing. It requests data via its serial port from the microprocessor and sends that data to a CGI program on a web server. It passes the data into the CGI using an HTTP GET request. This program only sends every three seconds, so as not to overwhelm the server with hits.
The fourth program is a CGI (common gareway interface) program, written in PHP. It takes in data from an HTTP GET request and appends it to a text file, along with the time the request was received. Note that this program does not check to see how big the file is, or whether the incoming data is properly formatted, so it isn’t terribly secure.
The fifth program is another PHP script that logs the data to a mySQL database. Running this doesn’t require any change in the microcontroller code, but it does require a slight change in the Processing code. The change is in the sentToNet() method, and is noted below.

Technorati Tags: ,


Continue Reading »

PHP
PicBasic Pro
Processing
arduino/wiring

Permalink

Basic XML Parsing Example

This is a basic example of an event-based XML parser in PHP. I got it from php.net. The example was written by Mauricio Massaia. I modified it slightly to take a string or a file address. I also added lines to print the results.

Technorati Tags: ,


Continue Reading »

PHP

Permalink

PHP to TCP Socket Form

This PHP program generates an HTML form which you can use to create a TCP socket to a remote device and send data to it. This assumes the remote device accepts the socket connection on the port you choose to connect to.

Thanks to John Schimmel for writing the code.

Technorati Tags: ,


Continue Reading »

PHP

Permalink

TCP Socket Server in PHP

This is a very basic TCP server written in PHP. Run it locally on your own machine; don’t try it on a production server first. It has an endless loop that will keep it going until you kill the process.

Thanks to John Schimmel for writing it.

Continue Reading »

PHP

Permalink