How can I set the RTC in HelTec LoRa WiFi ESP32 get the time using Python API?

how can I set the RTC in HelTec ESP32 LoRa WiFi (V2) get the time using Python API ?

yes. You can look at main.py in the meshtastic-python project for an example of this. Search for “settime”

I used the following command in the terminal:
meshtastic --settime
I got this output:
Screenshot from 2021-04-01 11-28-43

My question is from where I can access the value and can use it in my python desktop application?

The following value should be quite close:

interface.nodesByNum[interface.my_node_num].last_heard

should be the time (in seconds since 1970) of the last time the local node was seen on the net (which should be almost now, because it will get updated when it talks to the pc)

(this assumes 1.2 or later)

(the field names might be slightly different - I typed this from memory)

1 Like

is interface.nodesByNum[interface.my_node_num].last_heard in main.py or init.py?

nodesByNum is a property on the instance returned when you create a SerialInterface()

after updating the firmware to 1.2.20 and meshtastic library in my laptop my desktop application for peer to peer communication is showing error as follows.


Please help me with the fix, previously it was running fine. Now whatever the entry is given is not coming on the MeshtasticGUI screen. If you want I shall share my code.

Hmm. I think you’ll want to put a breakpoint so you can debug what attribute it is not finding. Can you post a link to the code?

The following is the link of the code:

https://github.com/Arijitdutta19910601/Meshtastic-Interface-GUI

Please download pythongui1.py and myFile.txt. The program is supposed to read text line by line from the myFile.txt file by clicking on the RAND button in the GUI application. It is working fine with 1.1.32

@geeksville Could you please tell me, which API class or function is responsible for receiving the acknowledgement(ACK) or (NAK)? Is it receiving the acknowledgement time as well?

Hi! I think I made a fix for your code and included some tips on how to debug things like this in the future:

The python API mostly ignores acks/naks, though you can handle them yourself like any other packet. You can see their structure by running “meshtastic --debug”.

For operations that are marked as wantResponse, we will forward the response or any NAKs that we received for that response to a provided response handler. For an example of this see meshtastic.node._requestSettings.

Does that help?

1 Like

Thanks a lot Kevin, for your time and effort. I shall run the code on new devices and shall let you know.

1 Like

Hi @geeksville,
I am continuing my research with 1.1.32 version only. After setting time the time to zero to both the devices using meshtastic --settime I could successfully get and observe the rx_time field value, which is coming in seconds. It will be a great help if can guide me how can I get the same value in milliseconds, as my research results require precision.

@geeksville @mc-hamster please reply if you know anything regarding this.

Hi @geeksville,
I am continuing my research with 1.1.32 version only. After setting time the time to zero to both the devices using meshtastic --settime I could successfully get and observe the rx_time field value, which is coming in seconds . It will be a great help if can guide me how can I get the same value in milliseconds , as my research results require precision.

Sorry. The times meshtastic shares are in seconds because I wanted to keep them small over the air. For most use cases this is fine because even sending a message often needs a few seconds per hop.

1 Like

@geeksville Thanks, I required this information.

Sorry. The times meshtastic shares are in seconds because I wanted to keep them small over the air. For most use cases this is fine because even sending a message often needs a few seconds per hop.

Hi @geeksville, using 1.1.32 firmware at times the device is getting a reboot while transmitting messages at a few seconds time interval. Please tell me which version has removed the problem?

Can anybody help me with the following from https://meshtastic.org/docs/software/other/power as my device taking a reboot while sending continuous messages with a certain interval:

full on (ON) - Everything is on, can eventually timeout and lower to a lower power state onEntry: setBluetoothOn(true), screen.setOn(true) onExit: screen->setOn(false)

P.S: I am using 1.1.32 firmware as well as API and I need the command line tool to stay the device on. HelTec 32 device connected with laptop via USB cable