Not getting Sensor Readings in Pysense with FiPy Module
-
From this above code we are getting an error called OSERORR :-01
At which line of code?
-
@livius
Line number 6 and 7 -
@archana-kadam said in Not getting Sensor Readings in Pysense with FiPy Module:
Line number 6 and 7
I do not have your source code ;-)
what this lines contain? and why on 6 and 7 - error should be raised only once -
@livius
import sockethost = '127.0.0.1'
port = 80 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send('Hello, world')
data = s.recv(1024)
s.close()
print('Received', repr(data))
Here is code to connect to server,but we are enable to connect -
@livius
import machine
from network import WLANconfigure the WLAN subsystem in station mode (the default is AP)
wlan = WLAN(mode=WLAN.STA)
go for fixed IP settings (IP, Subnet, Gateway, DNS)
wlan.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '192.168.0.1'))
wlan.scan() # scan for available networks
wlan.connect(ssid='mynetwork', auth=(WLAN.WPA2, 'my_network_key'))
while not wlan.isconnected():
pass
print(wlan.ifconfig())
I tried with code also, but its continuously running but there no output. -
@archana-kadam
I should start with this question, what is your firmware version?import os os.uname() -
@livius
Is Pybytes a server. Can we send data and store in pybytes -
@livius
We have latest version of firmware installed 1.17.b -
@archana-kadam
You can send data to whatever you like, but for pybytes you need account.
Did you successfully connected to the wifi network? -
@livius
We are running the below code on the FiPy to send data to the server. and we are using FiPy in its default mode i,e Access Point Mode.import socket
s = socket.socket()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(socket.getaddrinfo('192.168.0.109', 80)[0][-1])
your_data = "Hello"
s.send("your_data")Can you send us the one complete example code which sends data from fipy to server. Where a local computer in the same network can be used as server.
Thank You
-
@archana-kadam
with default modeAPyou must connect your computer to Fipy.
In modeSTAyou connect your Fipy to computer (most often through router)
After you are connected to the network (local) you can communicate between computer and Fipy.from network import WLAN import socket wlan = WLAN(mode=WLAN.STA) # wlan.ifconfig(config=('192.168.0.105', '255.255.255.0', '192.168.0.1', '192.168.0.1')) - you can ommit this line if you need to connect by DHCP wlan.connect(ssid='mynetwork', auth=(WLAN.WPA2, 'my_network_key'), timeout=30000) while not wlan.isconnected(): machine.idle() if wlan.isconnected(): s = socket.socket() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(socket.getaddrinfo('192.168.0.109', 2345)[0][-1]) #IP of your computer(192.168.0.109) in the same network as your Fipy and port(2345) of socket in listen mode on your computer your_data = "Hello" s.send("your_data")remember that you must have something listen on incoming traffic on your computer then.
-
@livius
We have successfully connected to the server by the given code, but we are getting an error in line number 14, im sending the screenshot please go through the file
-
@archana-kadam
remove line 13s = socket.socket()P.S> i have blurred your password on the screenshot
-
@livius
I removed line 13 "s = socket.socket()" but also im getting an error in line number 15
i,e #your_data = "hello" -
@archana-kadam and the error is...?
-
@jcaron
OSError -1 -
@jcaron
I will attach the screenshot and i have highlighted the error line.

-
@archana-kadam are you sure you correctly re-uploaded the modified file?
-
@jcaron
Yes i re-uploaded the modified file.
Earlier it was #your_data = "Hello" -
@archana-kadam
Quite impossible on line 15 where you store text (connect to your device by ftp and look like your file really is)but do you have host
192.168.0.109and especially do you have something which listen on that host on port2345?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login