Analog Sensor Reading and RN-XV Wifly Serial Communication System Setup
in Propeller 1
Dear forum,
I currently have several analog sensors connected to an MCP3208, I am displaying the values in the PST (Parallax Serial Terminal). I want to be able to use a RN-XV WiFly Module https://www.sparkfun.com/products/10822 to send the readings from the sensors to a PC/smartphone for displaying purposes. My understanding is that after setting up the wifly device, I only need to connect it to: 3.3V, Tx, Rx, and Gnd, and it will send the data via wifi thru TCP/IP protocol. I am attaching the code that I wrote to transfer the data from the propeller to the wifi as a zip file. My questions are the following:
1. How do I setup the wifly device? What are the optimum settings?
2. Is the code that I wrote correct to transfer the data serially to the wifly?
3. Once the data is sent thru wifi, how do I retrieve it at the PC/smartphone end, I want to be able to read and display the values of the sensors.
Please help me with this setup, I think it will be very helpful for the community to know how to manipulate such device.
Thank you
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
VAR
long data[4], stack[50]
OBJ
adc : "MCP3208"
pst : "FullDuplexSerial"
wifly : "FullDuplexSerial"
CON
dpin = 12
cpin = 13
spin = 14
PUB main
pst.start(31,30,0,9600)
adc.start(dpin, cpin, spin, 255)
cognew(wiflytoPC, @stack[0])
repeat
pst.Str(String("adc channel 0= "))
data[0] := adc.in(0)
pst.dec(data[0])
pst.Str(String(" units", 13))
pst.Str(String("adc channel 1= "))
data[1] := adc.in(1)
pst.dec(data[1])
pst.Str(String(" units", 13))
pst.Str(String("adc channel 2= "))
data[2] := adc.in(2)
pst.dec(data[2])
pst.Str(String(" units", 13))
pst.Str(String("adc channel 3= "))
data[3] := adc.in(3)
pst.dec(data[3])
pst.Str(String(" units", 13))
pst.Str(String(13))
waitcnt(clkfreq * 2 + cnt)
PUB wiflytoPC
wifly.start(2,3,0,9600)
repeat
wifly.dec(data[0])
wifly.Str(String(","))
wifly.dec(data[1])
wifly.Str(String(","))
wifly.dec(data[2])
wifly.Str(String(","))
wifly.dec(data[3])
waitcnt(clkfreq * 5 + cnt)

Comments