Esp01 esp8266 + pic


+ Reply to Thread
Results 1 to 8 of 8

Thread: Esp01 esp8266 + pic1405 days old

  1. #1
    Pic
    Guest

    0 Not allowed!

    Default Esp01 esp8266 + pic

    Hello everyone
    I'm trying to use the module ESP01 ESP8266 managed by a pic in serial to realize a relay actuation tab.
    Through micro managed to send all of the various AT commands to set the module I created the app control via smartphone and now everything works. The problem comes when I want a confirmation of implementation took place. I tried using these command strings to send an acknowledgment from the pic to ESP8266 and then to the smartphone this is the part of code:

    HSEROUT [ "AT + CIPSEND = 0.5", 13,10]
    HSEROUT [ "200", 13,10]

    0 of the first command line should show the id and the 5 must indicate the number of characters that later we inviare.Infatti 200 + 13 + 10 if I am not mistaken are treated as 5 characters.

    Trying with these commands in a serial transmission from the pic to ESP8266 the 200 number is sent, but I do not know if the module then I send it to your smartphone via wi-fi.

    For you to send via AT + CIPSEND syntax is correct?

    Thank you all

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    566
    Thumbs Up
    Received: 36
    Given: 26
    Total Downloaded
    4.47 GB

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Hi Pic,

    Should the line.....

    HSEROUT [ "AT + CIPSEND = 0.5", 13,10]

    not be.......

    HSEROUT [ "AT + CIPSEND = 0,5", 13,10]

    Don't forget to close the connection using

    AT+ CIPCLOSE=5

    or similar. My browsers don't display anything until this is done.


    I too am playing around with the ESP8266 and AT commands and have produced the little program below. It uses a DS18B20 to measure the current temperature and displays it on a web page. To be honest, I don't think it's the best way to use the ESP modules but it does work and it might give you a few ideas. I'd be interested in looking at your code too if you're willing to share.


    Code:
    '****************************************************************
    '*  Name    : ESP8266 web based temperature sensor using DS18B20*
    '*  Author  : Bob Marshall                                      *
    '*  Date    : 4/26/2016                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Only intended as "proof of concept".              *
    '*          : This program uses a 18F25K22 to control an        *
    '*          : unmodified ESP8266-01 WiFi module using standard  *
    '*          : AT commands. A web server is set up on the module *
    '*          : which, when connected to by a web browser, will   *
    '*          : display the current temperature as measured by    *
    '*          : the DS18B20. The Max/min temperatures seen by the *
    '*          : '18B20 are also displayed.                        *
    '****************************************************************
    
      Device = 18F25K22
    
    
      Xtal 64
    
      Declare Stack_Size = 127 'Wot, no more stack space :-(.
      Declare All_Digital = true
    
     'Calculated Baudrate = 115108 @ Xtal 64MHz, Error = -0.08%
      Declare Hserial_RCSTA  = 144 ; Enable continuous receive
      Declare Hserial_TXSTA  = 36  ; Enable transmit, BRGH = 1
      Declare Hserial_Clear  = On  ; Clear overflow automatically
      Declare Hserial_SPBRG  = 138 ; Baud Rate Generator Low Byte Value
      SPBRGH                 = 0   ; Baud Rate Generator High Byte Value
      BAUDCON.3              = 1   ; Enable the 16 bit Baud Rate Generator
    
    
    ;-------------------------------------------------------------------------------
    
      Dim TmpStr As String * 127    ' Limited by the maximum stack size
      Dim TmpStr2 As String * 127
    
      Dim Temperature     As    Word
      Dim TempHigh        As  Temperature.HighByte
      Dim TempH           As  Byte
      Dim TempL           As  Byte
      Dim sign            As  Bit
      Dim MaxTemp         As  Word
      Dim MinTemp         As  Word
      Dim TemperatureStr  As String * 25
    
      Symbol DQ       =     PORTB.0
      
      
      'Wait for an "OK" responce from the ESP module when
      'an AT command is sent. 
      $define WaitOK  HSerIn [Wait("OK")]
    
      Clear
      GoTo Main
      
    '********************************************************
      SendATCmd:
        Dim CmdStr As String * 50
        Dim Delay As Word
        Pop CmdStr
        HSerOut ["AT+",CmdStr,13,10]
        WaitOK
      Return
    '*******************************************************
    ' This routine finds the length of the HTTP string to 
    ' be sent to the ESP module server. It tells the server 
    ' how long each string is using CIPSEND. Once this is done, 
    ' the string itself is sent. Multiple strings can be sent, but
    ' the connection must not be closed until ALL string necessary
    ' to make up the web page have been sent.
    
      SendHTTP:
          Dim HTTPlen As Byte
          Dim HTTPStr As String * 100
          Dim HTTPStrLen As String * 20
          Pop HTTPStr
          HTTPlen = Len(HTTPStr)
          HTTPStrLen = "CIPSEND=0,"+ Str$(Dec HTTPlen)
          GoSub SendATCmd [HTTPStrLen]
          HSerOut [HTTPStr]
          WaitOK
      Return
    '*******************************************************
      GetTemp:
          OWrite DQ, 1, [$CC, $44]      ' Start temperature conversion
          DelayMS 800
          OWrite DQ, 1, [$CC, $BE]
          ORead DQ, 0, [Temperature.LowByte, Temperature.HighByte, Skip 6]
          ' Check for new max/min temperature values
          If Temperature.15 = MaxTemp.15 And Temperature > MaxTemp Then MaxTemp = Temperature
          If Temperature.15 = 0 And MaxTemp.15 > 0 Then MaxTemp = Temperature
    
          If Temperature.15 = MinTemp.15 And Temperature < MinTemp Then MinTemp = Temperature
          If Temperature.15 > 0 And MinTemp.15 = 0 Then MinTemp = Temperature            
      Return
    '*******************************************************
      Temp2Dec:
        sign = 0
        If  TempHigh.7 = 1 Then
          Temperature  =  ~Temperature + 1
          sign = 1
        EndIf 
        TempH = Temperature >> 4
        TempL = Temperature.LowByte & $0F
        Temperature = Dig (TempL * 625),3
        TemperatureStr = Str$(Dec TempH) + "." + Str$(Dec Temperature) + $B0 + "C" 
        If sign = 1 Then
          TmpStr = "-" + TemperatureStr
          TemperatureStr = TmpStr
        EndIf
      Return
    '*******************************************************
      SendTemp:
        Pop TmpStr2
        GoSub Temp2Dec
        TmpStr = "<h1>" + TmpStr2 + " Temp: " + TemperatureStr + "</h1>"
        TemperatureStr = TmpStr
        GoSub SendHTTP [TemperatureStr]
      Return
    '*******************************************************
    
      Main:
      DelayMS 11000 'Yes, this is necessary!
      GoSub GetTemp
      MaxTemp = Temperature
      MinTemp = Temperature
      'Set the ESP8622 to client mode
      GoSub SendATCmd ["CWMODE=1"]
      
      ' Join your wireless network. Your router will automatically assign
      ' an IP address to the ESP module. Make sure you can find out what
      ' it is or use the CIPSTA command to manually assign an IP address.
      TmpStr =  "CWJAP="+$22+"MyNetwork"+$22+","+$22+"MyPassword"+ $22
      GoSub SendATCmd [TmpStr]
      
      'Tell the ESP module to allow up to 4 connections. 
      GoSub SendATCmd ["CIPMUX=1"]
      
      'Start the web server on port 80 (80 is standard)
      GoSub SendATCmd ["CIPSERVER=1,80"]
    
      While
          
          'Wait until a connection to the server is made.
          HSerIn [Wait("+IPD")]   
          
          GoSub GetTemp
          
          ' Send the current, maximum and minimum temperatures to the web browser.
          GoSub SendTemp ["Current "]
    
          Temperature = MaxTemp
          GoSub SendTemp ["Max "]
    
          Temperature = MinTemp
          GoSub SendTemp ["Min."]
    
          ' Close all connections once the HTTP has been sent.
          GoSub SendATCmd ["CIPCLOSE=5"]
    
      Wend
    
    ' End of program
    
    
    ; **** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings
    
    
      Config_Start
          FOSC = HSMP    ;HS oscillator (medium power 4-16 MHz)
          PLLCFG = On    ;Oscillator multiplied by 4
          PRICLKEN = On    ;Primary clock enabled
          FCMEN = OFF    ;Fail-Safe Clock Monitor disabled
          IESO = OFF    ;Oscillator Switchover mode disabled
          PWRTEN = OFF    ;Power up timer disabled
          BOREN = SBORDIS    ;Brown-out Reset enabled in hardware only (SBOREN is disabled)
          BORV = 190    ;VBOR set to 1.90 V nominal
          WDTEN = Off    ;WDT is always enabled. SWDTEN bit has no effect
          WDTPS = 32768    ;1:32768
          CCP2MX = PORTC1    ;CCP2 input/output is multiplexed with RC1
          PBADEN = On    ;PORTB<5:0> pins are configured as analog input channels on Reset
          CCP3MX = PORTB5    ;P3A/CCP3 input/output is multiplexed with RB5
          HFOFST = On    ;HFINTOSC output and ready status are not delayed by the oscillator stable status
          T3CMX = PORTC0    ;T3CKI is on RC0
          P2BMX = PORTB5    ;P2B is on RB5
          MCLRE = EXTMCLR    ;MCLR pin enabled, RE3 input pin disabled
          STVREN = On    ;Stack full/underflow will cause Reset
          LVP = On    ;Single-Supply ICSP enabled if MCLRE is also 1
          XINST = OFF    ;Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
          Debug = OFF    ;Disabled
          Cp0 = OFF    ;Block 0 (000800-001FFFh) not code-protected
          CP1 = OFF    ;Block 1 (002000-003FFFh) not code-protected
          CP2 = OFF    ;Block 2 (004000-005FFFh) not code-protected
          CP3 = OFF    ;Block 3 (006000-007FFFh) not code-protected
          CPB = OFF    ;Boot block (000000-0007FFh) not code-protected
          CPD = OFF    ;Data EEPROM not code-protected
          WRT0 = OFF    ;Block 0 (000800-001FFFh) not write-protected
          WRT1 = OFF    ;Block 1 (002000-003FFFh) not write-protected
          WRT2 = OFF    ;Block 2 (004000-005FFFh) not write-protected
          WRT3 = OFF    ;Block 3 (006000-007FFFh) not write-protected
          WRTC = OFF    ;Configuration registers (300000-3000FFh) not write-protected
          WRTB = OFF    ;Boot Block (000000-0007FFh) not write-protected
          WRTD = OFF    ;Data EEPROM not write-protected
          EBTR0 = OFF    ;Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
          EBTR1 = OFF    ;Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
          EBTR2 = OFF    ;Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
          EBTR3 = OFF    ;Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
          EBTRB = OFF    ;Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
      Config_End
    
    ;**** End of Fuse Configurator Settings ****
    ;----------------------------------

    Bob
    Last edited by Mellbreak; 24th May 2016 at 11:44.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Pic
    Guest

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Thanks for having responded Mellbreak and sharing your work. I have seen from your code that imposed ESP8266 as Station mode (AT + CWMODE = 1) to connect the module to the Internet network instead .I have set ESP8266 as AP (AT + CWMODE = 2) to try to create a form control system + pic controlled by an app that I have already made via the App inventor. I managed to send the command strings with this App to turn on or off an LED.
    Enter through this app 192.168.1.20/1 string to turn on
    Enter through this app 192.168.1.20/0 string to turn off

    Now as I said the problem is that I can not send a confirmation response from the module on or off LEDs. I too have used the command: -

    Code:
    HSEROUT [ "AT + CIPSEND = 0.5", 13,10]
            HSEROUT [ "400", 13,10]
    I try to send the 400 response number to communicate the app that the LED is off
    
    HSEROUT [ "AT + CIPSEND = 0.5", 13,10]
               HSEROUT [ "200", 13,10]
    
    I try to send the 200 number to advise the app that the LED is on.
    
    I do not know if I'm wrong somewhere tell me
    
    Here's the code I did:
    ----------------------------------------------------
    main:  
    High led
    HSerIn [Wait("ready")]
    Low led
    GoTo setup
    ----------------------------------------------------
    main1:
    HSerIn [Wait("+IPD")]
    HSerIn [Wait("pin"),Dec2 stato ]
    GoSub decisionale
    GoTo main1
    ---------------------------------------------------
    decisionale:
    
    If stato = 0 Then 
     If flag.0 = 1 Then    
      Low led
    
        HSerOut["AT+CIPSEND=0,5",13,10]
            HSerOut["400",13,10]
        flag.0 = 0  
                    
     End If
    End If       
    
     If stato = 1 Then 
       If flag.0 = 0 Then  
        High led 
        HSerOut["AT+CIPSEND=0,5",13,10]
               HSerOut["200",13,10]
          flag.0 = 1
          
       End If                
     End If         
    
    HSerOut["AT+CIPCLOSE=5",13,10]     
       HSerIn [Wait("OK")]
    Return 
    
    ----------------------------------------------------
    
    setup:
    
    For x = 0 To 2
     High led 
      DelayMS 500
       Low led
        DelayMS 500 
     Next x                
    
    HSerOut["AT+RST",13,10]   
      HSerIn [Wait("ready")]
       DelayMS 100             
    HSerOut["AT+CWMODE=2",13,10]  
       HSerIn [Wait("OK")]
        DelayMS 100
    HSerOut["AT+CIPMUX=1",13,10]
       HSerIn [Wait("OK")]
        DelayMS 100
    HSerOut["AT+CIPAP=",34,"192.168.1.20",34,13,10] 
        HSerIn [Wait("OK")]
         DelayMS 100
    HSerOut["AT+CIPSERVER=1,80",13,10]
        HSerIn [Wait("OK")]
         DelayMS 100
    HSerOut["AT+CWSAP=",34,"SAN MICHELE",34,",",34,"1234",34,",2,3,4",13,10] 
       HSerIn [Wait("OK")] 
    
    For x = 0 To 2
     High led 
      DelayMS 500
       Low led 
        DelayMS 500
     Next x       
                              
    GoTo main1
    Last edited by joesaliba; 26th May 2016 at 16:10.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,169
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Why does this article keep appearing in What's New?
    JohnB

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,858
    Thumbs Up
    Received: 90
    Given: 34
    Total Downloaded
    4.60 GB

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    It hasn't been for me John. I do use mark messages as read fairly often when there are RSS feeds I'm not interested in. Maybe that clears things.
    John D

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Pic
    Guest

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Mellbreak I wanted to ask what you use to display the temperature data?
    Use an app or a html page loaded on ESP8266 form?
    Thank you

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Senior Member Mellbreak's Avatar
    Join Date
    Jun 2012
    Posts
    566
    Thumbs Up
    Received: 36
    Given: 26
    Total Downloaded
    4.47 GB

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Hi Pic,

    I'm currently using an html page.


    Bob

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Pic
    Guest

    0 Not allowed!

    Default Re: Esp01 esp8266 + pic

    Thanks for answering me .
    But the html page I loaded on esp8266 or on the pic?
    Because seeing the listing above you entered do not see the html page.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 5
    Last Post: 29th October 2018, 19:43
  2. Very High speed coms between Master Pic- Slave pic (needed)
    By Tim in forum Proton Plus Compiler v3
    Replies: 28
    Last Post: 27th April 2016, 15:25
  3. ESP8266 wifi module
    By RayEllam in forum WiFi
    Replies: 29
    Last Post: 1st October 2015, 00:24
  4. ESP8266 wifi module
    By RayEllam in forum The Lounge
    Replies: 27
    Last Post: 21st September 2015, 17:16

Tags for this Thread

Posting Permissions

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