Page 1 of 1

Pycom GPy-Adafruit feather huzzah/laptop client connections

Posted: Mon Jul 09, 2018 6:53 pm
by AdityaNarayanan
Hi all,

We are attempting to set up a feather huzzah as a client, which sends data to a Pycom GPy server. Instead of using PyBytes to graph our data, we are using a laptop as a second client to graph the data. Our goal is to transfer all the data over wireless connections rather than using a serial port.
The following data path is: sensor input into huzzah --> Pycom GPy server --> laptop client for plotting.

We are unable to connect both clients to the Pycom GPy at the same time. We are able to connect the laptop client to the Pycom GPy over the GPy's built in WiFi network. We set up the huzzah as a station using WLAN(network.STA_IF), and the GPy as an access point using WLAN.AP mode. But, setting the GPy in wlan.AP mode breaks the connection between the laptop and the GPy since the mode is changed.

Is there any way in which we can connect both the laptop and the feather huzzah to the GPy as clients at the same time?

We have included some of our MicroPython code below.

:arrow: GPy server code:
wlan = WLAN(mode=WLAN.AP, ssid = 'Pycom', auth =None, channel=1,antenna=None,power_save=False,hidden=True)
print("Network Setup!")
def main():
port = 324
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('Socket created')
server_address = ('',port)
sock.bind(server_address)
print('Socket bind complete')
sock.listen(1)
print('Socket now listening')
print('Accepting clients on port',port)
try:
while True:
conn,addr = sock.accept()
print('Client connected:: ', addr)
start_new_thread(clientthread, (conn,port,sock))
finally:
print('End')

:arrow: Laptop/huzzah client code:
wlan = network.WLAN(mode=network.WLAN.STA) #only included on huzzah
#setup client socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = "192.168.4.1"
port = 324
server_address = (address, port)
#connects to server
sock.connect(server_address)
print("connecting to ",address," on port ",port)

Thank you for any help and feedback!

Re: Pycom GPy-Adafruit feather huzzah/laptop client connections

Posted: Thu Jul 12, 2018 8:16 am
by pythoncoder
You might access more know-how about the GPy on the PyCom forum.