• AVR Freaks

Hot!IoT based home automation using esp8266 and Pic16f877a

Author
Deylyte
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2019/10/12 08:51:47
  • Location: 0
  • Status: offline
2020/06/05 14:24:55 (permalink)
0

IoT based home automation using esp8266 and Pic16f877a

Hello guys,
so, i have been working on this IoT based home automation project I found on here: https://circuitdigest.com/microcontroller-projects/iot-based-web-controlled-home-automation-using-pic
 
i have built the circuit and tested it to make sure that my esp8266 module is receiving AT commands from my MCU. 
i made some alterations to the code, to allow for compiling  but when i upload the code for the home automation, nothing works.
i don't know if there is something wrong with the code. can anybody help please.
 
#1

8 Replies Related Threads

    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/05 15:50:21 (permalink)
    +1 (1)
    How can we comment on code you haven't posted?
    Is your 877 actually running? Last time you posted, you were still trying to get it to flash an LED.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    Deylyte
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/10/12 08:51:47
    • Location: 0
    • Status: offline
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/05 15:56:53 (permalink)
    0
    yes its working. i have  been practicing some interfacing projects with Pic16f877a
    i have interfaced with esp8266  before and used to send "station" AT commands and it works fine
    it just doesn't work for the home automation project on that link i posted.
    i have attached the code from my MPLABX IDE
     
    post edited by Deylyte - 2020/06/05 16:08:24
    #3
    Deylyte
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/10/12 08:51:47
    • Location: 0
    • Status: offline
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/07 00:45:12 (permalink)
    0
    Hello
    please has anyone been able to go through the code? I'm stuck. or if there is any home automation project with the PIC MCU you can recommend for me
     
    post edited by Deylyte - 2020/06/07 04:28:06
    #4
    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/07 01:35:35 (permalink)
    0
    There's a number of small problems with the code, but the big one is that you are enabling interrupts but do not have an interrupt service routine.
    You do have a function named "SerialRxPinInterrupt", but it is not declared as an ISR.
     Without a valid ISR, the first interrupt will make it crash.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    Deylyte
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/10/12 08:51:47
    • Location: 0
    • Status: offline
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/07 10:33:42 (permalink)
    0
    oh, ok. it looks a bit beyond my level to understand; so, i'll just do a little research and come back.
    thanks a lot for your patience
    #6
    Deylyte
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/10/12 08:51:47
    • Location: 0
    • Status: offline
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/28 11:01:19 (permalink)
    0
    Hi @Ric, Please, I'm still trying to debug my home automation code with pic 16f877a. 
    i want to ask if its possible to print to a serial monitor with a USB to TTL converter module I built?
    I want to check if the "serial print" function of my code is working.
    thanks
    ric
    There's a number of small problems with the code, but the big one is that you are enabling interrupts but do not have an interrupt service routine.
    You do have a function named "SerialRxPinInterrupt", but it is not declared as an ISR.
     Without a valid ISR, the first interrupt will make it crash.




    #7
    ric
    Super Member
    • Total Posts : 27629
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/28 13:32:42 (permalink)
    0
    Your interrupt handling is all wrong, so don't enable interrupts.
    i.e. remove
        //RCONbits.IPEN   = 1; // ENABLE interrupt priority
        GIE  = 1; // ENABLE interrupts
        INTCONbits.PEIE = 1; // ENable peripheral interrupts.
        PIE1bits.RCIE   = 1; // ENABLE USART receive interrupt
        PIE1bits.TXIE   = 0; // disable USART TX interrupt
     
    // make sure the RX flag is clear
        PIR1bits.RCIF = 0;

    Your transmit function will work, but pointlessly tries to clear a read-only flag.
    (Read what the datasheet has to say about the TXIF flag)
    Try just
    void serialwrite(char ch)
    {
        while(TXIF==0);  // Wait till the transmitter register becomes empt
        TXREG=ch;        // load the char to be transmitted into transmit reg
    }

     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    Deylyte
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2019/10/12 08:51:47
    • Location: 0
    • Status: offline
    Re: IoT based home automation using esp8266 and Pic16f877a 2020/06/29 08:02:31 (permalink)
    0
    ok sir
    thank you
    let me try it
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5