Pybytes send signal arguments



  • Hi,
    I'm trying to use Pybytes using the NB-IoT connection on my Fipy. Starting the Pybytes connection at boot, the device is able to connect and to send signals. When I do not initialise Pybytes at boot, usign the command 'from _pybytes import Pybytes, pybytes = Pybytes' from the documentation, when I try to send a signal, I get this following error: 'TypeError: function takes 3 positional arguments but 2 were given'. What is the third argument?
    I have another question: when I initialise Pybytes at boot, the device is able to send signals, but sometimes it gets stuck, it reboots, or it sends signals but these messages are not received... it is not reliable at all. The device connects to Pybytes and then I just use the send_signal function: am I missing something?
    Thank you



  • @Gijs Yes, I am able to connect to pybytes, but I was curios to see if I was able to perform an HTTP request to my server with the cellular network, but it's not possible as you've told me. Thank you very much for your support.


  • Global Moderator

    If you are using a Pycom simcard, that is indeed the cause, I used to get EAI failed (error address info) though, but that could be related to your setup. Are you able to connect to pybytes though?



  • @Gijs Thanks for your answer. But is this library not useful when using NB-IoT connection? I get the 'ECONNABORTED' error when I try to reach an IP address via NB-IoT, while it works fine when I use Wi-Fi. I get the same error when I follow the example on the 'LTE power consumption page': when I try to open a socket with detectportal.firefox.com as suggested in the example, I get the ECONNABORTED. Is it beacuase we are only allowed to reach Pybytes with your sim cards? Thank you


  • Global Moderator

    From what I know, the urequest library was always an external library available from the micropython project here: https://github.com/micropython/micropython-lib/tree/master/urequests. The usage is similar to the pytrack / pysense libraries, where you place them in a folder named lib in your project and upload it all



  • @Gijs Thank you very much, I had already read about the current requirements but I'm definetly gonna try the power saving mode.
    But actually my main concern was how to send data after attaching and connecting to a NBIOT network.
    I also have another question: searching through old forum posts, I found out that some users used the urequests library to perform HTTP requests, but it seems that this library is no longer available in the documentation. Is there a way to perform a HTTP request? Thanks


  • Global Moderator

    Hi, sorry I must've missed your question

    Why are talking about 'at least a week of runtime'? Aren't we using IoT devices that are supposed to run for years with a single battery?

    The microcontroller is definitely a tradeoff between computing power and power consumption. Even when using the deepsleep functionality, it still consumes quite a bit of power compared to ultra low-power controllers (we are working on decreasing the deepsleep power consumption, but its quite a complicated task there). Next to that, using any kind of network communication (WiFi, LoRa etc) also uses a lot of power. For the LTE modem, it is possible to use the PSM mode: https://docs.pycom.io/tutorials/networks/lte/power/#power-saving-mode (Im not too familiar with the exact workings)

    In the documentation for the Fipy, we have listed some of the measured current requirements for several situations:https://docs.pycom.io/gitbook/assets/specsheets/Pycom_002_Specsheets_FiPy_v2.pdf, page 7. These might not directly coincide your application, but at least it gives some indication.

    Let me know if that answers your question
    Gijs



  • @Gijs Hi, any idea about this? Thank you for your support



  • @dnear1 Hi, thanks for your answer.
    I'm already trying to reduce unnecessary waste. What I'm doing right now is connecting to Pybytes, sending a message, disabling the LTE modem and then going into deepsleep, and later on the device wakes up to send another message. I'm not very interested in how long the battery will last, I'm more concerned whether I need a battery to satisfy the current peak need of the device. (I'm not an expert in this subject, it's the first time I'm working with such a device and the first time I have to choose devices and batteries).
    Since I'm not an expert on this topic, may I ask you something else? Why are talking about 'at least a week of runtime'? Aren't we using IoT devices that are supposed to run for years with a single battery?
    Thank you



  • @Flavio-Frattini You'd need to provide a lot more details to get anywhere with your battery needs. You'll need to track how much power is being used and spend a lot of effort to reduce unnecessary waste. Unless you just grab an unreasonably large battery to test with while you pare things down. Even then, you'll get wildly different suggestions that might not fit your needs based on different usage and requirements..

    One good solution is to buy a cheap USB power meter. They're $10-20 and plug between the power source and your device, and measure amps, watts, etc including a rough wattmeter to show power consumption over time. This will get you a lot closer. LTE itself can be quite power hungry, so you'll want to shut down the connection whenever you don't need it. Many people just go online long enough to send your packet then shut down the LTE connection for 90 seconds before going online to check again.. This gives you a reasonable power saving without making the response time too long. You'll also need to balance that against your data usage budget to keep your costs down.

    Also, you need to define the maximum allowable time between recharging your battery... because if it can't be plugged in daily, the battery needs to survive at least that long between "feedings". If you're planning to use Solar, you should give yourself at least a week of runtime, to account for bad weather, rainy days, etc... which can sometimes stretch for 3-4 days or more and prevent decent recharges. If downtime is critical, you may need more than a week. so your initial battery/charge controller/solar panel may not fit once it sees field conditions, tree cover, panel shading, bird poop, etc..



  • @Flavio-Frattini have a look at my posts here
    https://forum.pycom.io/topic/6704/lte-modem-firmware-and-lte-classes-can-get-into-bricked-state-to-easily/38

    I have been having LTE stability problems now for some time and after some recent changes the stability has vastly improve. I am yet to do more testing.

    Here are what I believe look like the key steps to improve LTE stability.
    Use Pycom firmware version 1.20.2r3
    Do a full/fresh upgrade of the LTE firmware. Do not use the delta/diff install method. I am using Nb-IoT firmware version NB1-41019.dup
    Use lte.deinit(reset=True) when de-initialising the modem.

    Now this might not be the miracle fix but it appears to be working for me at present.

    Good luck.

    Report back if it helps.

    Peter.



  • @Gijs Hi!
    Yes, it's different from the original issue.
    Yes, I'm pretty sure that the pybtes configuration has the correct default value you provided.
    I don't think it is a problem of LTE signal, because I'm testing the device in the same place, and what happens is that the device sends messages for some time and then all of a sudden it has problems with the connection.
    I'm interested in the manual LTE connection: I've tried the LTE example before, the attach and connect instructions work, but then? How do I send data? To which address can I send data?
    I have another question: I'm starting to think it is a battery problem. Could you advise me good batteries for a FiPy?
    Thank you very much.


  • Global Moderator

    Hi,
    The issue you are referencing to now appears to be different from the original issue?
    First, make sure the pybytes configuration still holds all the correct values.
    Next, it could be an issue of no available LTE signal, which indeed prevents a connection when trying to connect over LTE. You could instead try to connect over WiFi and see whether you can get that working, or manually create an LTE connection.
    Check the docs for examples: https://docs.pycom.io/tutorials/networks/

    Gijs



  • @Gijs Hi, I tried your code and I still have a problem.
    I put your instructions in my script. After every instruction I wrote something in a log file to be sure everything was successful. I have noticed that the first two lines (conf=read_config and pybytes=Pybytes(conf)) did not give me any problem, while the instruction pybytes.start was the one which gave me problem. The device was not able to connect to Pybytes and got stuck, it rebooted after 21 minutes, and it tried to connect again, unsuccessfully. Is it just me that I am facing this issue? Thank you.



  • @Gijs Thanks. It seems that now it's all working properly. I'll test for a long period to be sure everything is fine. Thank you very much.


  • Global Moderator

    Hi,
    I must say I am not having the reliablity issues you refer to, nor the type-error you mention. I will paste my output below:

    from _pybytes import Pybytes
    from _pybytes_config import PybytesConfig
    conf = PybytesConfig().read_config()
    pybytes = Pybytes(conf)
    
    pybytes.start()
    pybytes.send_signal(1, 'hello world')
    

    Screenshot 2020-12-10 at 09.58.31.png (I tried it 3 times just to be sure)
    Are you running the latest firmware version (1.20.2.r2)?
    Gijs



  • @Flavio-Frattini I know it says "can be any type", but I've never succeeded in sending strings.. Only Int, Float, etc..



  • @dnear1 I'm sending a string as reported in the coumentation, for example pybytes.send_signal(1, "hello world")



  • It should just be pybytes.send_signal(ID,Value)
    What exactly are you sending? Maybe the type Error is because of the data you're using?


Log in to reply
 

Pycom on Twitter