Code:
'<FL_PIC18F4550>'
DEFINE OSC 48
@ __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L
'############################ #
ADCON1 = 001110
CNT VAR BYTE
CNT = 0
OUT_TEMP VAR BYTE
ADC_TEMP VAR WORD
S_TEMP VAR BYTE
D_LAY VAR BYTE
ADR VAR BYTE [9]
TX VAR PORTD.6 ;ORANGE
RX VAR PORTD.7 ;YELLOW
X_TEMP VAR BYTE
PAUSE 2000
INTCON.5 = 1 'ENABLE TMR0
T0CON = 000101 ON INTERRUPT GOTO TLOOP
BOOT: 'iCHIP SET UP
SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC OUT_TEMP,$d,$a,$d ,$a]
PAUSE 500SEROUT2 TX,6,[ "AT+I",$d ,$a]
SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ]
SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ]
SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
GOSUB DIP
PAUSE 2000
SEROUT2 TX,6,["AT+iWWW",$d,$a]
SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
;#############################
EMAIL_SET:
SEROUT2 TX,6,["AT+iSBJ:MAC_ETHERNET",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iTOA:[email protected]",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+ito:MACKRACKIT",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iREA:[email protected]",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFRM:MAC_ETH",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMTP:mail.mf3x3.com",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMA=1",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMP:booger",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMU:[email protected]",$d,$a]
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
FTP:
CNT = CNT + 1
SEROUT2 TX,6,["AT+i",$d,$a]
SEROUT2 TX,6,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
SEROUT2 TX,6,["AT+iFOPN:192.168.2.16:mac,999999",$d,$a]'OPEN SESSION
SERIN2 RX,6,1000,BOOT,[WAIT("I/000")]
PAUSE 100
SEROUT2 TX,6,["AT+iFCWD:000,ichip",$d,$a]
SERIN2 RX,6,1000,BOOT,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFSTO:000,",$22,"ichip.txt",$22,$d,$a]
SERIN2 RX,6,1000,BOOT,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFSND:000,19:"," The temperature is",$d,$a]:PAUSE 100
SEROUT2 TX,6,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
SEROUT2 TX,6,["AT+iFSND:000,18:",DEC OUT_TEMP," F In the shop.",$d,$a]:PAUSE 100
SEROUT2 TX,6,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
SEROUT2 TX,6,["AT+iFSND:000,12:",DEC CNT," MINUTES.",$d,$a]:PAUSE 100
SEROUT2 TX,6,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
PAUSE 100
SEROUT2 TX,6,["AT+i",$d,$a]':PAUSE 100
SERIN2 RX,6,100,BOOT,[WAIT("I/OK")] :PAUSE 100
GOSUB GET_TFOR D_LAY = 1 TO 120
PAUSE 500
NEXT D_LAY
IF CNT = 2 THEN EMAIL
IF CNT > 60 THEN CNT = 0
GOTO BOOT
END
EMAIL:
SEROUT2 TX,6,["AT+iEMA:",$d,$a]
SEROUT2 TX,6,["HI, THIS IS FROM MAC_ETH",$d,$a]
SEROUT2 TX,6,["SENT EVERY HOUR.",$d,$a]
SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
SEROUT2 TX,6,[DEC OUT_TEMP,"F IN THE SHOP.",$d,$a]
SEROUT2 TX,6,["GO TO:",$d,$a]
SEROUT2 TX,6,["http://mackrackit.com/mac/ichip/ichipw.py",$d,$a]
SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
SEROUT2 TX,6,[$d,$a,".",$d,$a]
SERIN2 RX,6,60000,BOOT,[WAIT("I/ONLINE")]
PAUSE 1000
SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a]
HIGH PORTD.0
PAUSE 1000
LOW PORTD.0
GOTO BOOT
DIP:
IF !ADR[1] AND !ADR[1] AND !ADR[2] AND !ADR[3] THEN SEROUT2 PORTC.3,16780,[" NOT "]
SEROUT2 PORTC.0,16468,[" CONNECTED ",$d,$a]
SEROUT2 PORTC.0,16468,["ADR - " ,DEC3 ADR[0],".",DEC3 ADR[1],".",DEC3 ADR[2],".",DEC3 ADR[3],$d,$a]
PAUSE 1000
RETURN
BROKE:
SEROUT2 PORTC.0,16468,["NOT WORKING",$d,$a]
PAUSE 500
GOTO BOOT
GET_T:
ADC_TEMP = 0
FOR X_TEMP = 1 TO 20
ADCON0=00000001
GOSUB READ_AD
S_TEMP = ADRESH
ADC_TEMP = ADC_TEMP + S_TEMP
PAUSE 250
NEXT X_TEMP
OUT_TEMP = ADC_TEMP / 20
OUT_TEMP = OUT_TEMP * 13/10
RETURN
READ_AD:
PAUSE 50
ADCON0.1=1
WHILE ADCON0.2=1:WEND
RETURN
DISABLE
TLOOP:
INTCON.2=0:TOGGLE PORTD.0
RESUME: ENABLE
Bookmarks