Jump to content
Electronics-Lab.com Community

Simple Server controlled LED -- MicroPython with Ameba


Recommended Posts

This is MicroPython project developed using Ameba RTL8722.
MicroPython is offically supported on Ameba RTL8722, so through this demo video, we will see how easy and fast it is to develop a simple server socket on Ameba, which would then control other peripheral to perform other tasks.
Here we are using a client socket code running on PC to send a 'Hello, world' string via the WiFi network, Ameba receives it and if it is indeed 'Hello, world' then it will blink the LED.
Check out the demo video down below,
Code used:
#!/usr/bin/env python3

#PC Client code

import socket

HOST = ''  # The server's hostname or IP address
PORT = 80        # The port used by the server

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    s.send(bytes('Hello, world','utf8'))


#Ameba Code

from machine import Pin
from wireless import WLAN
import time
import socket

led = Pin("PB_4",Pin.OUT)

s = socket.SOCK()
port = 80
data = ' '


conn, addr = s.accept()

while True:
	data = conn.recv(1024)
	if data == b'Hello, world':
		print('turn on LED 1')
		for i in range(6):
	if not data:


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...