mackrackit's ConnectOne example code


Closed Thread
Results 1 to 40 of 92

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    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!

    Last edited by jellis00; - 10th October 2011 at 05:05.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    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.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    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

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    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.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: mackrackit's ConnectOne example code

    Up date..<br>Trying to set up the iChip using only AT commands like you are. Not having much luck. &nbsp;Have to get back to work. Will continue later.

  7. #7
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    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




  8. #8
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378

    Default Re: mackrackit's ConnectOne example code

    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

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts