#picaxe 18M2
symbol TCP_Send = C.1
eeprom 0, (190,10)
Startup:
read 0,b0
read 1,b1
setfreq m16
serout TCP_Send,T19200_16,("b0 = ",#b0,", b1 = ",#b1,13,10)
Main:
;--------------------------------------------
gosub connectToRouter
pause 10000
gosub sendSplit
b0 = b0 - 1
b1 = b1 + 1
write 0, b0
write 1, b1
read 0,b0
read 1,b1
setfreq m16
serout TCP_Send,T19200_16,("b0 = ",#b0,", b1 = ",#b1,13,10)
Nap 10 '16s nap
goto main
connectToRouter:
pause 5000
setfreq m16
serout TCP_Send,T19200_16,("AT+RST",13,10)
pause 10000
serout TCP_Send,T19200_16,("AT+CWMODE=1",13,10)
pause 10000
serout TCP_Send,T19200_16,("AT+CWJAP=",34,"router name here",34,",",34,"router password here",34,13,10)
pause 20000
serout TCP_Send,T19200_16,("AT+CIPMODE=0",13,10)
pause 10000
serout TCP_Send,T19200_16,("AT+CIPMUX=1",13,10)
pause 10000
return
sendSplit:
; ----------------------------------------------------------
serout TCP_Send,T19200_16,("AT+CIPSTART=0,",34,"TCP",34,",",34,"host website",34,",","80",13,10)
pause 10000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,23",13,10)
pause 1000
serout TCP_Send,T19200_16,("POST /add.php HTTP1.1",13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,20",13,10)
pause 1000
serout TCP_Send,T19200_16,("Host: host website hagain",13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,13",13,10)
pause 1000
serout TCP_Send,T19200_16,("Accept: */*",13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,49",13,10)
pause 1000
serout TCP_Send,T19200_16,("Content-Type: application/x-www-form-urlencoded",13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,20",13,10)
pause 1000
serout TCP_Send,T19200_16,("Content-Length: 17",13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,2",13,10)
pause 1000
serout TCP_Send,T19200_16,(13,10)
pause 1000
serout TCP_Send,T19200_16,("AT+CIPSEND=0,23",13,10)
pause 1000
serout TCP_Send,T19200_16,("temp1=",#b0,"&hum1=",#b1,13,10,13,10,13,10)
return