User`s guide
RN-WIFLYCR-UG
www.rovingnetworks.com Version 1.2r 4/30/13 page 80
4.4.5 Post Binary Data
Web servers expect ASCII data. If the user data is binary, the module can convert it to
ASCII format before sending it to the web server.
EXAMPLE 4-13: EXAMPLE: CONVERT DATA FROM BINARY TO ASCII
4.4.6 Post Sensor Data Automatically
The module can send the value of the GPIO and sensor pins to the web server auto-
matically. The data arrives as 18 bytes of ASCII hex data in the format <2 bytes
GPIO><channel 0 thru 7 sensor data>.
EXAMPLE 4-14: POST SENSOR DATA TO WEB SERVER
set ip proto 18 // Turn on HTTP mode = 0x10 and
// TCP mode = 0x2
set dns name www.webserver.com // Set the web server name
set ip host 0 // Turn on DNS
set ip remote 80 // Set the web server port, 80 is
// standard
set com remote GET$/userprog.php?DATA=
// Sample server application
set option format 1 // Convert binary data to ASCII hex
// format
For example, if the incoming UART data is 6 bytes of binary data with hex values
0x01, 0xAB, 0x03, 0xFF, 0x05, and 0x06, the module sends this string GET /user-
prog.php?DATA=01AB03FF0506\n\n to the web server.
Note: The analog-to-digital convertor is 14 bits on a 400 mV signal, which trans-
lates to about 24 microvolts (0x61A80 in hex). When you use the show q
command in command mode, the module displays the raw readings. How-
ever, for HTTP web posting and UDP broadcast packets, the module shifts
the reading by 4 bits (which is a divide by 16) resulting in a 16-bit number.
Therefore, if you want the actual voltage sampled, you must take the 16-bit
number and shift it left by 4 bits to get the number of microvolts. If you the
value in millivolts (and do not need high accuracy), right shift by another 6
bits, which is the same as dividing by about 1K.
set ip proto 18 // Turn on HTTP mode = 0x10 and
// TCP mode = 0x2
set dns name www.webserver.com // Set the web server name
set ip host 0 // Turn on DNS
set ip remote 80 // Set the web server port, 80 is
// standard
set com remote GET$/userprog.php?DATA=
// Sample server application
set q sensor 0xff // Module samples all 8 sensor channels
set sys auto 30 // Connect every 30 seconds
set option format 7 // Send the header plus the sampled
// binary data converted to ASCII format