Rachel Beddor
Published © GPL3+

Basic IoT Node on MPLAB Xpress Board

Become an IoT developer! This project will show you how just how easy it is to add WiFi communication to your next project.

BeginnerProtip1.5 hours791
Basic IoT Node on MPLAB Xpress Board

Things used in this project

Hardware components

MikroElektronika WiFly Click
×1
MPLAB Xpress Evaluation Board (DM164140)
Microchip MPLAB Xpress Evaluation Board (DM164140)
×1

Software apps and online services

Microchip MPLAB Xpress
Cloud-Based IDE for PIC Microcontrollers
MPLAB Code Configurator
Microchip MPLAB Code Configurator
Graphical Programming Tool, available as a plug-in to MPLAB

Story

Read more

Schematics

Image of Board Setup

Simply plug the WiFly click into the MikroBUS socket on the MPLAB Xpress board

Code

MPLAB Code

C/C++
To program the MCU using MPLAB X or MPLAB Xpress IDE
I recommend uploading it to MPLAB Xpress
No preview (download only).

Python 3 Server

Python
To run a Python 3 Server from your PC
'''
/*
    (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this
    software and any derivatives exclusively with Microchip products.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
    WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
    TERMS.
*/
'''

import socket
#from string import rstrip
#import string

s = socket.socket()
host = socket.gethostname()
port = 1337

s.bind((host,port))
print ('Socket bound')

s.listen(5)

c, addr = s.accept()
print ('Connection from', addr[0], '\n')

c.settimeout(5.0)

try:
    (c.recv(1024))
    c.send(b'Proceed')
    
    print("Remote: " + (c.recv(1024)).decode())
    
    response = b'Who\'s there?\n'
    c.send(response)
    print("Server: " + response.decode())
    
    whos = str.rstrip((c.recv(1024)).decode())
    print("Remote: " + whos + "\n")
    
    response = (whos + " who?\n")
    c.send(response.encode())
    print("Server: " + response)
    
    print("Remote: " + (c.recv(1024)).decode())
    
except socket.timeout:
    print ('Receive timed out')
    
c.close()
print ("Connection closed")
s.close()
print ("Socket closed")

Python 2.7 Server

To run the python server from your PC

Credits

Rachel Beddor
16 projects • 31 followers
Product Marketing Engineer, Microchip Technology. 8-bit AVR & PIC enthusiast. Georgia Tech.

Comments