Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Trouble with FiPy code not working

    Scheduled Pinned Locked Moved FiPy
    fipycode
    33 Posts 8 Posters 9.8k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      livius @Dylan
      last edited by

      @dylan
      without the sample i suppose no one can predict the reason

      think about people first, then computers

      D 1 Reply Last reply Reply Quote 1
      • D Offline
        Dylan @livius
        last edited by

        @livius I am using the sample code from the LoRaWAN nano-gateway docs for the node with ABP.

        D 1 Reply Last reply Reply Quote 0
        • D Offline
          Dylan @Dylan
          last edited by

          @dylan Looks like it isn't waking up from time.sleep or machine.deepsleep, I'll give that a google and see how it goes.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dylan
            last edited by

            Downgrading the firmware has solved the problem

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dylan
              last edited by

              Not sure if coincidence or not, but straight after downgrading the firmware I get the following error in atom:
              Failed to load the Pymakr package
              Cannot find module 'serialport'

              I've tried re-installing many times to no success, I'm just going to Filezilla what I need to test over the weekend and let it be a Monday problem, but if you have any ideas whats going on there, any help would be appreciated,

              sebS 1 Reply Last reply Reply Quote 0
              • sebS Offline
                seb @Dylan
                last edited by

                @dylan
                Can you share the code that didnt work until you upgraded? If you dont want to share publicly you can email it to me: sebastian@pycom.io

                As for the pymakr issue, I will pass this along to that team, they will be in touch soon.

                D 1 Reply Last reply Reply Quote 0
                • R Offline
                  Ralph
                  last edited by

                  @Dylan Sorry about this, but Pymakr has some issues with Atom 1.25. If you are on OSX, update to todays v1.2.10 of Pymakr. For windows and linux we are still working on a fix.

                  D 1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dylan @Ralph
                    last edited by

                    @ralph Ok Cool, it all worked on the home computer so I managed to get a bit of work done over the weekend anyway.

                    @seb No problem, I'll put both here next post.

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      Dylan @seb
                      last edited by seb

                      @seb
                      The code that worked on LoPy but not on FiPy. Worth noting that the LoPy was 1.11.0.b1 which is the version I downgraded the FiPy too.

                      Also how do I make the code look all neat in posts like I've seen elsewhere?

                      from network import LoRa
                      from pytrack import Pytrack
                      from coords import Coords
                      from CayenneLPP import CayenneLPP
                      from L76GNSS import L76GNSS
                      from LIS2HH12 import LIS2HH12
                      import machine
                      from machine import Pin
                      from machine import I2C
                      import socket
                      import binascii
                      import struct
                      import time
                      import array
                      # Initialize LoRa in LORAWAN mode.
                      lora = LoRa(mode=LoRa.LORAWAN, public=1,  adr=0, tx_retries=0)
                      # Remove default channels
                      dev_addr = struct.unpack(">l", binascii.unhexlify('269928E2'.replace(' ','')))[0]
                      nwk_swkey = binascii.unhexlify('7A7E7000000F93BD1BB4693127C374FE'.replace(' ',''))
                      app_swkey = binascii.unhexlify('F93BD1BBBA53BBF3B4096A72115E9F5D'.replace(' ',''))
                      
                      for index in range(0, 72):
                          lora.remove_channel(index)
                      
                          lora.add_channel(index, frequency=918000000, dr_min=0, dr_max=3)
                      
                      lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey), timeout=0)
                      # wait until the module has joined the network
                      
                      
                      while not lora.has_joined():
                          time.sleep(5)
                      
                      # remove all the non-default channels
                      
                      for i in range(8, 15):
                          lora.remove_channel(i)
                      # create a LoRa socket
                      s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
                      
                      # set the LoRaWAN data rate
                      
                      s.setsockopt(socket.SOL_LORA, socket.SO_DR, 3)
                      
                      # make the socket blocking
                      s.setblocking(False)
                      time.sleep(2.5)
                      while lora.has_joined():
                          acc = LIS2HH12()
                          pitch = acc.pitch()
                          roll = acc.roll()
                          time.sleep(1)
                          py = Pytrack()
                          battery = py.read_battery_voltage()
                          battery = battery * 10
                          cayenne = CayenneLPP()
                          time.sleep(1)
                          l76 = L76GNSS(py, timeout=10)
                          lat1 = str(l76.lattitude())
                          lon1 = l76.longitude()
                          if len(lat1) > 5:
                              lona = lat1
                              lata = lon1
                              meta = 9500
                              lat = float(lona)
                              lon = float(lata)
                              met = float(meta)
                              cayenne.add_gps(4, lat, lon, met)
                              cayenne.add_temperature(3, battery)
                              s.send(cayenne.get_buffer())
                      
                          if len(lat1) < 5:
                              cayenne = CayenneLPP()
                              cayenne.add_temperature(3, battery)
                              s.send(cayenne.get_buffer())
                              print('No fix')
                          rx = s.recv(256)
                          if rx:
                              print(rx)
                          machine.deepsleep(890000)
                      
                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        MJ
                        last edited by

                        @ralph Is the Pymakr version 1.2.10 compatible for the Atom 1.25.0 already? As until now i am unable to install the Pymakr 1.2.10 and show me failed to search for the Pymakr package " connect ETIMEDOUT 50.16.223.157.443". May i know how can i solve this? Thank you.

                        D 1 Reply Last reply Reply Quote 0
                        • D Offline
                          Dylan @MJ
                          last edited by

                          @mj
                          Not sure if this will help but I just downloaded the VScode and got it running so I can do all I need to do in that.

                          https://docs.pycom.io/chapter/pymakr/installation/vscode.html

                          M 1 Reply Last reply Reply Quote 0
                          • M Offline
                            MJ @Dylan
                            last edited by

                            @dylan Thanks for sharing but i am using the Atom not the Visual Studio. But until now the Pymakr still cannot installed.

                            D 1 Reply Last reply Reply Quote 0
                            • D Offline
                              Dylan @MJ
                              last edited by

                              @mj I've tried lots of different things to get Atom working again with no luck, I just didn't even realize Visual studio was an option, I'm liking it so far.

                              M 1 Reply Last reply Reply Quote 0
                              • M Offline
                                MJ @Dylan
                                last edited by

                                @dylan Is it Visual Studio code work as the same as the Atom? The language using also the same?

                                D 1 Reply Last reply Reply Quote 0
                                • D Offline
                                  Dylan @MJ
                                  last edited by

                                  @mj Very similar, the biggest difference I found is the Run/Upload/Download buttons are down the bottom left and I guess it all looks slightly different ofcourse.

                                  1 Reply Last reply Reply Quote 0
                                  • sebS Offline
                                    seb
                                    last edited by

                                    @Dylan
                                    I would recommend adding some print statements into the code you shared to see where it gets stuck on your fipy

                                    D 1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      Dylan @seb
                                      last edited by

                                      @seb Yeah I've been putting print("Line #") to catch the errors, excellent way of debugging. However in this case it makes it all the way to the end, it just never wakes back up from either the deepsleep I have above or the time.sleep(10) I use for quick testing (a print is always on the last line of code to check it makes it there).

                                      sebS 1 Reply Last reply Reply Quote 0
                                      • sebS Offline
                                        seb @Dylan
                                        last edited by

                                        @dylan

                                        two things

                                        1. Code after a deepsleep will never run, once the device goes to deepsleep and wakes up it will be just like the reset button was pressed, it does not continue execution from where it went to sleep

                                        2. I see no reason why your module should lock up and not wake from deep sleep with the code sample above, Have you tried the latest firmware?

                                        D 1 Reply Last reply Reply Quote 0
                                        • D Offline
                                          Dylan @seb
                                          last edited by

                                          @seb 1. This is true, I had many prints throughout and I'm reasonably sure I thought of that haha
                                          2. This was tried on the latest firmware and pytrack updates as these were new FiPys just arrived. I've had a few things go right for me so I have a some spare time, I might update a FiPy and try to recreate the error and work from there.

                                          L 1 Reply Last reply Reply Quote 0
                                          • L Offline
                                            livius @Dylan
                                            last edited by

                                            @dylan said in Trouble with FiPy code not working:

                                            This was tried on the latest firmware and pytrack updates as these were new FiPys just arrived. I've had a few things go right for me so I have a some spare time, I might update a FiPy and try to recreate the error and work from there.

                                            this does not guarantee that you have recent firmware there

                                            think about people first, then computers

                                            D 1 Reply Last reply Reply Quote 0

                                            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
                                            • 1
                                            • 2
                                            • 2 / 2
                                            • First post
                                              Last post

                                            Pycom on Twitter

                                            Pycom