This program reads a serial string from a GPS reader. It parses the sentence and returns latitude and longitude.
It’s also a simple example of how to read an ASCII-formatted, comma-delimited serial protocol.
code, circuits, & construction
code and fabrication resources for physical computing and networking
This program reads a serial string from a GPS reader. It parses the sentence and returns latitude and longitude.
It’s also a simple example of how to read an ASCII-formatted, comma-delimited serial protocol.
This is a test server. I use it any time I have a client that needs to connect to a web server or chat server, and I want to see what the client is sending, byte for byte. You can modify it to send and receive whatever you need.
Technorati Tags: networked objects, networks
This program shows how to make a HTTP request in Processing.
Technorati Tags: networked objects, networks
Sometimes you want to send a binary value into Processing (say, from a microcontroller) and check the individual bits of the value. This example checks the bits of an 8-bit number individually, and reports whether each one is a 0 or a 1.
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: networked objects, networks
This example for Processing shows how to take in a multi-byte string of serial data and process it byte by byte. In this example, the computer sends an “A” to the microcontroller, and the microcontroller sends three bytes in response. Each byte represents a sensor value.
After sending the “A”, the computer reads each byte in, adding it to a string until it has three bytes in the string. It then parses each byte of the string out into an int, and assigns values to three variables from those bytes.
This example is written for Processing,by Casey Reas and Ben Fry. It was last updated for beta version 115.