View Full Version : mackrackit's ConnectOne example code
dhouston
- 25th May 2011, 15:57
Here's a link to his ConnectOne example (http://mackrackit.com/mac/ichip/ichip.html).
Pros: The ConnectOne modules have a complete set of internet protocols and all the coding is similar to that in the mackrackit example. Configuration can be done via the ethernet or serial connection. The modules do all of the heavy lifting. IMO, these are the easiest to use.
Drawbacks: Their modules take up more real estate than some others and mounting them to a mainboard is problematic in some cases. They do not fit breadboards. The code burden of the AT commands can add up quickly.
mackrackit
- 26th May 2011, 06:27
Another drawback with the ConnectOne is it can not be setup to use "non-standard" ports when using it as a web server. Port 80 and 443 are it.
About a year ago I asked them about it and they told me they were working on new firmware. Maybe the new firmware is out but I have not seen it..
jellis00
- 21st June 2011, 18:35
Here's a link to his ConnectOne example (http://mackrackit.com/mac/ichip/ichip.html).
Pros: The ConnectOne modules have a complete set of internet protocols and all the coding is similar to that in the mackrackit example. Configuration can be done via the ethernet or serial connection. The modules do all of the heavy lifting. IMO, these are the easiest to use.
Dave, I am considering using a ConnectOne MiniSocketWiFi Module for a battery operated wireless application because it has a shutdown mode that only consumes 40 uA...which is lowest consumption that we have found in any other wireless module.
We intend on sending it data via its asynchronous serial interface (no flow control) for WiFi transmission. However, after reviewing the data sheet for the MiniSocketWiFi module we are confused as to whether it requires use of the DTS and DSR handshaking interfaces. Your posting here doesn't say which ConnectOne module you are using, but I would very much like to see a reference design if you have one and an explanation of how you are wiring the serial interface...maybe even a schematic?
Would also like to know from your example the delay time from AT message transmission to the ConnectOne until the WiFi message is actually transmitted via WiFi if you by chance have measured it or can estimate it?
dhouston
- 21st June 2011, 20:41
Just tie the handshaking lines (nCTS,nRTS) together if you are not using them.
In the ethernet shields, I bring them out to a point where you can solder a wire jumper between them.
I've put up a web page with the shields and some other related things here...
http://davehouston.org/Arduino.htm
All the connections are shown on the shields.
I don't have the iWiFi but only the SocketLAN so I cannot answer about the delay. Maybe the other Dave can.
In general I've found that the translation delay between serial and other protocols isn't noticed until you try something intensive like updating firmware over the link where the translation time and handshaking for error checking become a larger factor.
As for the current draw, the various serial-to-WiFi adapters are all over the map. I was considering a shield using a WIZNet module (which I do have) until I saw it used about twice as much current when transmitting than others.
BTW, look into BR type batteries if you haven't already.
mackrackit
- 22nd June 2011, 10:50
I have only used the Nano LANReach, Nano SocketLAN, and Nano Socket iWiFi modules. The only data connections used are the TX and RX from MCU to the ConnectOne module.
I never noticed a delay and have not taken the time to measure what it is, has to be some. For what it is worth, the
SERIN2 RX ,BAUD,2500,EMAIL_SET,[WAIT("I/OK")]
has to be the very next line of code after an "AT+Ixx" command is sent. The "I/OK" will be missed if the SERIN command is placed in a sub routine, so the ConnectOne seems pretty fast.
jellis00
- 23rd June 2011, 02:32
I have only used the Nano LANReach, Nano SocketLAN, and Nano Socket iWiFi modules. The only data connections used are the TX and RX from MCU to the ConnectOne module.
Dave,
I have been reviewing the data sheet for the MiniSocket WiFi module and can't find ansers to following questions. Can you or anyone else on this thread answer them??
1)When using a UART serial interface from the MCU to the MiniSocket to perform asynchronous data transfer, should the TXD pin of the MiniSocket be connected to the RX pin of the MCU? Similarly, should the RXD pin of the MiniSocket be connected to the TX pin of the MCU? I ask this because the Nano WiReach reference design sent to me by ConnectOne has TXD to TX and RXD to Rx, which is contrary with most MCU serial interfaces I have seen.
2)We are not going to use flow control on the serial interface so we are tying the -CTS and –RTS pins together. However, we can’t determine from the MiniSocket data sheet whether we need to use the handshaking interfaces with DTR and DSR or not when performing asynchronous serial data transfer with the MiniSocket from the MCU. I notice the ConnectOne reference design for the Nano WiReach did show the DTR and DSR interfaces implemented, yet in most asynchronous serial interfaces we have seen with a PIC MCU they are not used. Please clarify??
3) It is my understanding that the MiniSocket (which is a 3.3 v device) is not tolerant to 5v logic signals. Our application is all 5v circuits. Any suggestions on how to convert the 5v logic of the MCU to 3.3v logic for the MiniSocket with minimum hardware....our board is already very densely populated and can't afford a lot of additional components.
Really appreciate any comments/answers to these questions.
John
dhouston
- 23rd June 2011, 03:47
I'm the other Dave but I'll give you my responses to your questions, anyway.
1. Cross-connect them.
2. The Mini Socket iWiFi datasheet explicitly says to connect CTS/RTS if they are not used but says nothing about DTR/DSR so I don't think you need to connect them but you probably should ask this of Connect One Support.
3. I dropped my intent to make the shield work with 5V and 3.3V because it was just to complicated with all the SPI lines on the other modules. However, with the Mini Socket iWiFi, we are only dealing with two inputs and one output. The way I prefer to handle this is with a transistor and two resistors for each line. You can see example circuits in FIG 15 of AN213 (http://www.zbasic.net/appNotes/AN213.pdf).
mackrackit
- 23rd June 2011, 10:49
What Dave said...
I will add..
When ConnectOne says TXD to TX they are meaning cross over.
If I were you I would make a point to start designing things for 3.3... But in the mean time
here are more possible solutions, or the same ?
http://ww1.microchip.com/downloads/en/DeviceDoc/chapter%208.pdf
dhouston
- 23rd June 2011, 11:54
I should have mentioned that the Mini Socket iWiFi datasheet says for RXD...
Input - Host Data Receive – Asynchronous serial data received from host.anf for TXD...
Output - Host Data Send – Asynchronous serial data sent to host.
jellis00
- 23rd June 2011, 23:14
What Dave said...
If I were you I would make a point to start designing things for 3.3...
Thanks for the URL to the Tips file. The only reason I am still using 5.0 volts for the MCU is I am using one of the GPIO pins to power on and off a SRF02 Ultrasonic Ranger, which only operates on 5.0v. I am using two LDO regulators, one for 9v to 5.0 v to power the MCU (and the SRF02), and one further downstream for 5.0v to 3.3v to power the ConnectOne WiFi module.
jellis00
- 23rd June 2011, 23:19
I should have mentioned that the Mini Socket iWiFi datasheet says for RXD...anf for TXD...
Thanks, Dave. I also got a Tech Support input from OneConnect saying to connect TXD to MCU's RX and RXD to MCU's Tx, -DTR to ground, -DSR unconnected, and -CTS connected to -RTS. So this clarifies the serial interface requirements for their MiniSocket WiFi module with a PIC MCU.
jellis00
- 23rd June 2011, 23:27
3. I dropped my intent to make the shield work with 5V and 3.3V because it was just to complicated with all the SPI lines on the other modules. However, with the Mini Socket iWiFi, we are only dealing with two inputs and one output. The way I prefer to handle this is with a transistor and two resistors for each line. You can see example circuits in FIG 15 of AN213 (http://www.zbasic.net/appNotes/AN213.pdf).
Other Dave,
I appreciate your referral to this app note...it has a lot of good ideas in it. However, for the level shifting I have to do between the 5V logic on the PIC MCU and the 3.3v logic on the MiniSocket iWiFi module, I am going to give the Sparkfun device a try (see http://www.sparkfun.com/products/8745 ). It is low cost and gives me enough channels to handle the problem. Have you or anyone had any experience with it?
dhouston
- 24th June 2011, 00:44
Have you or anyone had any experience with it?Yes, I've used it when breadboarding. In fact, I meant to include it in my post but could not find it with a quick search at Spark Fun. (I lost a network drive a few months back which had a lot of my notes, etc. and most of my toys are still in storage after a lengthy hospitalization last year.) It should work fine here.
Also, either the Tips file referenced by mackrackit or a similar one from Microchip (I think.) has tips on getting 5V from 3.3V. For example, if you're using a MAX232 or similar line driver, you can steal 10-12V from it. Of course, it depends on the current needs of your 5V device.
isaac
- 19th August 2011, 15:02
i am waiting for delivery of Nano Lan Reach
http://www.connectone.com/media/upload/Nano_LAN_Reach_PB_01.pdf
but i am not clear as to if i use one of your shelds as below
http://davehouston.org/Arduino.htm (http://davehouston.org/Arduino.htm)
just a few questions
i would be using this with a pic18f452 running at 5v and i know the data sheets for the nano runs at 3v3
if i do supply if it 3v3 do i need to to anything to the Tx/Rx lines or do they have to be 3v3 as well.
On you board is this already taken care of
Regards
isaac
dhouston
- 19th August 2011, 16:04
Yes, if you run the PIC at 5V and the ConnectOne module at 3.3V you will need to do level conversion in both directions.
My shields have been delayed. I had a bout of atrial fibrillation resulting in a brief (4 day) hospitalization but some not so brief medical bills which have blown holes in my budget. All my projects have been set aside for the time being.
The Spark Fun level shifter mentioned above should do what you need. (The AN213 link also shows a few different methods.) You need to deal with TX, RX & RESET. Outputs from the module (TX) need to be shifted up to 5V for input to the PIC, inputs to the module (RX, RESET) need to be shifted down to 3.3V.
isaac
- 19th August 2011, 18:43
I hope you get better as quick as possible i now get it clearly
mister_e
- 19th August 2011, 20:38
Speedy recovery, take it easy in meantime.
dhouston
- 19th August 2011, 23:27
I'm fine. I've had Congestive Heart Failure for about 9 years and all is under control by medication. My primary care doc even commented that I have the vital signs of a 20 year old (seems a shame to waste them on a 70 year old). And, tests in the hospital confirmed that my heart is still normal in size and pumping efficiency (ejection fraction) with no water around it.
I just got caught in a couple of bureaucratic snafus not of my own making. I get my meds from the Veterans Administration. I was moving and the VA refused to accept my change of address over the phone, telling me I had to come, in person, with a piece of mail in-hand that I received at the new address. Simultaneously, my cardiologist for the past 9 years (outside the VA) was forced to close his practice by a non-compete lawsuit brought by the very hospital I ended up in which had recently bought the group practice he had been a member of but chose to leave after the sale. I could not reach him to get a prescription so I ran out of two critical meds which regulate BP and pulse rate. I'm back on my medication and even the VA accepted my new address with no further red tape so my supply is assured for awhile.
I just need to clear all the hospital/doctor bills before spending anything on toys.
But, thanks for the good wishes.
ofuzzy1
- 20th August 2011, 21:44
Dave H,
Glad you're doing well and still on this side of the grass.
And THANK YOU for your service.
Fuzzy
jellis00
- 17th September 2011, 04:06
Mackrackit, I know your ConnectOne example code is for a Nano Socket iWiFi module configurtion, whereas I am working with a iWiFi MiniSocket module, but I am trying to interpret some of your code to help me figure out how to program my 18F4550 as the embedded host for the MiniSocket. Without your schematic I am confused as to what connections on the iWiFi module are used with the PortC.4 and PORTC.3 connections on the MCU. Could you please post a schematic to help understand the purpose of the different connections between your 16F873A/iWifi module?
Am also confused by some of your code:
Are you using the sequential HIGH and then LOW statements for PORTC.4 to perform somekind of reset of the iWiFi module?
When you use the SEROUT2 statements with PORTC.3, what are you doing when you send ["iChipO OK"] and ["TEST_",DEC3 CNT, 13, 10]?
I also don't understand the purpose of the DIP subroutine??
Can you please explain these statements to me?
mackrackit
- 17th September 2011, 08:08
The DIP routine is for parsing the address that the router assigned to the iChip.
When you use the SEROUT2 statements with PORTC.3, what are you doing when you send ["iChipO OK"] and ["TEST_",DEC3 CNT, 13, 10]?
PORTC.3 goes straight to a terminal for debugging. ["iChipO OK"] is what the iChip returns after a successful operation, I would pass that to a terminal to see if things were working. The code counts to 60 before an email is sent, ["TEST_",DEC3 CNT, 13, 10] is to see what the count is.
HIGH PORTC.4 :PAUSE 250: LOW PORTC.4: PAUSE 500
' Is a crude "heart beat" to see if the MCU is running.
Below is pretty much the same code but for a 18F4550 along with the hookup.
I know, I should use more comments...
'<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
dhouston
- 17th September 2011, 13:38
And you can see the mini iWiFi connections here (http://davehouston.org/ConnectOne_top.JPG) and here (http://davehouston.org/ConnectOne_x-ray.JPG).
jellis00
- 18th September 2011, 08:21
Dave, I have adapted your 18F4550 code you included in your above post into a version that uses my schematic and an 18F2550. I have a protoboard configured to my schematic with the MiniSocket mounted on it. I have studied the AT+ Programmers Manual and I believe I understand all the coding and have it correct, but it wouldn't work. The only way I have to trouble shoot this is to embed WRITE to EEPROM statements at incremental locations to isolate where the problems are. I have discovered that in two places the code will not execute beyond certain statements even though this code compiles and assembles OK. If you look at my attached code (which is closely adapted from yours) you will see where the embedded WRITE statements bracket two statements that don't execute. One is a PAUSE 2000 statement that for the life of me I don't understand why it won't execute when uncommented. Can you see why?
The other is obviously telling me that the MiniSocket module is not resonding to the AT+I message and is therefore going to the BROKE label, which tells me that either the MiniSocket module is dead or my board level serial interface is not wired correctly.
I am hoping you might help me trouble shoot this by looking at this code and my attached interface and tell me where I have gone wrong. Would GREATLY appreciate it!
'<FL_PIC18F2550>'
DEFINE OSC 48 ' Using 8 MHz crystal
@ __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_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 &_XINST_OFF_4L
'#############################
'ADCON1 = 001110 ' different A/D setup in temperature routine
CNT VAR BYTE
CNT = 0
temp VAR BYTE
WRITE 3,3 'EEPROM test to see if program executes to here..it does
'ADC_TEMP VAR WORD 'not used in new temperature routine
'S_TEMP VAR BYTE 'not used in new temperature routine
D_LAY VAR BYTE
ADR VAR BYTE [9] 'array for IP address elements
TX VAR PORTC.6 'differnt ports used for WiFi module interface
RX VAR PORTC.7
'X_TEMP VAR BYTE 'not used in new temperature routine
WRITE 3,3 'EEPROM test to see if program executes to here..it does
'PAUSE 2000 'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
WRITE 4,4 'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
'INTCON.5 = 1 'ENABLE TMR0 interrupt not used
'T0CON = 000101
'ON INTERRUPT GOTO TLOOP
'*****************SETUP FOR USING LM34 Temperature Sensor**************
'DEFINE osc 8 ' Using a 16 MHz oscillator..already defined
DEFINE ADC_BITS 10 ' Set A/D for 10-bit operation
DEFINE ADC_CLOCK 5 ' Set A/D clock Fosc/16
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
samples VAR WORD ' Multiple A/D sample accumulator
sample VAR BYTE ' Holds number of samples to take
value VAR WORD ' Holds LM34 measured temperature value
BOOT: 'iCHIP SET UP
'SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC temp,$d,$a,$d ,$a] 'test not used
PAUSE 500
SEROUT2 TX,6,[ "AT+I",$d ,$a]
WRITE 5,5 'EEPROM test to see if program executes to here..it does
SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK")]
WRITE 6,6 'EEPROM test to see if program executes to here..it doesn't!
' ABOVE TEST INDICATESInterface to iChip is NOT working!
'SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ] 'test not used
'SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ] 'test not used
SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
WRITE 10, ADR[0] ' Write the received IP address to EEPROM as a test
WRITE 11, ADR[1]
WRITE 12, ADR[2]
WRITE 13, ADR[3]
GOSUB DIP
PAUSE 2000
'SEROUT2 TX,6,["AT+iWLWM=1",$d,$a] ' Sets WEP enabled with 64bit key
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
'SEROUT2 TX,6,["AT+iWLKI=1",$d,$a] ' Sets the Wireless LAN transmission WEP-Key index
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
'SEROUT2 TX,6,["AT+iWLKn1=xxxxxxxxxx",$d,$a] ' Sets the Wireless LAN WEP key
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
SEROUT2 TX,6,["AT+iWLSI=Buckskin",$d,$a] ' Sets the destination Wireless LAN SSID
SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
SEROUT2 TX,6,["AT+iWWW",$d,$a] ' Activates iChip's internal web server
SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
;#############################
EMAIL_SET:
SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iTOA:
[email protected]",$d,$a] 'Permanently sets Email addressee
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+ito:jellis00",$d,$a] 'Permanently sets Email header s =To: description
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iREA:
[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a] 'Permanently sets Email header =From: description.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMTP:mail.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMA=1",$d,$a] 'Permanently sets SMTP authentication method
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a] 'Permanently sets authenticated SMTP login
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMU:
[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
FTP: 'not using FTP but left this for timing
CNT = CNT + 1
GOSUB GET_T
FOR D_LAY = 1 TO 120 ' 60 seconds delay
PAUSE 500
NEXT D_LAY
IF CNT = 2 THEN EMAIL ' Send EMAIL every 2 minutes
IF CNT > 2 THEN CNT = 0 ' During testing set for two minute cycle
WRITE 15, temp 'test of temperature reading
GOTO BOOT
END
EMAIL:
SEROUT2 TX,6,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
SEROUT2 TX,6,["SENT EVERY 2 minutes.",$d,$a]
SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
SEROUT2 TX,6,["GO TO:",$d,$a]
SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
SEROUT2 TX,6,[$d,$a,".",$d,$a]
SERIN2 RX,6,[WAIT("I/ONLINE")]
PAUSE 1000
'SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a] 'test not used
WRITE 5,$01 ' Write 1 to EEPROM as test if Email sent
HIGH PORTC.5 ' blink green led as test to show email sent
PAUSE 1000
LOW PORTC.5
GOTO BOOT
DIP:
'IF (!ADR[1]) AND )!ADR[1]) AND (!ADR[2]) AND (!ADR[3]) THEN
HIGH PORTC.6 'blink red led as test if not connected
PAUSE 1000
LOW PORTC.6
'ENDIF
'SEROUT2 PORTC.0,16468,[" CONNECTED ",$d,$a] ' test not used
'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] 'Commented out for now
WRITE 16, "B" 'Record in EEPROM as test if Broke
PAUSE 500
GOTO BOOT
GET_T: ' Subroutine to measure temperature from LM34
'===========
' This subroutine is an adaptation from below reference to 10-bit A/D
'************************************************* ***************
'* Name : LM34.BAS *
'* Author : Bruce Reynolds *
'* Date : 10/23/2001 *
'* Version : 1.0 *
'* Notes : 8-bit A/D temperature conversion with National *
'* ; LM34CAZ analog temperature sensor. *
'* : See http://www.rentron.com/PicBasic/LM34.htm *
'************************************************* ***************
samples = 0 ' Clear samples accumulator on entry
' Setup registers for A/D input per Sec 21.0 of datasheet
'1. Configure the A/D module:
' Configure analog pins, voltage reference AND I/O (ADCON1)
ADCON1 = %00000011 'Vdd as ref; all analog except AN12 (RB0)
' SELECT A/D INPUT channel (ADCON0)
ADCON0 = %001011000 'Set AN11 (PORTB.4) as A/D input but disabled
' SELECT A/D acquisition time & A/D conversion clock (ADCON2)
ADCON2 = %10110101 'Right justified;TAD=16;A/D clock=Fosc/16
' Turn ON A/D module (ADCON0)
ADCON0.0 = 1 'Enable the A/D module
'2. Configure A/D INTERRUPT (IF desired):
' CLEAR ADIF BIT
' Set ADIE BIT
' Set GIE BIT
'3. WAIT the required acquisition time (IF required).
'PAUSE 250 ' Wait approximately 1/4 seconds per loop
'4. Start conversion-Set GO/DONE BIT (ADCON0 register)
ADCON0.1 = 1
'5. WAIT FOR A/D conversion TO complete, by either:
' Polling FOR the GO/DONE BIT TO be cleared
'OR
' Waiting FOR the A/D INTERRUPT
FOR sample = 1 TO 20 ' Take 20 samples
ADCIN 11, value ' Read channel 11 into temp variable
'PAUSE 2
' or use alternative manual method to read A/D input
'WHILE ADCON0.1 : WEND
'6. READ A/D Result registers (ADRESH:ADRESL);
'CLEAR BIT ADIF, if required.
'value.HIGHBYTE = ADRESH
'value.LOWBYTE = ADRESL
samples = samples + value ' Accumulate 20 samples
'7. FOR NEXT conversion, go TO STEP 1 or STEP 2, as
'required. The A/D conversion time per BIT IS
'defined as TAD. A minimum WAIT of 3 TAD IS
'required before the NEXT acquisition starts.
PAUSE 250 ' Wait approximately 1/4 seconds per loop
NEXT sample
value = samples/20 ' Determine average of 20 measurements
'ADC Math for 10-bit A/D when using Vdd as referenc
'ADC Resolution = 4.99 V/1024 COUNT = 4.912109 mV/COUNT
'=> LM34DZ OUTPUT voltage (mV) = 2 x COUNT
'Temperature ( F) = LM34 OUTPUT voltage in mV/10
'=> Temperature ( F) = 4.912109 x COUNT/10 = 0.4912109*COUNT
' Therefore temp = 0.4912109*Count or approx. = Count/2.036
' To avoid floating point math, multiply by 1000 and then DIV32
value = 1000 * value
temp = DIV32 2036
'temp = value
samples = 0 ' Clear old sample accumulator for next cycle
ADCON1 = 255 ' Go to all digital ops
RETURN
'DISABLE 'Interrupt not used
'TLOOP:
'INTCON.2=0:
'TOGGLE PORTC.5
'RESUME: ENABLE
5987
mackrackit
- 18th September 2011, 11:22
With 8 MHz in and wanting to run the chip at 48 MHz
@ __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
And the "level" converter should not be used with mode 6, with the converter in place try mode 16390.
http://melabs.com/resources/ser2modes.htm
(http://melabs.com/resources/ser2modes.htm)
The iChip config utility might help make sure the module is setup correctly
http://www.connectone.com/support.asp?did=30
(http://www.connectone.com/support.asp?did=30)They say vista is not supported by I run it on win 7. Set a restor point just to be safe...
Thats what I see....
jellis00
- 20th September 2011, 01:57
Thanks, Dave. I implemented all of your suggested changes to my 18F2550 adaptation of your example code and the MiniSocket module still doesn't connect to my wireless router/PC. I also tried to use the iChip Config Utility to setup and test the module, but discovered you have to have a serial interace that connects directly to the WiFi module to use it... which I don't have on my PCB implementation. So I looked for another way to setup and test my MiniSocket module and discovered in the Programmers Manual the Easy Configuration method (pg 142 of Programmer's Manual). Per that method, I programmed the MCU to send an AT+iFD command to the module to reset it to Factory Default settings, which will supposedly search for and link up with any AD-HOC AP in range so that you can use this method to get your PC connected to the module to setup the desired configuration for your application. What I discovered leads me to believe that my particular MiniSocket module is a bad one. Take a look at this code and the embedded and commented WRITE EEPROM test and please tell me if you concur with that conclusion.
'<FL_PIC18F2550>' ' Set MCU type for FineLine Editor
'**************** Configure MCU and set port registers ********************
DEFINE OSC 48 ' Using 8 MHz crystal
@ __CONFIG _CONFIG1L, _PLLDIV_2_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 &_XINST_OFF_4L
TRISA = 0 ' Reserve PortA as outputs for LCD use
TRISB = %00011100 ' RB2 & RB3 reserved as RTC Alarm1 & Alarm2 inputs
' PORTB.2 is also an interrupt from manual switch GND
' PORTB.4 is set as A/D Channel 11 input
TRISC = %10000000 ' Set PortC to all outputs except PortC.7 which is
' reserved as RX input.
' PortC.1 is output for MSEL to WiFi module
' PortC.2 is used for the LCD R/W connection when
' LCD present..otherwise as _RES_PD to Wifi Module.
' PortC.4 is output to LED_RED
' PortC.5 is output to LED_GRN
'********************* Declare Variables and Aliases **********************
WRITE 2,2 'EEPROM test to see if program executes to here..it does
LED_RED VAR PortC.4 ' Red LED
LED_GRN VAR PortC.5 ' Green LED used to indicate Routine entries
MSEL VAR PORTC.1 ' iChip Mode Select
_RES_PD VAR PORTC.2 ' iCHIP RESET/Power-Down
TX VAR PORTC.6 ' ports used for WiFi module serial interface
RX VAR PORTC.7
'X_TEMP VAR BYTE 'not used in new temperature routine
WRITE 3,3 'EEPROM test to see if program executes to here..it does
PAUSE 2000 'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
WRITE 4,4 'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
' Blink LED_GRN 2X times to indicate iChip test started
FOR I = 0 TO 1
HIGH LED_GRN
PAUSE 500
LOW LED_GRN
PAUSE 500
NEXT
'***************** SETUP FOR USING iWiFi MiniSocket Module ***************
BOOT: 'iCHIP SET UP
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
PAUSE 10000
HIGH MSEL ' Set high for normal AT+i ops
PAUSE 500
SEROUT2 TX,16390,[ "AT+iFD",$d ,$a] ' Reset iChip to factory defaults
WRITE 5,5 'EEPROM test to see if program executes to here..it does
SERIN2 RX ,16390,2500,BROKE,[ WAIT("I/OK")]
WRITE 6,6 'EEPROM test to see if program executes to here..it doesn't!
' ABOVE TEST INDICATES Interface to iChip is NOT working!
BROKE:
WRITE 16, "B" 'Record in EEPROM as test shows iChip broke
WRITE 7,7 'EEPROM test to see if program executes to here..it doesn't!
' Blink LED_RED 2X times to indicate iChip not working
FOR I = 0 TO 1
HIGH LED_RED
PAUSE 500
LOW LED_RED
PAUSE 500
NEXT
GOTO BOOT
jellis00
- 20th September 2011, 02:20
CORRECTION TO CODE. Please ignore the code in previous post in favor of this one. Would really appreciate opinion as to whether this test code is telling me the MiniSocket has failed or not.
'<FL_PIC18F2550>' ' Set MCU type for FineLine Editor
'**************** Configure MCU and set port registers ********************
DEFINE OSC 48 ' Using 8 MHz crystal
@ __CONFIG _CONFIG1L, _PLLDIV_2_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 &_XINST_OFF_4L
TRISA = 0 ' Reserve PortA as outputs for LCD use
TRISB = %00011100 ' RB2 & RB3 reserved as RTC Alarm1 & Alarm2 inputs
' PORTB.2 is also an interrupt from manual switch GND
' PORTB.4 is set as A/D Channel 11 input
TRISC = %10000000 ' Set PortC to all outputs except PortC.7 which is
' reserved as RX input.
' PortC.1 is output for MSEL to WiFi module
' PortC.2 is used for the LCD R/W connection when
' LCD present..otherwise as _RES_PD to Wifi Module.
' PortC.4 is output to LED_RED
' PortC.5 is output to LED_GRN
'********************* Declare Variables and Aliases **********************
WRITE 2,2 'EEPROM test to see if program executes to here..it does
I VAR BYTE ' For-Next Loop index
LED_RED VAR PortC.4 ' Red LED
LED_GRN VAR PortC.5 ' Green LED used to indicate Routine entries
MSEL VAR PORTC.1 ' iChip Mode Select
_RES_PD VAR PORTC.2 ' iCHIP RESET/Power-Down
TX VAR PORTC.6 ' ports used for WiFi module serial interface
RX VAR PORTC.7
'X_TEMP VAR BYTE 'not used in new temperature routine
WRITE 3,3 'EEPROM test to see if program executes to here..it does
PAUSE 2000 'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
WRITE 4,4 'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
' Blink LED_GRN 2X times to indicate iChip test started
FOR I = 0 TO 1
WRITE 5,5 'EEPROM test to see if program executes to here..it does
HIGH LED_GRN
PAUSE 500
LOW LED_GRN
PAUSE 500
NEXT
'***************** SETUP FOR USING iWiFi MiniSocket Module ***************
BOOT: 'iCHIP SET UP
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
WRITE 6,6 'EEPROM test to see if program executes to here..it does
PAUSE 10000
HIGH MSEL ' Set high for normal AT+i ops
PAUSE 500
SEROUT2 TX,16390,[ "AT+iFD",$d ,$a] ' Reset iChip to factory defaults
SERIN2 RX ,16390,2500,BROKE,[ WAIT("I/OK")]
WRITE 7,7 'EEPROM test to see if program executes to here..it doesn't!
' ABOVE TEST INDICATES Interface to iChip is NOT working!
END
BROKE:
WRITE 16, "B" 'Record in EEPROM as test shows iChip broke
WRITE 8,8 'EEPROM test to see if program executes to here..it doesn't!
' Blink LED_RED 2X times to indicate iChip not working
FOR I = 0 TO 1
HIGH LED_RED
PAUSE 500
LOW LED_RED
PAUSE 500
NEXT
GOTO BOOT
mackrackit
- 20th September 2011, 15:24
This part really has me baffled
WRITE 3,3 'EEPROM test to see if program executes to here..it does
PAUSE 2000 'FOR SOME REASON PROGRAM DOESN'T EXECUTE PAST HERE IF STATEMENT IS UNCOMMENTED
WRITE 4,4 'EEPROM test to see if program executes to here..it doesn't if above statement uncommented!
Obviously pointing to a larger problem but I can not think what it is. Need to get this fixed first.
Anyone see what I am missing?
cncmachineguy
- 20th September 2011, 18:50
I don't see any reason for it not to be, but are you able to verify the PIC is actually running at 48Mhz? It seems there can only be 3 reasons to get stuck on a pause: Just taking forever because the clock is wrong, PIC is resetting - WDT maybe? or something is corroupting system variables causing PAUSE to mess up. I don't think it's the last option, no interrupts shown so what else could corrupt it? WDT and MCLR are both turned off. so that seems like it takes option 2 out. Leaves us to clock. The configs look correct, Maybe the crystal is not working/connected/...
jellis00
- 10th October 2011, 06:00
Delay of this reply was due to me having to get a new ConnectOne iWiFi Mini Socket Module. I fried the other one.
Also spent time while waiting for new module to get the application code working to requirements up to integration of the iWiFi. My application works perfectly up to the point of integration of the module, which I got yesterday. Spent today trying to get it to work with my application. Here is how my applications works.
1) My application receives a periodic RBC_INT interrupt from the Alarm1 (_INTA) signal sent from a DS1337 RTC.
2) Upon receipt of the interrupt the service routine measures a temperature and depending on the temperature initiates an email via iWiFi.
Everything is working up to here. I hope you guys will help me figure out why the iWiFi and email process isn't working. If you need to see the full schematic of the application it is in a post I made in the Schematic forum regarding a question I had on Oring the backup battery with the Vcc supply for the RTC.
I adapted Dave's ConnectOne example code by breaking it into a set of subroutines to integrate the iWiFi function into my application. My appliction is running on a 16F886 MCU that has a serial interface to the module via a SparkFun serial level converter (MCU is at 5 v....module is at 3.2v). I have double checked the pin/trace interfaces on the PCB and I think they are correct. I will list the subroutines and explain how I intended the process to work below. You will notice I use a lot of WRITE statements to EEPROM for post run evaluation/testing and also a lot of RED and GREEN LED blinking codes for run-time testing. I have annotated each write statement as to whether the code works to that point or not.
Here is the routine called by the interrupt service handler to initiate the Email process...every thing works up to here:
Email:
' Blink Green LED 1x long at start of Email routine
TOGGLE LED_GRN
PAUSE 1000
TOGGLE LED_GRN
PAUSE 2000
GOSUB BOOT ' Setup WiFi module for ops if installed
' Executuon fails in BOOT and never gets to this point...see WRITE statement notes in BOOT routine below
EMAIL_SET:
SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iTOA:
[email protected]",$d,$a] 'Permanently sets Email addressee
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+ito:jellis00",$d,$a] 'Permanently sets Email header s =To: description
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iREA:
[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a] 'Permanently sets Email header =From: description.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMTP:mail.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMA=1",$d,$a] 'Permanently sets SMTP authentication method
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a] 'Permanently sets authenticated SMTP login
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMU:
[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
' Put code here to email low temperature warning via WiFi
SEROUT2 TX,6,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
SEROUT2 TX,6,["SENT EVERY 2 minutes.",$d,$a]
SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
SEROUT2 TX,6,["GO TO:",$d,$a]
SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
SEROUT2 TX,6,[$d,$a,".",$d,$a]
SERIN2 RX,6,[WAIT("I/ONLINE")]
PAUSE 1000
'SEROUT2 PORTC.0,16468,["EMAIL SENT ",$d,$a] 'test not used
WRITE 5,$01 ' Write 1 to EEPROM as test if Email sent
' Blink Green LED 2x long after email sent
FOR I = 0 TO 1
TOGGLE LED_GRN
PAUSE 1000
TOGGLE LED_GRN
PAUSE 1000
NEXT
PAUSE 2000
RETURN
Here is the BOOT subroutine where the execution stops. I can't figure out why communication with the module isn't established.
'*********SETUP FOR USING ConnectOne Mini Socket iWiFi module**********
BOOT: 'iCHIP SET UP
' Blink Green LED 2x short at start of BOOT routine
FOR I = 0 TO 1
HIGH LED_GRN
PAUSE 250
LOW LED_GRN
PAUSE 250
NEXT
PAUSE 2000
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
PAUSE 10000
HIGH MSEL ' Set high for normal AT+i ops
'SEROUT2 PORTC.0,16468,["TEMP OUTSIDE ",DEC temp,$d,$a,$d ,$a] 'test not used
PAUSE 500
WRITE 4,4 'EEPROM test to see if program executes to here..it does
SEROUT2 TX,6,[ "AT+I",$d ,$a]
WRITE 5,5 'EEPROM test to see if program executes to here..it does
SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK")]
WRITE 6,6 'EEPROM test to see if program executes to here..IT DOESN"T!
' ABOVE TEST INDICATESInterface to iChip is NOT working! Execution doesn't to this point!
'SEROUT2 PORTC.0,16468 , [ "iChip OK",$d,$a ] 'test not used
'SEROUT2 PORTC.0,16468 , [ "TEST_" , DEC3 CNT , 13 , 10 ] 'test not used
SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ]
SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
WRITE 10, ADR[0] ' Write the received IP address to EEPROM as a test..NEVER HAPPENS!
WRITE 11, ADR[1]
WRITE 12, ADR[2]
WRITE 13, ADR[3]
GOSUB DIP
PAUSE 2000
'SEROUT2 TX,6,["AT+iWLWM=1",$d,$a] ' Sets WEP enabled with 64bit key
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
'SEROUT2 TX,6,["AT+iWLKI=1",$d,$a] ' Sets the Wireless LAN transmission WEP-Key index
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
'SEROUT2 TX,6,["AT+iWLKn1=xxxxxxxxxx",$d,$a] ' Sets the Wireless LAN WEP key
'SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
SEROUT2 TX,6,["AT+iWLSI=Buckskin",$d,$a] ' Sets the destination Wireless LAN SSID
SERIN2 RX ,6,2500,BROKE,[ WAIT("I/OK") ]
SEROUT2 TX,6,["AT+iWWW",$d,$a] ' Activates iChip's internal web server
SERIN2 RX,6,1000,BOOT,[WAIT("I/(")]
RETURN
For completeness, here is the code for the BROKE segment that is used in BOOT when communication fails. I do see the character B written int EEPROM at the point in this code that confirms the failure in BOOT.
BROKE:
'SEROUT2 PORTC.0,16468,["NOT WORKING",$d,$a] 'Commented out for now
WRITE 16, "B" 'Record in EEPROM as test if Broke...it does this!
' Blink LED_RED 3X long to indicate iChip not working
FOR I = 0 TO 2
TOGGLE LED_RED
PAUSE 1000
TOGGLE LED_RED
PAUSE 1000
NEXT
PAUSE 2000
Can you see anything in this that would cause failure other than a broken module? I can't believe that this brand new module is broken. I took extra precautions with it after breaking the previous one. Used static sensitive protection measures and never exposed it to wrong voltage. Please take a look and give me your observations and recommendations. Your help is GREATLY appreciated!
mackrackit
- 10th October 2011, 08:08
I am not familiar with Sparkfun stuff, that module converts 5 to 3? Why not just run the whole thing from a 3 volt supply and be done with it?
Is your router set for DCHP? Does it see a new device?
I have always used the ConnectOne software to set the passkey and baud rate.
When I get back to the shop I will look at this closer.
jellis00
- 10th October 2011, 17:41
My application is also using a SRF02 ultrasonic ranger sensor as controlled by my 16F886 MCU. The SRF02 will only work on 5v so I made the choice of running the MCU also at 5v and then I had to use the Sparkfun level converter between it and the ConnectOne iWiFi module.
I will double check my router setting for DCHP.
What code are you referring to from ConnectOne to set the passkey and baud rate? Can you share or point me to it with a URL?
I really appreciate your looking at my code.
John
mackrackit
- 10th October 2011, 17:55
http://www.connectone.com/support.asp?did=30
iChipConfig utility
I have used it on win7, but I recommend setting a restore point before installation... just in case.
You will need a MAX232 or equivalent to connect the device to a PC terminal.
Can you link to the sparkfun part?
(http://www.connectone.com/support.asp?did=30)
mackrackit
- 10th October 2011, 21:15
Up date..
Trying to set up the iChip using only AT commands like you are. Not having much luck. Have to get back to work. Will continue later.
mackrackit
- 10th October 2011, 21:56
Up date..<br>Trying to set up the iChip using only AT commands like you are. Not having much luck. Have to get back to work. Will continue later.
jellis00
- 11th October 2011, 00:53
Do you have a URL link that will get me to where I can download the iChipConfig utilility and its user manual?
I will have to use it on a Windows XP lapto. My application PCB doesn't have a serial interface to it that I can use to connect to PC terminal. Does that mean I can't use iChipConfig utility?
Here is a URL to the SparkFun level converter. http://www.sparkfun.com/products/8745
jellis00
- 11th October 2011, 01:13
Dave, I began to wonder if in my process of converting your ConnectOne example code to my 16F886 MCU and my parsing of the code into subroutines that I could call from my application might have done something that screwed up its ability to communicate with the iChip module. So I went back to your original example code which is a lot simpler and modified it slightly so it is supposedly compatible with 16F886, without parsing into subroutines. Below is the resulting code where I have annotated where it stops and won't execute any further. Still looks like I can't get communication with the iChip. Would appreciate you trying it to see if you can get it to communicate with your module.
I also tried using the AT+iFD command to reset the iChip to Factory Defaults, in hopes that it would connect.....I did this because of this quote in the iChip WiFi Configuration Manual which says " Assuming all WiFi related parameters are cleared to their default value, as is the case after a Factory-Defaults setting (AT+iFD), iChip will attempt to associate and connect to the closest available Access Point (AP) that does not have any security configured. " I used this statement to try to do this and it won't even compile as if there is a syntax error: SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
I don't see anything wrong with this. Any ideas why this won't compile?
'Adapted from http://mackrackit.com/mac/ichip/ichip.html
'Every 60 seconds OR so the PIC sends the commands TO the iChip TO FTP a file along with a new number in the file.
'Every 60 seconds OR so the page will reload with a new number generated by a PIC.
'Every 60 minutes OR so the DATA IS also emailed.
'The PIC code which will compile:
'#####################################
'< FL_PIC16F886 >' ' First valid PIC found within the first 200 lines will
' highlight AND set device.
'< FL_PBPW >' ' OR < FL_PBPL >
'< FL_MPASM >' ' OR < FL_PM >
' Set configuration fuses for the MCU
' To use standard config include file, comment out below statement
@ __config _CONFIG1, _HS_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
ASM
ERRORLEVEL -306
ENDASM
DEFINE OSC 8
ADCON1 = %00001110
TRISC.4 = 0 ' Used as output for LED_GRN
TRISC.5 = 0 ' Used as output for LED_RED
TRISC.6 = 0 ' Used as output for serial TX
TRISC.7 = 1 ' Used as input for serial RX
' Define variables and aliases
CNT VAR BYTE
CNT = 0
temp VAR BYTE 'Already declared in main program as temp
D_LAY VAR BYTE
ADR VAR BYTE [9]
TX VAR PORTC.6
RX VAR PORTC.7
PAUSE 2000
BOOT: 'iCHIP SET UP
' Blink LED_GRN 1x LONG
HIGH PORTC.5 :PAUSE 1000
LOW PORTC.5: PAUSE 2000
'SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
WRITE 2,2 'Above statement won't compile when uncommented
SEROUT2 TX,6,[ "AT+I",$d ,$a] 'Verify that the iChip is communicating
WRITE 3,3 'EEPROM test to see if program executes to here..it does.
SERIN2 RX,6,2500,BROKE,[ WAIT("I/OK") ]
WRITE 4,4 'EEPROM test to see if program executes to here..IT DOESN'T!
SEROUT2 PORTC.3 , 16780 , [ "iChip OK" ]
SEROUT2 PORTC.3 , 16780 , [ "TEST_" , DEC3 CNT , 13 , 10 ]
SEROUT2 TX ,6 , [ "AT+iIPA?" , $d , $a ] 'Report the current IP address
SERIN2 RX ,6 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ] 'Store IP in array
GOSUB DIP ' If IP address is empty, report not connected
PAUSE 2000
SEROUT2 TX,6,["AT+iWWW",$d,$a] 'Activate iChip s internal web server
SERIN2 RX,6,1000,BOOT,[WAIT("I/(")] ' 1 sec timout to BOOT label..I/(<Local IP addr>)where,<Local IP addr> IS the iChip local IP address
EMAIL_SET:
SEROUT2 TX,6,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header s Subject field
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iTOA:
[email protected]",$d,$a] 'Permanently sets Email addressee
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+ito:jellis00",$d,$a] 'Permanently sets Email header s =To: description
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iREA:
[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iFRM:iChip",$d,$a] 'Permanently sets Email header =From: description.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMTP:mail.comcast.com",$d,$a]'Sets the SMTP Server Name or IP.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMA=1",$d,$a] 'Permanently sets SMTP authentication method
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMP:Kevin111",$d,$a] 'Permanently sets authenticated SMTP login
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,6,["AT+iSMU:
[email protected]",$d,$a]'Permanently sets Authenticated SMTP login User Name.
SERIN2 RX ,6,2500,EMAIL_SET,[WAIT("I/OK")]
FTP:
CNT = CNT + 1
FOR D_LAY = 1 TO 12
PAUSE 5000
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] 'Defines a plain text e-mail body
SEROUT2 TX,6,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
SEROUT2 TX,6,["SENT EVERY HOUR.",$d,$a]
SEROUT2 TX,6,["THE TEMPERATURE IS.",$d,$a]
SEROUT2 TX,6,[DEC temp," F Inside.",$d,$a]
SEROUT2 TX,6,["GO TO:",$d,$a]
SEROUT2 TX,6,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
SEROUT2 TX,6,["FOR A ONE MINUTE UPDATE.",$d,$a]
'After successfully sending the e-mail, IF the stay online flag (!) IS specified.
SEROUT2 TX,6,[$d,$a,".",$d,$a]
SERIN2 RX,6,[WAIT("I/ONLINE")]
PAUSE 1000
GOTO BOOT
DIP:
IF !ADR[1] AND !ADR[1] AND !ADR[2] AND !ADR[3] THEN SEROUT2 PORTC.3,16780,[" NOT "]
SEROUT2 PORTC.3,16780,[" CONNECTED ",$d,$a]
SEROUT2 PORTC.3,16780,["ADR - " ,DEC3 ADR[0],".",DEC3 ADR[1],".",DEC3 ADR[2],".",DEC3 ADR[3],$d,$a]
PAUSE 1000
RETURN
BROKE:
SEROUT2 PORTC.3 ,16780,["NOT WORKING",$d,$a]
PAUSE 500
GOTO BOOT
GET_T:
ADCON0=00000001
GOSUB READ_AD
temp = ADRESH
temp = temp * 2
RETURN
READ_AD:
PAUSE 50
ADCON0.2=1
WHILE ADCON0.2=1:WEND
RETURN
jellis00
- 11th October 2011, 05:12
I used this statement to try to do this and it won't even compile as if there is a syntax error: SEROUT2 TX,6 [ "AT+iFD",$d ,$a ] 'Set iChip to Factory Defaults
I don't see anything wrong with this. Any ideas why this won't compile?
I at least figured out why this statement wouldn't compile....I forgot to put a comma after the SEROUT2 TX,6 . However, after fixing this and compiling/running it, the factory defaults didn't seem to happen.
I may have found part of the problem. I have placed a voltmeter on the pin that is RX going into the iWiFi and it stays at a constant 3.3 volts throughout this program...no fluctuations indicating any serial transmission. Also put it on the TX pin comming out of my MCU...also constant. This tells me that the serial interface from the MCU is not working. That would mean that the AT+iFD message never got to the module, hence no Factory Defaults. However, I don't know why or how to fix it. Any ideas?
jellis00
- 11th October 2011, 06:14
I changed all the SEROUT2 TX statements in the code to mode 396 to lower the baud rate to 2400 to see if this made the serial interface work. Still doesn't appear to work. BAFFLED!!
Is there any way to tell whether the asynchronous serial interface on a PIC chip that is using PortC.6 and PortC.7 is working?? I don't have an external serial interface to my PCB to use to see if it is working with a PC terminal or I would. I have the TX and RX pins hooked up only internally to the iChip module.
mackrackit
- 11th October 2011, 09:56
Post #32 has the link to the config utility. You will need a serial interface to your PC to use it along with a MAX232. A USB to serial adapter works fine.
A USB to serial adapter will also let you test you TX, also will help in debugging.
Hang in there, we will get this figured out.
jellis00
- 11th October 2011, 19:07
Just received the below email for ConnectOne tech support confirming what you said about Config utility, so looks like the option is out for me since I don't have an external serial interface on my board.
From what I know now, my problem is really getting the PIC to establish serial communications on my board with my code to the iChip. Once that is done I should be able to use the http:// approach he mentions in the email to setup the iChip configuration. So if you ca help me figure out why the PIC isn't executing the serial interface, that will be the big step.
Regards, John
Here is their email:
Hi John,
According to our R&D, the LAN to WiFi Wizard is not operational and should not be used (it should have been removed from the s/w).
To configure the unit either use the FULL CONFIGURATION tool in the iChipConfig or manually type in AT+I commands using the “Dumb terminal”.
Once the unit is configured, it will save the parameters in non volatile memory.
You will need to power down the unit for the parameters to take effect.
Once you’ve setup the module for the AP you want to connect to and enabled the internal web server, you can than access directly the ichip web configuration page via http://x.x.x.x/ichip
All the information you need for setting up the module is available in the documentation I previously sent you.
Best regards,
Daniel Doron
Customer Support & FAE Manager
Connect One
20 Atir Yeda st.
Kfar Saba 44643 Israel
Phone: 972-9-7660456 x138
mackrackit
- 11th October 2011, 19:35
Can you solder a couple of wire onto your board?
mackrackit
- 12th October 2011, 09:18
I finally got back to this.
To set the iChip up for you network change the below as needed. The config utility is not needed.
TX VAR PORTC.0 'ICHIP PIN 8
RX VAR PORTC.1 'ICHIP PIN 7
PAUSE 2000
BOOT: 'iCHIP SET UP
SEROUT2 TX,84,["AT+iBDRA",$d,$a] ' FORCE ICHIP TO AUTO BAUD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' SETTING BAUD TO 9600
PAUSE 100
SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a] ' WPA-TKIP PROTOCAL
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+iWLSI=MACLAN2",$d,$a]' SET SSID WE ARE LOOKING FOR
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] '
PAUSE 100
SEROUT2 TX,84,["AT+iWLPP=macmac3X3",$d,$a]' SET PASS-PHRASE
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+i!RP10",$d,$a] ' REPORTS CONNECTION PARAMETERS
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' FOR DEBUGGING
PAUSE 100
SEROUT2 TX ,84,[ "AT+iIPA?" , $d , $a ] ' RETURNS IP ADDRESS
PAUSE 100 ' FOR DEBUGGING
SEROUT2 TX,84,["AT+iWWW",$d,$a] ' STARTS WEB SERVER
SERIN2 RX,84,1000,BOOT,[WAIT("I/(")]
PAUSE 100
GOSUB BLINK ' IF WE GET HERE BLINK
PAUSE 100
GOTO BOOT
It may take a minute or two to get a connection and "blink".
Then look at your router and find a new device address.
Enter the address into a browser
http://192.168.2.19/ichip
(http://192.168.2.19/ichip)
You should have the web config page.
jellis00
- 13th October 2011, 00:06
Can you solder a couple of wire onto your board?a
I think I know where you are going with this, Dave. Are you implying that if I solder 3 individual wires to the pins on my PCB that are TX, RX and GND and then connect those three wires to a DB-9 connector, I can jurry-rig a serial interface to my PCB?
I could do this if that is what you are implying, but I also have the problem that none of our computers have a serial interface on them....they are all newer computers and it seems that only older computers have RS-232. I supposed we could try to use a USB to RS-232 converter cable, but we have had very bad experience in trying to use those...they typically don't work well with serial applications.
John
jellis00
- 13th October 2011, 00:09
Does this code actually work with one of your ConnectOne MiniSockets?
I will try this with mine. If it works with yours and not with mine, this may be a way I can verify whether my module has gone bad or not...which is unforunately one of my increasing suspicions.
John
mackrackit
- 13th October 2011, 01:27
The code was tested on a ConnectOne Nano Socket. Same chipset as far as I know.
Yup, I am implying bugging in a DB9.
I used one of these (http://www.tripplite.com/en/products/model.cfm?txtModelID=2430&gclid=CI3lzfmj5KsCFQNggwodKg9BUg) while debugging the above code on a win7 netbook. :eek: But I agree, the converters are not good for everything and I have brands that do not work at all.
Or you could get a LCD with a serial back-pack to see what is going on. Either way, it will sure make debugging faster.
jellis00
- 15th October 2011, 23:30
It may take a minute or two to get a connection and "blink".
I modified your proven code you inserted above very slightly per below. Because my PCB has the _RES_PD and MSEL interfaces connected to MCU pins for control of the module, I had to insert the "Initialize" statements for those interfaces per programmers manual to supposedly have module in normal AT+i ops for the internal serial interface. I also inserted some WRITE to EEPROM statements with comments and some LED blinking to assist my troubleshooting.
As you can see from the comments, I never get the first I/OK acknowledgment from the module, which tells me that the internal serial interface from my MCU to the module is not working.
Next step I guess is to solder 3 wires to my PCB to provision a temporary serial interface to my PC to see if Serial interface is working from MCU. Any other suggestions?
'< FL_PIC16F886 >' ' First valid PIC found within the first 200 lines will
' highlight AND set device.
'< FL_PBPW >' ' OR < FL_PBPL >
'< FL_MPASM >' ' OR < FL_PM >
' Set configuration fuses for the MCU
' To use standard config include file, comment out below statement
@ __config _CONFIG1, _HS_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
ASM
ERRORLEVEL -306
ENDASM
DEFINE OSC 8
ADCON1 = %00001110
' Define variables and aliases
CNT VAR BYTE
CNT = 0
temp VAR BYTE 'Already declared in main program as temp
D_LAY VAR BYTE
ADR VAR BYTE [9]
MSEL VAR PORTC.1 ' iChip Mode Select (MSEL)
_RES_PD VAR PORTC.2 ' iCHIP RESET/Power-Down (_RES_PD)
TX VAR PORTC.6
RX VAR PORTC.7
PAUSE 2000
'Initialize iWiFi MiniSocket Module
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
PAUSE 10000 ' Delay 10 sec
HIGH MSEL ' Proceed with normal ops
PAUSE 2000 ' Delay 2 sec
BOOT: 'iCHIP SET UP
HIGH PORTC.4 :PAUSE 500 ' Short Blink the LED_RED as heart beat
LOW PORTC.4: PAUSE 500
WRITE 3,3 'EEPROM test to see if program executes to here..it does.
SEROUT2 TX,84,["AT+iBDRA",$d,$a] ' FORCE ICHIP TO AUTO BAUD
WRITE 4,4 'EEPROM test to see if program executes to here..it does.
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' SETTING BAUD TO 9600
PAUSE 100
WRITE 5,5 'EEPROM test to see if program executes to here..IT DOESN'T!
' It just keeps looping to BOOT and blinking LED_RED
SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
'SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a] ' WPA-TKIP PROTOCAL
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+iWLSI=Buckskin",$d,$a]' SET SSID WE ARE LOOKING FOR
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] '
PAUSE 100
'SEROUT2 TX,84,["AT+iWLPP=macmac3X3",$d,$a]' SET PASS-PHRASE
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+i!RP10",$d,$a] ' REPORTS CONNECTION PARAMETERS
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' FOR DEBUGGING
PAUSE 100
SEROUT2 TX ,84,[ "AT+iIPA?" , $d , $a ] ' RETURNS IP ADDRESS
PAUSE 100 ' FOR DEBUGGING
SEROUT2 TX,84,["AT+iWWW",$d,$a] ' STARTS WEB SERVER
SERIN2 RX,84,1000,BOOT,[WAIT("I/(")]
PAUSE 100
GOSUB Blink ' IF WE GET HERE BLINK LED_GRN
PAUSE 100
GOTO BOOT
Blink:
HIGH PORTC.5 :PAUSE 500 ' Short Blink the LED_GRN..NEVER GETS HERE!
LOW PORTC.5: PAUSE 500
RETURN
mackrackit
- 16th October 2011, 04:14
The only pins used for normal operation are the GND, VDD, RXD0, and TXD0. All others are left floating.
You are keeping things in reset by playing with the other pins.
jellis00
- 17th October 2011, 06:08
I understand your point, Dave, but I already built the PCB with hookups to MSEL and _RES_PD from the MCU so have to make them work in the setup.
This code works! The fix was to set TRISC so that _RES_PD and MSEL were declared as outputs. When this worked I was able to read the EEPROM to see what the IP was for the iChip website that it established and then to got to it via http://xx.xx.x.xxx/ichip and set the parameters I wanted.
Now on to figure out how to integrate this working code into my application so I can use the iWiFi module to send an email via its connection with my wireless router to the internet.
Thanks for your help, Dave. I hope this attached code will show others who visit this thread how to setup a iWiFi MiniSocket module to set its parameters without having to use the config utility.
/s/ John Ellis
' STATUS: Works OK!
'< FL_PIC16F886 >' ' First valid PIC found within the first 200 lines will
' highlight AND set device.
'< FL_PBPW >' ' OR < FL_PBPL >
'< FL_MPASM >' ' OR < FL_PM >
' Set configuration fuses for the MCU
' To use standard config include file, comment out below statement
@ __config _CONFIG1, _HS_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
ASM
ERRORLEVEL -306
ENDASM
DEFINE OSC 8
ADCON1 = %00001110
TRISC.1 = 0 ' Make pin output for MSEL
TRISC.2 = 0 ' Make pin output for _RES_PD
' Define variables and aliases
CNT VAR BYTE
CNT = 0
temp VAR BYTE 'Already declared in main program as temp
D_LAY VAR BYTE
ADR VAR BYTE [9]
MSEL VAR PORTC.1 ' iChip Mode Select (MSEL)
_RES_PD VAR PORTC.2 ' iCHIP RESET/Power-Down (_RES_PD)
TX VAR PORTC.6
RX VAR PORTC.7
PAUSE 2000
'Initialize iWiFi MiniSocket Module
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
PAUSE 10000 ' Delay 10 sec
HIGH MSEL ' Proceed with normal AT+i command ops
PAUSE 2000 ' Delay 2 sec
BOOT: 'iCHIP SET UP
HIGH PORTC.4 :PAUSE 500 ' Short Blink the LED_RED as heart beat
LOW PORTC.4: PAUSE 500 ' while disconnected from router.
WRITE 3,3 'EEPROM test to see if program executes to here..it does.
SEROUT2 TX,84,["AT+iBDRA",$d,$a] ' FORCE ICHIP TO AUTO BAUD
WRITE 4,4 'EEPROM test to see if program executes to here..it does.
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' SETTING BAUD TO 9600
PAUSE 100
WRITE 5,5 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
'SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a] ' WPA-TKIP PROTOCAL
' Commented out until WPA setup on wireless router
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+iWLSI=Buckskin",$d,$a]' SET SSID WE ARE LOOKING FOR
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] '
PAUSE 100
'SEROUT2 TX,84,["AT+iWLPP=macmac3X3",$d,$a]' SET PASS-PHRASE
' Commented out until WPA setup on wireless router
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+i!RP10",$d,$a] ' REPORTS CONNECTION PARAMETERS
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' FOR DEBUGGING
PAUSE 100
SEROUT2 TX ,84,[ "AT+iIPA?" , $d , $a ] ' RETURNS IP ADDRESS
' FOR DEBUGGING
SERIN2 RX ,84 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
PAUSE 100
WRITE 16,ADR[0] ' Write the IP to EEPROM for post run identify
WRITE 17,ADR[1]
WRITE 18,ADR[2]
WRITE 19,ADR[3]
WRITE 6,6 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84,["AT+iWWW",$d,$a] ' STARTS WEB SERVER
SERIN2 RX,84,1000,BOOT,[WAIT("I/(")]
PAUSE 100
GOSUB Blink ' IF WE GET HERE BLINK LED_GRN
PAUSE 100
GOTO BOOT
Blink:
HIGH PORTC.5 :PAUSE 500 ' Short Blink the LED_GRN..IT DOES AFTER ~2 minutes!
LOW PORTC.5: PAUSE 500
RETURN
mackrackit
- 17th October 2011, 14:40
Glad you got it working!!!
But,
TRISC.1 = 0 ' Make pin output for MSEL
TRISC.2 = 0 ' Make pin output for _RES_PD
Would/should not have made a difference because the HIGH/LOW commands do that in the background.
Must have been another change...
jellis00
- 17th October 2011, 23:23
I thought it was working...and it is to a point. However I am seeing an anomaly I can't understand. I hope you can help me figure this out.
I am programming my application with the below code using a PICKIT2. I have the PICKIT2 set to "VDD Target" so that the PICKIT2 is not providing power...my application has its own power.
The programming of the device is normal and it starts working and executes the program normally as long as the PICKIT2 is still connected (but not providing power).
However, when I disconnect the PICKIT2 and power down my application and then reapply the application's power, the code is obviously stopping execution at the point in the code where the AT+i coommand is given to set auto-baud at 9600 baud. I know this from the WRITE 4,4 statement not appearing in EEPROM after the test run and the LED_RED not blinking. However, when I then reconnect the PICKIT2 and load the PICKIT2 software with its screen, my application then works normally and executes the complete program with the LED_RED blinking as a heart beat during the BOOT loop.
It is almost like the iWiFi module isn't getting power when the PICKIT2 is disconnected and therefore the AT+iBDRA fails...but it is getting power...I checked with a voltmeter.
I am stumped and can't go any further in integrating this code with my overall application until I resolve this anomaly.
Do you or anyone have any ideas why the iWiFi module would act this way with this code and this scenario?? At least I was able to use this code when it worked while PICKIT2 was connected to identify the IP address, log into the iChip web server from my PC via the wireless route,r and set parameters on the iChip.
John
CODE]
'< FL_PIC16F886 >' ' First valid PIC found within the first 200 lines will
' highlight AND set device.
'< FL_PBPW >'
'< FL_MPASM >'
' Set configuration fuses for the MCU
' To use standard config include file, comment out below statement
@ __config _CONFIG1, _HS_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
ASM
ERRORLEVEL -306
ENDASM
DEFINE OSC 8
ADCON1 = %00001110
TRISC.1 = 0 ' Make pin output for MSEL
TRISC.2 = 0 ' Make pin output for _RES_PD
' Define variables and aliases
CNT VAR BYTE
CNT = 0
temp VAR BYTE 'Already declared in main program as temp
D_LAY VAR BYTE
ADR VAR BYTE [9]
MSEL VAR PORTC.1 ' iChip Mode Select (MSEL)
_RES_PD VAR PORTC.2 ' iCHIP RESET/Power-Down (_RES_PD)
TX VAR PORTC.6
RX VAR PORTC.7
PAUSE 2000
CLEAR
'Initialize iWiFi MiniSocket Module
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize coming out of power down mode
LOW MSEL ' Exit SERIALNET mode and return iChip to normal AT+i mode
PAUSE 5000 ' Delay 5 sec
HIGH MSEL ' Proceed with normal AT+i command ops
PAUSE 2000 ' Delay 2 sec
BOOT: 'iCHIP SET UP
WRITE 3,3 'EEPROM test to see if program executes to here..it does under all conditions.
SEROUT2 TX,84,["AT+iBDRA",$d,$a] ' FORCE ICHIP TO AUTO BAUD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' SETTING BAUD TO 9600
PAUSE 100
WRITE 4,4 'EEPROM test to see if program executes to here..it does when
'application is connected to PICKIT2 but DOESN'T when
'disconnected and then started on application's own power.
'However when reconnected to PICKIT2 and the PICKIT2 screen
'is then opened, it executes normally again. PICKIT2 is set to
'VDD target and is not supplying power to the application.
HIGH PORTC.4 :PAUSE 500 ' Short Blink the LED_RED as heart beat
LOW PORTC.4: PAUSE 500 ' during BOOT loop. Doesn't Blink when
' disconnected from PICKIT2!
SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
WRITE 5,5 'EEPROM test to see if program executes to here..it does!
'SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a] ' WPA-TKIP PROTOCAL
' Commented out until WPA setup on wireless router
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+iWLSI=Buckskin",$d,$a]' SET SSID WE ARE LOOKING FOR
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] '
PAUSE 100
'SEROUT2 TX,84,["AT+iWLPP=macmac3X3",$d,$a]' SET PASS-PHRASE
' Commented out until WPA setup on wireless router
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
SEROUT2 TX,84,["AT+i!RP10",$d,$a] ' REPORTS CONNECTION PARAMETERS
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' FOR DEBUGGING
PAUSE 100
SEROUT2 TX ,84,[ "AT+iIPA?" , $d , $a ] ' RETURNS IP ADDRESS
' FOR DEBUGGING
SERIN2 RX ,84 , 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ]
PAUSE 100
WRITE 6,6 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84,["AT+iWWW",$d,$a] ' STARTS iChip WEB SERVER
SERIN2 RX,84,1000,BOOT,[WAIT("I/(")]
WRITE 7,7 'EEPROM test to see if program executes to here..it does!
PAUSE 100
GOSUB Blink ' IF WE GET HERE BLINK LED_GRN
PAUSE 100
WRITE 16,ADR[0] ' Write the IP to EEPROM for post run identify
WRITE 17,ADR[1] ' Use PC host to then go to iChip web server at
WRITE 18,ADR[2] ' http:ADR[0].ADR[1].ADR[2].ADR[3] and set all
WRITE 19,ADR[3] ' desired iChip parameters for operations
GOTO BOOT
Blink:
HIGH PORTC.5 :PAUSE 500 ' Short Blink the LED_GRN..IT DOES AFTER ~1 minute!
LOW PORTC.5: PAUSE 500
RETURN
[/CODE]
mackrackit
- 17th October 2011, 23:58
Does the PIC run without the PicKit2?
Do a blinky to verify.
The Sparkfun device looks like it requires 5 and 3 volts.
Do you have both? Do they share a ground, VSS ?
Do you have capacitors near the PIC across VDD and VSS?
Did you change the backup battery problem?
jellis00
- 18th October 2011, 21:52
Does the PIC run without the PicKit2?
Do a blinky to verify.
I created a set of code that is the same as above post down through the _RES_PD and MSEL initialization followed only by a mainloop that blinks the LED. I did this so that all the setup code I was using was still the same in this test. This blinky code works whether the PICKIT2 is connected or not, so that didn't ID the problem.
The Sparkfun device looks like it requires 5 and 3 volts.
Do you have both? Yes. Actually I have the iWiFi module running on 3.32 volts which is within its required Vdd range, so the lov voltage side of the Sparkfun converter is at 3.32v.
Do they share a ground, VSS ? Yes, I created a large ground plane layer on the top layer of my PCB right below the iWiFi module's outline where it is mounted to the PCB and this ground plane is shared with the level converter, the PIC and the rest of the PCB circuit.
Do you have capacitors near the PIC across VDD and VSS? Yes, I have a 10uf tantalum and a 0.1uf ceramic connected near Vdd on the PIC to the Vss.
Did you change the backup battery problem? Yes, after I cut the traces to the pull-ups and greenwired them to Vcc I then replaced the backup battery and the clock is running fine and maintaining time.
These were all good questions and I appreciate you making me think through this. The bad news is that the code still quits running when the PICKIT2 is disconnected. However the good news is that I am now sending and receiving an email from the ichip (but only when the PICKIT2 is connected). Still trying to figure out the AT+i commands and right sequence of WAITs to only send one email when I want to. At this time for some reason it is sending two emails one minute apart repeated every 8 minutes. I thought I had the timing in this code set to only send one every 5 minutes and don't see where this is causing the repeats at the wrong interval. I only want it to send one every 5 minutes. I don't think I have the WAIT statements for I/OK, I/DONE, and I/ERROR correct and the timeouts to the EMAIL label may be causing repeated emails. Here is the EMAIL routine code I am using....any suggestions?
EMAIL_SET:
SEROUT2 TX,84,["AT+iSBJ:iChip ADC TEMPERATURE",$d,$a] 'Permanently sets Email header Subject field
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iTOA:
[email protected]",$d,$a] 'Permanently sets Email addressee
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+ito:jellis00",$d,$a] 'Permanently sets Email header =To: description
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iREA:
[email protected]",$d,$a] 'Permanently sets the RETURN EMAIL Address
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFRM:iChip",$d,$a] 'Permanently sets Email header =From: description.
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iSMTP:smtp.comcast.net",$d,$a]'Sets the SMTP Server Name or IP.
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iSMA=1",$d,$a] 'Permanently sets SMTP authentication method
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iSMP:Kevin111",$d,$a] 'Permanently sets authenticated SMTP login
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iSMU:je.lodestar",$d,$a] 'Permanently sets Authenticated SMTP login User Name.
SERIN2 RX ,84,2500,EMAIL_SET,[WAIT("I/OK")]
GOSUB Blink_GRN ' Short blink the LED_GRN if gets to here
CNT = CNT + 1
FOR D_LAY = 1 TO 12 ' Delay for 1 min
PAUSE 5000
NEXT D_LAY
IF CNT > 4 THEN ' Execute if 5 minutes have passed
FOR I = 0 TO 1 ' Long Blink LED_GRN 2x if gets to here
HIGH PORTC.5
PAUSE 2000
LOW PORTC.5
PAUSE 2000
NEXT
GOSUB GET_T
GOSUB EMAIL ' Send an email every 2 minutes
CNT = 0 ' Reset CNT after 2 minutes
ENDIF
PAUSE 2000
GOTO BOOT
END ' To protect code from going to never-never-land
EMAIL:
SEROUT2 TX,84,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
SEROUT2 TX,84,["HI, THIS IS FROM 206 N Veterans.",$d,$a]
SEROUT2 TX,84,["SENT EVERY HOUR.",$d,$a]
SEROUT2 TX,84,["THE TEMPERATURE IS.",$d,$a]
SEROUT2 TX,84,[DEC temp," F Inside.",$d,$a]
SEROUT2 TX,84,["GO TO:",$d,$a]
SEROUT2 TX,84,["http://www.lodestarassoc.com/ichip/ichip.html",$d,$a]
SEROUT2 TX,84,["FOR A ONE MINUTE UPDATE.",$d,$a]
SEROUT2 TX,84,[$d,$a,".",$d,$a]
SERIN2 RX ,84,2500,EMAIL,[WAIT("I/OK")]
GOSUB Blink_GRN ' Short blink LED_GRN 3x
GOSUB Blink_GRN
GOSUB Blink_GRN
PAUSE 1000
GOTO Sent
SERIN2 RX ,84,2500,EMAIL,[WAIT("I/ERROR")]
GOSUB Blink_RED ' Short blink LED_RED 3x
GOSUB Blink_RED
GOSUB Blink_RED
PAUSE 1000
SERIN2 RX,84,2500,EMAIL,[WAIT("I/DONE")]
PAUSE 2500 ' After successfully sending the e-mail, allow 2.5 seconds
'delay for iChip re-initialization following an Internet mode session.
GOSUB Blink_GRN ' Short blink LED_GRN 4x
GOSUB Blink_GRN
GOSUB Blink_GRN
GOSUB Blink_GRN
PAUSE 1000
Sent: ' Label for GOTO after email is sent to skip other WAIT checks.
RETURN
mackrackit
- 19th October 2011, 09:29
To have accurate timing you will need to interrupt base the routine. You can use the RTC for that.
jellis00
- 22nd October 2011, 06:47
Dave, I am already using a DS1337 RTC in my applicaton with intention of using an interrupt from it on periodic basis to take a temperature reading and to initiate emails via the wireless module per the code I am currently trouble shooting. You can see the schematic of all this in an email I sent to Darrel Taylor which I copied you on in which I enlisted his help to find out why it is only working when a PICKIT2 is plugged in. I also included you on an email to ConnectOne techsupport and one that was direct to you regarding how you terminated the _RES_PD and MSEL connections in your application. Did you get them??
mackrackit
- 22nd October 2011, 07:11
I just saw them, got two.
I do not have the RES_PD or MSEL pins connected to anything, they are floating.
Cut some more traces.
Or if all else fails, skip the sparkfun part and test with the whole system running on ~3 volts.
Ain't prototyping fun :)
jellis00
- 11th November 2011, 01:34
Dave, I finally got it all working...or I should say almost all. Still troubleshooting one statement I want to add to the FTP process that is posting the wrong HH:MM values used from the RTC...for which I will describe and ask for help at end of this posting..
First of all, I made what I think are some good changes to the approach which I will share below for benefit of anyone else monitoring this thread that is trying to use the ConnectOne iWiFi MiniSocket module. I broke a lot of your sample code into some callable subroutines which I will list and explain below. I am posting all this code because I discovered that the ConnectOne programmers manual for the MiniSocket doesn't have any examples so it is somewhat difficult to get the syntax just right. Since these routines are tested and work it should save others from having this problem. Although I should say that the TechSupport people at ConnectOne have been very helpful and also say they are going to add examples to each command reference in their next publish of the programmers manual for the very reason I pointed out to them.
You will see a lot of WRITE to EEPROM statements embedded in this code which you can comment out or ignore...I use them to debug the AT+i command sequences so I know where the hangups are in the code by reading the EEPROM of the MCU after each run of the code when programming the MiniSocket module. I also have embedded a lot of variable duration, blinking LED statements to make use of a GREEN/ RED LED on my board to help see what is happening when the code is running.
From your mainloop when you want to use the MiniSocket module you first need to call this subroutine (BOOT) to initialize the module. You will have to substitue your own router SSID name in the iWLSI statement.
BOOT: 'Subroutine for setting up ConnectOne MiniSocket iWiFi module
' Blink Green LED 2x short at start of BOOT routine...for test only
FOR I = 0 TO 1
HIGH LED_GRN
PAUSE 250
LOW LED_GRN
PAUSE 250
NEXT
PAUSE 1000 'Initialize iWiFi MiniSocket Module
HIGH _RES_PD ' Set high for normal ops
PAUSE 500 ' Delay to stabilize if coming out of power up mode
WRITE 48,2 'EEPROM test to see if program executes to here..it does.
SEROUT2 TX,84,["AT+iBDRA",$d,$a] ' FORCE ICHIP TO AUTO BAUD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] ' SETTING BAUD TO 9600
PAUSE 100
WRITE 49,3 'EEPROM test to see if program executes to here..it does.
SEROUT2 TX,84,["AT+iRPG=booger",$d ,$a] ' SETS REMOTE PASSWORD
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
' Commented out until WPA setup on wireless router
'SEROUT2 TX,84,["AT+iWSEC=0",$d ,$a] ' WPA-TKIP PROTOCAL
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
PAUSE 100
WRITE 50,4 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84,["AT+iWLSI=EllisOfficeNetwork",$d,$a]' SET SSID WE ARE LOOKING FOR
SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")] '
PAUSE 100
' Commented out until WPA setup on wireless router
'SEROUT2 TX,84,["AT+iWLPP=passphrase",$d,$a] ' SET PASS-PHRASE
'SERIN2 RX ,84,2500,BOOT,[WAIT("I/OK")]
'PAUSE 100
WRITE 51,5 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX ,84, [ "AT+iIPA?" , $d , $a ] 'Report the current IP address
SERIN2 RX ,84, 2500 ,BOOT , [ DEC ADR[0] , DEC ADR[1] , DEC ADR[2] , DEC ADR[3] ] 'Store IP in array
WRITE 52,6 'EEPROM test to see if program executes to here..it does!
GOSUB DIP ' If IP address is empty, report not connected
PAUSE 1000
WRITE 32,ADR[0] ' Write the IP to EEPROM for post run identify...for test only
WRITE 33,ADR[1]
WRITE 34,ADR[2]
WRITE 35,ADR[3]
WRITE 53,7 'EEPROM test to see if program executes to here..it does!
RETURN
For completeness I will also list a couple of other routines that are called by BOOT (BROKE and DIP):
BROKE: ' Executes when iChip not working...blinks LED_RED
WRITE 5, "B" 'Record in EEPROM as test if Broke!
' Blink LED_RED 3X long to indicate iChip not working
FOR I = 0 TO 2
TOGGLE LED_RED
PAUSE 1000
TOGGLE LED_RED
PAUSE 1000
NEXT
PAUSE 2000
GOTO BOOT
DIP: ' Check whether IP is valid, blink LED_RED if not
'===
IF (!ADR[0]) AND (!ADR[1]) AND (!ADR[2]) AND (!ADR[3]) THEN
' Blink LED_RED 4X short to indicate iChip not working
FOR I = 0 TO 3
TOGGLE LED_RED
PAUSE 250
TOGGLE LED_RED
PAUSE 250
NEXT
PAUSE 2000
ENDIF
PAUSE 1000
RETURN
Then after the BOOT routine has been executed you can call the EMAIL routine listed below to send an email to wherever you want (by changing some of the permanent AT+i parameters you must have previously programmed per the inital comments in the start of the EMAIL routine):
Email: ' Sends email via ConnectOne iWifi MiniSocket module
'=====
'This subroutine assumes user has previously programmed the MiniSocket module
'with permanent entries for following email paramaters...see the programmer's
'manual at http://www.connectone.com/support.asp?did=42 for following commands:
' AT+iTO,AT+iREA,AT+iFRM,AT+iSMTP,AT+iSMA=1,AT+iSMP, AT+iSMU,
' Blink Green LED 1x long at start of Email routine
TOGGLE LED_GRN
PAUSE 1000
TOGGLE LED_GRN
PAUSE 2000
WRITE 54,8 'EEPROM test to see if program executes to here..it does!
' Put code here to email low temperature warning via WiFi
SEROUT2 TX,84,["AT+iEMA:",$d,$a] 'Defines a plain text e-mail body
SEROUT2 TX,84,["Hi, this is from 206 N Veterans.",$d,$a]
SEROUT2 TX,84,["The inside temperature is:",$d,$a]
SEROUT2 TX,84,[DEC temp," F Inside.",$d,$a]
SEROUT2 TX,84,["GO TO:",$d,$a]
SEROUT2 TX,84,["http://www.lodestarassoc.com/ichip/ichip.php",$d,$a]
SEROUT2 TX,84,["for an hourly update.",$d,$a]
SEROUT2 TX,84,[$d,$a,".",$d,$a]
SERIN2 RX,84,[WAIT("I/ONLINE")]
WRITE 55,9 'EEPROM test to see if program executes to here..it does!
GOSUB Blink_GRN ' Short blink LED_GRN 2x after email sent
GOSUB Blink_GRN
PAUSE 1000
Sent:
' Blink Green LED 2x long after email sent
FOR I = 0 TO 1
TOGGLE LED_GRN
PAUSE 1000
TOGGLE LED_GRN
PAUSE 1000
NEXT
RETURN
Alternatively you can call the FTP routine to FTP data to a website of your choice for which you will have to modify the domain, username and password in the iFOPN statement, the directory name (iChip) in the iFCWD statement, and the file name (include-3.txt) in the iFSTO statement. In my application I have a folder on the website named "iChip" which contains a text file named "include-3.txt" to which this code writes the information in the iFSND statements. The website uses a PHP script to automatically update the web page by reading and displaying the text file every 2 minutes so it dynamically keeps up with the updates that may be coming from the MiniSocket module at rate faster than 2 minutes. If anyone wants this PHP script for use on their website, send me a PM.
FTP: 'FTP temperature data to internet based website
'===
SEROUT2 TX,84,["AT+i",$d,$a]
SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
SEROUT2 TX,84,["AT+iFOPN:lodestarassoc.com,username,password$d,$a]'OPEN SESSION
SERIN2 RX,84,1000,FTP,[WAIT("I/000")] :PAUSE 100
SEROUT2 TX,84,["AT+iFCWD:000,iChip",$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSTO:000,",$22,"include-3.txt",$22,$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSND:000,19:"," The temperature is",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,13:",DEC temp," F Outside",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
WRITE 56,10 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84, ["AT+iFCLF:000",$d,$a] : PAUSE 100 ' Close file
SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
PAUSE 100
WRITE 57,11 'EEPROM test to see if program executes to here..it does!
SEROUT2 TX,84,["AT+i",$d,$a]':PAUSE 100
SERIN2 RX,84,100,BOOT,[WAIT("I/OK")] :PAUSE 100
RETURN
I hope the above routines will help people that are using the ConnectOne MiniSocket avoid the learning curve I had to go thru.
Now for a request for help to solve a remaining problem I am trying to solve in using the MiniSocket with PICBASICPro.
Since my application has an embedded RTC, I want to include in the FTP routine a sequence that will send a message as a time stamp so that whoever logs into the website can see when the data was posted. To do this I am trying to use the following added iFSND statements to append a time stamp to the rest of the posted data:
'FTP the time stamp of the temperature measurement
SEROUT2 TX,84,["AT+iFOPN:lodestarassoc.com:jellis00,Kevin111#",$d,$a]'OPEN SESSION
SERIN2 RX,84,1000,FTP,[WAIT("I/000")] :PAUSE 100
SEROUT2 TX,84,["AT+iFCWD:000,iChip",$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSTO:000,","include-4.txt",$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSND:000,5:",HEX2 hr,":",HEX2 MINs,$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
IF (test=1) THEN
WRITE 59,14 'EEPROM test to see if program executes to here..it does.
ENDIF
'SEROUT2 TX,84,["AT+iFSND:000,3:",DEC CNT,$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFCLF:000",$d,$a] 'Close file
SERIN2 RX,84,[WAIT("I/OK")]:PAUSE 100
SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'Close Session
SERIN2 RX,84,100,BOOT,[WAIT("I/ONLINE")]:PAUSE 100
SEROUT2 TX,84,["AT+i",$d,$a]
SERIN2 RX,84,100,BOOT,[WAIT("I/OK")]
My problem centers around the statement: SEROUT2 TX,84,["AT+iFSND:000,5:",HEX2 hr,":",HEX2 MINs,$d,$a]:PAUSE 100
For some reason the displayed values in the website always show up as constant 4:32 in all FTP postings rather than as the actual HH:MM values from the RTC at the time of the posting. Can anyone tell me why this is happening? I have spent a couple of days trying to figure this out with no success and any help would be appreciated.
jellis00
- 11th November 2011, 08:36
Since these routines are tested and work it should save others from having this problem.
CORRECTION! I discovered that running the above routines as callables from a mainloop will only execute correctly on the first loop and will quit after that.
This was due to a simple syntax error in one of the statements in the FTP subroutine. Therefore, replace the above posted FTP routine with this one that has been corrected and the routines will continue to work no matter how many times they are called:
FTP: 'FTP temperature data to internet based website
'===
SEROUT2 TX,84,["AT+i",$d,$a]
SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
SEROUT2 TX,84,["AT+iFOPN:lodestarassoc.com:jellis00,Kevin111#",$d,$a]'OPEN SESSION
SERIN2 RX,84,1000,FTP,[WAIT("I/000")] :PAUSE 100
SEROUT2 TX,84,["AT+iFCWD:000,iChip",$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSTO:000,",$22,"include-3.txt",$22,$d,$a]
SERIN2 RX,84,[WAIT("I/OK")]
SEROUT2 TX,84,["AT+iFSND:000,19:"," The temperature is",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,13:",DEC temp," F Outside",$d,$a]:PAUSE 100
SEROUT2 TX,84,["AT+iFSND:000,2:",$d,$a]:PAUSE 100
SEROUT2 TX,84, ["AT+iFCLF:000",$d,$a] : PAUSE 100 ' Close file
SEROUT2 TX,84,["AT+i!FCLS:000",$d,$a] 'CLOSE SESSION
PAUSE 100
SEROUT2 TX,84,["AT+i",$d,$a]':PAUSE 100
SERIN2 RX,84,100,BOOT,[WAIT("I/OK")] :PAUSE 100
RETURN
mackrackit
- 11th November 2011, 10:29
What was your Aha moment that finally got things working?
I hope the above routines will help people that are using the ConnectOne MiniSocket avoid the learning curve I had to go thru.
I do not see what you did different from what you were working with at the beginning?
RTC-FTP
I have to ask, are you certain the RTC is running.
jellis00
- 11th November 2011, 20:12
The Aha moment came when I finally purchased an EVB for the MiniSocket that allowed me to use the config utility to pre-set the parameters in my iChip and to interactively test different sequences of AT+i commands, which also helped me converge on the correct syntax for the AT+i commands. Once I did this, it helped transition the results and my learning curve to my PBP code version of the AT+i commands.
The main thing I did different than Macrackit's example code is break things into callable subroutines so that the user can decide where and in what sequence in the mainloop to make things happen with the MiniSocket. Since the AT+i code will stop anywhere it fails and therefore stop further execution of the main PBP program, this gives more flexibility to the user on how to use the different features of the MiniSocket rather than a complete, single, in-line code set like Mackrackit's example which will fail wherever an AT+i command fails. For example, breaking the Email process away from the FTP process as separate callable routines very much accelerated my troubleshooting process and seems to increase the reliability of the functional performance of the main program.
Annother thing I did different was to take advantadge of the fact that most of the EMAIL setup AT+i parameters can be pre-set as permanent parameters stored in FLASH on the iChip. As long as you are always going to send the EMAILs to the same place, as my application does, this eliminates the need of having to list these as PBP statements in you program and executing them everytime you send an email, as Mackrackit is doing in his example code....this saves MCU program memory and reduces execution time of the EMAIL routine.
Good question re: RTC-FTP. I know the RTC is running during most of the program because of the embedded statements that WRITE the HH:MM to EEPROM. However, I haven't tested to make sure it is still running and hasn't stopped for some reason when the FTP subroutine starts. I will do that...Thanks! I am also going to try changing the time statement from HEX2 hr and HEX2 MINs to DEC2 hr and DEC2 MINs to see if that displays the correct time on the web page after the FTP. I know using HEX2 is the right way to display time on LCD, but not sure whether it should stay in HEX format via the FTP process to web page or not.
I notice you attempted to send me a PM this morning and my PM mailbox was full and rejected it. I have cleaned up my PM mail box, so send it again.
Thanks for all your help and advice. /s/ John Ellis
kenruizal
- 21st November 2011, 08:34
Do you have a schematic diagram of your design?...
mackrackit
- 21st November 2011, 10:00
Read the whole thread. John and I have both posted schematics.
kenruizal
- 21st November 2011, 16:16
hello sir..your post in this thread is not complete theres a certain part of your schematic i cannot see or it was cut..tnx
mackrackit
- 21st November 2011, 16:19
It shows how the ConnectOne is connected.
kenruizal
- 21st November 2011, 16:34
can i see your whole schematic if its okay to u sir..because i want to use the WizFi210-EVB module sir.its more alike in connectone sir..tnx
mackrackit
- 21st November 2011, 16:39
It will be tomorrow before I can post it as I do not have it with me.
kenruizal
- 21st November 2011, 16:54
thank you very much sir...
dhouston
- 21st November 2011, 16:59
... i want to use the WizFi210-EVB module sir.its more alike in connectone sir..tnxThe WizFi210-EVB bears no resemblance to the Connect One module. It has a DB-9 connector for the serial connection and uses RS232 levels and polarity. You'll just confuse yourself looking at Dave's schematic. Refer, instead, to the WizFi210-EVB schematic (http://www.wiznet.co.kr/Sub_Modules/en/product/Product_Detail.asp?cate1=5&cate2=43&cate3=0&pid=1133#tab) and their other documentation.
kenruizal
- 21st November 2011, 17:14
i was just confuse of what PIC should i use to interface the WizFi210-EVB sir...i'm a beginner sir so any suggestion of wat PIC should i use?...tnx...i want to design a PIR sensor like john design nw but i use WizFi210-EVB instead of connectone ant PIR instead of ultrasonic.and iwant to interface to PC unit with an application of Visual Basic as my GUI...i want to monitor my sensor through wireless..
dhouston
- 21st November 2011, 18:45
The WizFi210-EVB is designed to connect to a PC via its DB-9 connector. How do you plan to connect the PIR sensor? It will get awfully expensive if you plan to use another WizFi210-EVB to provide it with WiFi.
Does your LAN have a WiFi router? If so, you only need a WiFi interface for the sensor but the WizFi210-EVB is both costly and poorly suited for that as you would have to un-covert the RS232 levels/polarity (or use Debug/DebugIn). You would be better off designing your own PCB for the WizFi210 plus whatever PIC you wish to use which really depends on what else you need the PIC to do.
The WizFi210/220 have several pins (ADC, DIO) that you can probably use to connect directly with the sensor w/o need of a PIC. Download the documentation from the page I referenced earlier in the thread. One of the application notes appears to show getting data from the module using HTTP although it does not provide sufficient detail to be sure. You probably should be communicating with WizNET rather than posting questions here.
kenruizal
- 22nd November 2011, 02:06
thank you sir
dhouston
- 22nd November 2011, 02:23
I have designed a Zarduino (http://davehouston.org/WizNET.htm)TM Shield for the WizFi210/220 or Wiz105SR with prototype PCBs being made right now. Once I have the PCBs and can test them, I'll try to figure out the HTTP app note and post here. But, that's likely to be 4-5 weeks away.
jellis00
- 22nd November 2011, 03:48
Do you have a schematic diagram of your design?...
Not sure whether you are asking me for schematic or from mackrackit.
As mackrackit says in one of his posts, we have both posted schematics. However, the previous one I posted had some errors in how to connect the ConnectOne iWiFi MiniSocket module, which I discovered the hard way in my PCB and had to re-do the wiring on the PCB. Therefore, if you want this updated schematic that shows how to wire the MiniSocket and how to use a SparkFun level converter module in the interface between the PIC MCU and the MiniSocket, here it is attached.
6132
jellis00
- 22nd November 2011, 03:59
You would be better off designing your own PCB for the WizFi210 plus whatever PIC you wish to use which really depends on what else you need the PIC to do7.
For your info, kenruizal, I agree with Dave on his statement above. The WizFi210 is expensive and difficult to program. I did a thorough evaluation on the available WiFi modules and ended up selecting the ConnectOne iWiFi MiniSocket Module. I recommend you use a ConnectOne iWiFi MiniSocket Module on a PCB interfaced to a PIC chip via a SparkFun level converter like I did (if you have to use 5V on the PIC for interface to your PIR sensor....if not you can run everything on 3v and eliminate the SparkFun level converter...see my schematic in above post). It is easy to program in PBP to command the MiniSocket module with its AT+i commands. It can be purchased for ~$58 for plugin to your PCB via a 2x6 female header. Then once you have debugged the code while running on your PCB you can further reduce the cost by using ConnectOne's reference design and do a 2nd generation PCB with all the iWiFi module components mounted directly on the PCB as surface mount devices.
I can help you with a couple of subroutines I developed that are tested and working with the MiniSocket. These subroutines connect to an external website via the internet and post data to it, as well as another one to send emails. You can also program it as a TCP listening socket and command it from the internet side. If you need help on this, start a new thread and point me to it via a Personal Message and I will help you get it working.
kenruizal
- 22nd November 2011, 05:41
i tried to email connect one but no one reply us...can you give me a number or an email of connectone because i came from asia philippines...plz
jellis00
- 22nd November 2011, 06:43
i tried to email connect one but no one reply us...can you give me a number or an email of connectone because i came from asia philippines...plz
Daniel Doron [
[email protected]] from ConnectOne's Tech Support has been very responsive to me.
dhouston
- 22nd November 2011, 13:41
For your info, kenruizal, I agree with Dave on his statement above. The WizFi210 is expensive and difficult to program.I wouldn't go that far. The WizFi210 itself is inexpensive, retailing for $30US but the Evaluation Board which the OP proposed using costs $110US so is rather expensive. For setting the configuration, the WizFi210 also uses an AT command set similar to what ConnectOne uses so, while it lacks a few protocols (email, network time), programming looks fairly simple. It has two ADC pins and several DIO pins as well as multiple communications methods (Serial, SPI, I2C, etc.). It's main drawback is the need for a custom designed PCB.
That it has ADC functions is intriguing. It really makes no sense to have them if you can only read them with a microcontroller since you could likely do that more easily with the microcontroller ADC channels. There is an app note (HTTP Data Transfer) that appears to show how to read a sensor over HTTP but, like most of their documentation, is sparse and difficult to understand.
kenruizal
- 23rd November 2011, 15:50
sir what part number of your mini socket iwifi and model maker?tnx
kenruizal
- 23rd November 2011, 16:37
john...what is best to be used it is with evaluation board or without evaluation board mini socket iwifi?
kenruizal
- 8th December 2011, 14:54
Hello john and mackrackit..if it is ok to you..can i have ur schematic in full...tnx
kenruizal
- 14th December 2011, 16:52
uhm..Sir what must be use in oscillator is it ok 4mhz or 8mhz?..what software do you use to load into pic18f4550 sir?...
mackrackit
- 14th December 2011, 18:28
The internal 8MHz oscillator is fine for this.
I use a PicKit2 to load the hex file onto the 4550.
jellis00
- 15th December 2011, 01:30
uhm..Sir what must be use in oscillator is it ok 4mhz or 8mhz?..what software do you use to load into pic18f4550 sir?...I use an 8mhz external crystal with capacitors as shown in the schematic I will post with this. Like mackrackit, I also use the Pickit2 to load programs into my 18F4550.
kenruizal
- 22nd December 2011, 11:48
Hello sir john.. i would to know if the minisocket need an external antenna?or is it ok without extrnal antenna?tnx..
kenruizal
- 22nd December 2011, 12:23
hello john is it ok to use the the 16F873A?...uhm sir is it ok to disconnect the PICKIT2 when your are done load it to ur PIC?tnx
kenruizal
- 6th January 2012, 07:07
Sir do you have a schematic how u connect the max232 in iwifi connectone to interface in PC?
mackrackit
- 6th January 2012, 21:34
I can not find my schematic but...
Using the Nano Socket IWifi.
Header J8 iWifi pin 8 connect to pin 12 max232
Header J8 iWifi pin 9 connect to pin 11 max 232
Max232 pin 13 connect to PC DB9 pin 3
Max232 pin 14 connect to PC DB9 pin 2
And the grounds (zero rail) are all common.
kenruizal
- 8th January 2012, 16:58
Ok sir..tnx..Sir mackrackit in your program and design? are u using iconfig to send to ur website and email..?tnx sir
mackrackit
- 8th January 2012, 19:38
Ok sir..tnx..Sir mackrackit in your program and design? are u using iconfig to send to ur website and email..?tnx sir
Not sure I understand the question. This thread has all kinds of code showing how do send email and do FTP.
kenruizal
- 22nd January 2012, 12:30
Helo Sir...what software connectone u use to convert the HTML to image file?what is the name of software..tnx sir
mackrackit
- 22nd January 2012, 16:27
The Config Utility has the program used to do the conversion.
LGabrielson
- 16th June 2012, 19:21
Hi,
I just ordered a Connect One SocketLAN, and am doing some background searching for tips on how to hook it up to a PIC project. It looks like the serial pins are the most basic but am a little in the dark about the above conversation. Should I be adding hardware/provisions for a MAX232 circuit to talk to a terminal program too, and if so, how should it connect... to the PIC, or to the SocketLAN? I see Macrackit's code examples, but it doesn't tell me anything about how the hardware is connected. This is my first attempt at an ethernet project, and don't want to miss anything critical as I'm mulling over a board layout. I plan to start off with the PIC's serial connection to the SocketLAN for simple emails etc.
Anybody have a simple hookup drawing, or can explain what this terminal connection you're talking about is?
Thanks
mackrackit
- 16th June 2012, 19:46
Start at the beginning of the thread.
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.