Posts: 7
Joined: Sat Feb 11, 2012 11:15 am

PHP Weather Station Scripts for Ultimeter 800 (CWOP)

Mon Nov 26, 2012 10:13 pm

Hi Everyone,

As part of the fun of interfacing things, I have ported some PHP code and a couple of shell scripts to drive an Ultimeter 800 weather station off a RaspPi.

I previously ran this on an NSLU2 unit, but this is smaller, uses less current and offers the ability for a proper console.

I have only just started running this on the Pi, but the results are visible from here:

The details of the system are as follows.
  • *Using Earlier Raspberry Pi Model B with 4Gb SD card and Debian
    *Weather station is a serial-based Ultimeter 800, made by Peet Brothers
    *The serial to USB converter is a standard PL2302 device (details from dmesg in a minute)
    *PHP script to pull the data from the unit of /dev/USB0
    *Shell script to set the serial speed correctly
    *Writes to a local file and then uploads to CWOP (optional)
Attached is the PHP file and a picture of the setup.

So you can check what I am using, the output from dmesg for the serial to USB is as follows

Code: Select all

usb 1-1.3: new full speed USB device number 5 using dwc_otg
usb 1-1.3: New USB device found, idVendor=067b, idProduct=2303
usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.3: Product: USB-Serial Controller D
usb 1-1.3: Manufacturer: Prolific Technology Inc.
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
pl2303 1-1.3:1.0: pl2303 converter detected
usb 1-1.3: pl2303 converter now attached to ttyUSB0
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
The shell script to run the PHP script ( is:

Code: Select all



# Carry out specific functions when asked to by the system
case "$1" in
        echo "Running ultimeter 800 to cwop"
        /usr/bin/php $HOMELOC/wx-silent.php cwop >> $HOMELOC/wx.log
        echo "Running ultimeter 800 locally"
        /usr/bin/php $HOMELOC/wx-silent.php >> $HOMELOC/wx.log
The code is used to correctly set the serial port each time (because sometimes things get changed):

Code: Select all

stty -F /dev/ttyUSB0 ispeed 2400
stty -F /dev/ttyUSB0 ospeed 2400
stty -F /dev/ttyUSB0
Rasp Pi and U800 unit
IMG_0939.jpg (62.4 KiB) Viewed 6405 times
The crontab entry is as follows:

Code: Select all

1,11,21,31,41,51 * * * * /home/pi/cgi-bin/
To use the CWOP element, you will need to register with CWOP. Otherwise use the data locally.

For this to work, ensure you change the CWOP ID in the PHP script (search and you will find it), and also edit your latitude/longitude as well (in the function "FormatAPRSData()").

Offered without warranty but I hope of use out there.

Feedback welcome.

A zipped PHP script to get the data
(4.77 KiB) Downloaded 305 times

Posts: 4
Joined: Tue Sep 18, 2012 3:37 am

Re: PHP Weather Station Scripts for Ultimeter 800 (CWOP)

Wed Jul 03, 2013 4:35 pm

Thanks for the code, I am using it to send in packets from my Ultimeter 2100 - the complete record format is the same.

I did make a change to the wind functions as the wind speeds out of the Peet Bros serial port is in kph, not mph (which is what the CWOP packet should have).

$wind = round(hexdec($gWxData[1])*0.1); //Note this is in steps of 0.1

is what you had...

$wind = round((hexdec($gWxData[1])*0.1)*0.622); //Note this is in steps of 0.1, and 0.622 converts kph to mph

is what I changed it to for both wind functions (Wind5MinPeakSpeedFromWxStn() and WindCurrentSpeedFromWxStn())



Posts: 4
Joined: Tue Sep 18, 2012 3:37 am

Re: PHP Weather Station Scripts for Ultimeter 800 (CWOP)

Fri Jan 24, 2014 7:50 pm

I have made additional changes to the script to better work with my U2100, I posted the new script on my website (



Return to “Automation, sensing and robotics”