Code: Select all
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
True
>>> sta_if.ifconfig(('192.168.10.99', '255.255.255.0', '192.168.10.1', '8.8.8.8'))
>>> sta_if.isconnected()
False
>>>
Code: Select all
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
True
>>> sta_if.ifconfig(('192.168.10.99', '255.255.255.0', '192.168.10.1', '8.8.8.8'))
>>> sta_if.isconnected()
False
>>>
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "local.py", line 21, in <module>
AttributeError: 'function' object has no attribute 'init'
Code: Select all
retval = e.init() # line 21
if (retval != None):
print('init() did NOT work')
machine.reset()
Code: Select all
e = espnow.ESPNow
Code: Select all
e = espnow.ESPNow()
Code: Select all
e = espnow.ESPNow()
Code: Select all
e = espnow.ESPNow()
Code: Select all
>>> import local
b'$\n\xc4Yd\x88'
2021-1-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "local.py", line 19, in <module>
AttributeError: 'str' object has no attribute 'init'
Without seeing your code, it is difficult to help. For me:davef wrote: ↑Tue Jan 19, 2021 11:39 pmSo, did a print(e) , after:and when it failed I saw:Code: Select all
e = espnow.ESPNow()
Looks like it is returning the date ??Code: Select all
>>> import local b'$\n\xc4Yd\x88' 2021-1- Traceback (most recent call last): File "<stdin>", line 1, in <module> File "local.py", line 19, in <module> AttributeError: 'str' object has no attribute 'init'
Code: Select all
from esp import espnow
e = espnow.ESPNow()
print(e)
Code: Select all
ESPNow(rxbuf=516, timeout=300000)
Code: Select all
<ESPNow>
Code: Select all
import network
from esp import espnow
import utime
import machine
from machine import Pin
# import ubinascii
pin2 = Pin(2, Pin.OUT) # Discharge pump clamp pin
pin2.off() # enable discharge pump on re-boot
# A WLAN interface must be active to send()/recv()
w0 = network.WLAN(network.STA_IF)
w0.active(True)
#mac = w0.config('mac')
#print(mac)
#mac = ubinascii.hexlify(w0.config('mac'),':').decode()
#print(mac)
e = espnow.ESPNow()
retval = e.init()
if (retval != None):
print('init() did NOT work')
machine.reset()
#peer = b'\x18\xfe4\xde\xea\xf3' # MAC address of ESP-01S local
peer = b'$\n\xc4Yd\x88' # MAC address of ESP32 local
retval= e.add_peer(peer)
if (retval != None):
print('add_peer did NOT work')
machine.reset()
print('waiting for command')
while True:
msg = e.irecv()
utime.sleep(1)
# if (msg != None):
if msg:
command = msg[1].decode('utf-8')
print(command)
if (command == 'pump off'):
print('You have turned the pump off')
pin2.on() # this disables the discharge pump
print('send ACK')
retval = e.send(peer, "pump is now off", True)
if (retval != True):
print('send did NOT work')
machine.reset()
utime.sleep(5)
retval = e.deinit()
if (retval != None):
print('deinit() did NOT work')
machine.reset() # just to be tidy
w0.active(False) # take-down WiFi
machine.reset()