How do I communicate to NodeMCU module through python? - python

Basically I want to be able to send instructions for a bot over WiFi using the nodeMCU module, but I cant find any detailed functions list that can help me.
I've already tried setting up a server on the NodeMCU, and then a html webpage can then be created on my laptop with buttons for instructions from this and it works, but when I try to to the same on python, (send GET requests through python) I get this error on trying to do more than one request:
ConnectionError: ('Connection aborted.', ConnectionAbortedError(10053, 'An established connection was aborted by the software in your host machine', None, 10053, None))
Also I think the converse would be better suited for my case, a server on the laptop and client as the module, but I don't know where to start.
I coded the on the module using arduino IDE and on my laptop I'm using spyder. For sending requests and stuff I'm using the requests package.

You can create HTTP endpoints in nodeMCU and call them from your python script.
For this to work, both the nodeMCU and the machine running the python script has to be in the same network. and the IP address of the nodeMCU should be correctly added in the python script.
If you wanted to use your laptop as the server, I would suggest going with an MQTT broker such as mosquito, and communicate between the nodeMCU and the python script using the MQTT protocol.

Related

Raspberry Pi unable to connect to Windows Websocket

I am attempting to send data from a Python script running on a Raspberry Pi to a Java Micronaut ServerWebSocket running on a Windows machine, but I am getting asyncio.exceptions.TimeoutError errors during the process.
I attempted to use the websockets library in Python on the Raspberry Pi to establish a websocket connection, but encountered a ConnectionRefusedError. Is this issue related to a network problem as mentioned here, and should I ask somewhere else like Superuser or Serverfault? Or is there another solution to this problem?
As #life888888 suggested, it had something to do with Windows firewall.
But instead of the public firewall being the problem, it was the one for the domain network instead.

How do I make a Python socket server that is connected to another Python socket server?

I'm creating a Python socket server that is supposed to handle requests from a frontend JavaScript. The Python backend needs to be simultaneously connected to another socket server to download real time crypto prices. How would I go about doing that?
I've tried many things, but I'm not able to get both the server and client functionality on my Python working.

How to interact with Influxdb running on a remote Windows 10 PC in a local network?

I'd like to make a post request by whatever method to write a new point into Influxdb database called my_db, running on another PC in my local network. The PC with Influxdb 1.8 runs on Windows 10. So far I tried to use Python in this way:
import requests
requests.post(url="192.168.x.x:8086/write?db=my_db", data=my_data)
But I'm getting an error:
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for '192.168.x.x:8086/write?db=my_db'
Is there some kind of setup to be done in order to enable remote connections? Please excuse my ignorance, but I'm not very comfortable with the networking stuff. If possible, I'd like to avoid any kind authentication.

Forward a FTP port via UPnP in Python

I am making a Python application that requires the server to have an FTP port forwarded to his computer(a Rasberry PI3) in order to communicate with client. The current implementation works quite great, yet the only thing is that the person who's running the file must forward the port to the local IP manually. I want to automate this. I have serached a lot but i didnt find anything.

How to establish a Putty Serial connection through a Python script?

From a Python script, I would like to start PUTTY for a serial line (COM1, COM2,.. etc) and also mention the speed through python script.
I have explored, but most of the information is helpful for Python to Putty (SSH) connection.
Will it be possible to establish Python to Putty(Serial) connection and take logs?
If your goal is to communicate over serial link, consider using
PySerial, I used it many times for communicating with devices connected via serial link and it works very well on MS Windows as well as on Linux.
Putty is just a type of console, which allows to communicate with serial link, but for your Python it is not required.

Categories

Resources