• Simple Lopy to Lopy via WiFi

    4
    0 Votes
    4 Posts
    491 Views
    P
    Thanks @crumble and @timh for your answers! I've changed my code, because I want to implement a WiFi Direct between my two Lopy4 ( so one act like AP, and the other like STA). I have changed my code as you advised me: Server Main import usocket as socket import machine from network import WLAN wlan = WLAN() # get current object, without changing the mode if machine.reset_cause() != machine.SOFT_RESET: wlan.init(mode=WLAN.AP, ssid='Lopy-wlan', auth=(WLAN.WPA2,'www.pycom.io'), channel=10, antenna=WLAN.INT_ANT) myconfig = wlan.ifconfig() lst_myconfig = list(myconfig) lst_myconfig[0] = '192.168.0.20' myconfig = tuple(lst_myconfig) wlan.ifconfig(config=myconfig) print("Wlan configuration", myconfig) s = socket.socket() s.bind((lst_myconfig[0],2000)) s.listen(5) c, addr = s.accept() # Establish connection with client. print ('Got connection from', addr) c.send(b'Thank you for connecting') # Send bytes c.close() Client Main from network import WLAN import pycom import machine import socket ssid1 = "Lopy-wlan" password = "www.pycom.io" wlan = WLAN(mode=WLAN.STA) #station nets = wlan.scan() s = socket.socket() #create socket for net in nets: if net.ssid == ssid1: print("Found network: " + net.ssid) wlan.connect(net.ssid, auth=(net.sec, password), timeout=5000) #connected to lopy AP while not wlan.isconnected(): machine.idle() # save energy if wlan.isconnected() == True: print('WLAN connection succeeded!') s.connect(socket.getaddrinfo('192.168.0.20',2000)[0][-1]) b = bytes("Hello",'utf-8') s.sendall(b) #send bytes buffer = s.recv(64) #receive bytes print(buffer) #print bytes received s.close() I've upload Server code on my Lopy server, then I run Client code on my Lopy client, but when I try to connect the socket ( with s.connect(...)) I have OSError: -1. I've seached on google but I did not find anything. What can it be?
  • MEmoryError: memory allocation failed

    lopy memoryerror
    2
    0 Votes
    2 Posts
    495 Views
    C
    Depends. 2k on a LoPy is a lot of memory. If it occurs during compilation time, precompiling your code with mpy_cross is the solution. Otherwise it is not that easy. You have to reduce memory fragmentation. You can see the fragmentation with micropython.mem_info() Precompile as many files as you can. So the memory of the LoPy is not fragmented after boot time. Allocate huge buffers as early as you can. Reuse them instead of reallocate. You can try to call the garbage collector in front of your memory allocation. But this does not help in many situations. The garbage collector does not relocated objects in use, so the memory is still fragmented. If there is a background thread, it may fill your memory faster than you can free it. For example if it calculate float objects in a loop.
  • Change LoPy devEUI and LoRaWAN

    lopy lorawan otaa
    3
    0 Votes
    3 Posts
    420 Views
    B
    @eric73 Thank you for your answer, I think it replies my question: It is possible however it depends on the network server allowed behavior.
  • ABP - troubleshooting first connection attempt

    1
    0 Votes
    1 Posts
    193 Views
    No one has replied
  • Lora Antenna

    lora antenna lora
    3
    0 Votes
    3 Posts
    383 Views
    J
    @robert-hh Thanks for that will take a look
  • I am looking for a temperature and humidity sensor

    lopy wipy 3.0 bme280 sensor
    5
    0 Votes
    5 Posts
    483 Views
    W
    @robert-hh Okay, thanks for your help.
  • Is a TTN App Key the same thing as an Access Key?

    2
    0 Votes
    2 Posts
    267 Views
    dwsD
    @dws NM solved it. it's on the Device Overview page
  • Setup trouble - can't connect to device

    2
    0 Votes
    2 Posts
    436 Views
    dwsD
    @dws Drat I was using a charge-only usb cable. Does anyone know if there is a universal way that charge-only or true data + charge cables are indicated, ie does the presence of the USB logo indicate true data capability? I would just ring out the cable with a ohmmeter but it's not easy to tap into the pins and frankly it's an annoying thing to have to do. thanks
  • Lopy to Lopy via WiFi

    3
    0 Votes
    3 Posts
    294 Views
    P
    @sarthak04 Thanks! Now I have a problem with socket, so I will open a new thread :)
  • Display SSD1306 with lopy4 doesn't work

    ssd1306 oled spi
    5
    1
    0 Votes
    5 Posts
    613 Views
    G
    @paul-thornton no error display on the console and the display does not show anything. I give up with this module.
  • Send data from Android device to Lopy4 via Wifi (Sockets)

    lopy4 wifi ap sockets
    1
    0 Votes
    1 Posts
    286 Views
    No one has replied
  • Deep Sleep

    lopy deep sleep expansion board
    3
    0 Votes
    3 Posts
    437 Views
    W
    Thank You
  • Pymakr plug-in not working.

    lopy4
    2
    0 Votes
    2 Posts
    266 Views
    catalinC
    Hi @abhishek2101, do you still have a particular error? Maybe it's the node.js version, or some issue from Atom/VCS. I confirm the latest Pymakr works ok: Atom 1.34.0 -> pymakr 1.4.11 VSC 1.31.1 -> pymakr 1.0.7
  • Wake on any RX

    lopy4 sleep power saving
    4
    0 Votes
    4 Posts
    600 Views
    J
    @hanssanitizer Leaving the LoRa radio in RX mode means the LoRa chip will be drawing a bit over 10 mA at all times. What are your constraints in terms of battery size and battery lifetime? A relatively large 2500 mAh will be emptied in 10 days in this scheme, not even counting what is drawn when the LoPy is awake, so probably less than a week overall, depending on how often it wakes up, for how long, and what it does. If that's something that is acceptable for you, then one could probably explore modifying the firmware to handle that, though my guess the complexity will arise from having to bypass all the LoRa chip initialisation on startup. Note that if that kind of power budget is acceptable, maybe just using the light sleep modes may be OK and probably much easier. For reference, the original LoPy uses the SX1272 while the LoPy4 uses the SX1276. I believe the FiPy uses the SX1276 as well.
  • lora.nvram example needed

    nvram deepsleep lopy nvram lopy lorawan
    8
    0 Votes
    8 Posts
    2k Views
    G
    I know this is an old post but for me this is still an issue. Any may of learning more about the specifics would be very much appreciated e.g what does pycom.nvs_get(key) return? Should I see somthing in the REPL? Example: >>> lora.nvram_save() >>> l= pycom.nvs_get('lora') >>> print(l) None Am I going about this in completely the wrong way?
  • LoPy 4 + Expansion board 3.1 power consumption in deep sleep mode

    15
    0 Votes
    15 Posts
    1k Views
    robert-hhR
    @loth4in At the LoPy4, the flash file system has a capacity of 4 MB. And you can always connect by WiFi. So even if you do not have it enabled all the time, you could use a switch (reed contact) or button to tell the unit to activate WiFi. Then you can use ftp to access the data.
  • Lopy and Lopy4 Power-Up default GPIO states

    3
    0 Votes
    3 Posts
    299 Views
    K
    @robert-hh Thanks for your reply. It actually helped a lot :)
  • Send data serially from LoPy to PC

    8
    0 Votes
    8 Posts
    556 Views
    S
    @robert-hh yes the data that I receive is a combination of multiple sensor data, and I am sending it as a struct. So I guess the same would work here too. Thanks
  • ELF for 1.18.2.r1 (LoPy4)

    2
    0 Votes
    2 Posts
    254 Views
    I
    Hi @olivieroswald, .elf files are now uploaded on GitHub
  • india frequency 865-867

    india
    20
    0 Votes
    20 Posts
    2k Views
    robert-hhR
    @abhishek2101 I have pushed builds for LoPy4 and FiPy for the LORA IN865 region to the usual place https://github.com/robert-hh/Shared-Stuff. They are based on V1.20.0.rc7.2, FAT file system. I did not use littlefs, since I think to have seen some strange effects. I did not make too much tests. Just verified that they send & receive data.

Pycom on Twitter