0

I am facing an issue in connecting my ESP-32(in micropython) to my socket server(in nodejs). I have successfully connected to server via browser or flutter but I am unable to connect to it using my esp32. I am new to micropython , please help me to find the "correct approach" or "some library" so that I can move ahead. I am stuck due to this. Any help or suggestion will be appreciated.

Thank you in advance

1 Answer 1

1

If this is a general question about sockets, you should try usocket documented at https://docs.micropython.org/en/latest/library/usocket.html. The examples below are more or less the same from the usocket docs:

Sockets can be created like this :

# TCP socket
s = usocket.socket(AF_INET, SOCK_STREAM)

# UDP socket
s = usocket.socket(AF_INET, SOCK_DGRAM)

After this, you can do s.connect(...), s.send(...), s.write(...), socket.recv(...), s.read(..) etc.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank You for your answer. I will try this. i have gone through the docs but find its difficult to implement . eg I need to pass query param with socket. I switched back to ardunioIDE back for now. but i will give some try more in micropython.
Please correct me if I'm wrong, but it sounds like you are new to Python socket programming. I would suggest testing some Python code on a computer before trying to implement it on a microcontroller. You can use the libraries (almost) the same way.
yes , i am new to micropython and infact i am new to python :D . so you suggest for i need to learn python before learning micropython ?
Simple answer: Yes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.