LoraWAN HAT for RPi with SX1302 SPI

I have a problem with setting time on the gateway. When I receive a message, co called an uplink, I get always a wrong timestamp from 1999:

JSON up: {"rxpk":[{"jver":1,"tmst":1654468754,"time":"1999-11-30T00:04:29.272429Z","tmms":1395595786272,"chan":2,"rfch":1,"freq":868.500000,"mid": 8,"stat":1,"modu":"LORA","datr":"SF9BW125","codr":"4/5","rssis":-36,"lsnr":9.5,"foff":2382,"rssi":-35,"size":15,"data":"gOFqfgCAEwAK4KFS9dyy"}]}

System, a classical Rpi 4, has time and timezone correctly set. On downlinks, time is correct.

«1

Comments

  • Hi ektanoor, you start by displaying the Raspberry Pi system time by typing date at the Raspberry Pi command line. Then you run the HAT program to print out the program status. Finally, provide a full log. The complete log may help me to solve the problem for you.

  • 1 - root@raspberrypi:~# date
    Thu Mar 28 01:04:16 PM MSK 2024
    The machine is syncd by NTPd. The original raspbian setup shifts time quite a few seconds per day.
    2 - "Then you run the HAT program to print out the program status"
    I didn't get this one. I haven't seen a "HAT program" on the wiki. Could you specify?
    3 - The full log of lora_pkt_fwd, right? In the attachment.

  • From your logs, it looks like you have GPS turned on. Did you connect the GPS antenna? Your logs are reporting an error indicating that there is no valid GPS data available.

    Please make sure the GPS antenna is connected. And place the GPS antenna outside in an open and unobstructed environment. After this see if the incorrect timestamp still appears. If it still does please send the log again here for my reference.

  • It is turned on, it is over a window and it was put to south. Several other GPS devices have had a bit of trouble locating satellites but in 80% of cases it is a problem that goes off in some half an hour. In the case of the shield, a day passed without success. I have some experience with SDR and I don't see serious trouble with the antenna. What could be a problem is that this chip seems to have a GPS+Beidou setting as default. We don't have Beidou here, at all. Frankly, GPS also looks degraded lately, due to known world troubles. How to turn GLONASS? The chip allows it but something seems to block commands towards /dev/ttyS0. I tried in several way but without success. Yes, I turned off lora_pkt_fwd to try this, yet commands don't seem to reach the chip. It could be a problem on terminal software.

  • SunSun
    edited April 1

    Hi ektanoor, please type cat /dev/ttyS0 in the Raspberry Pi's terminal to see the GPS output. Please send it here to reference through screenshot.

  • Here it goes...

  • Managed to send commands to GPS. It was a terminal problem indeed. Didn't want to process cr+lf normally.
    I tried GPS+GLONASS and all GNSS on. Even Beidou appears from time to time. Coordinates are lost sometimes, yet timings/date keep coming correctly. In any case, in the lora_pkt_fwd, I keep seeing uploads at 1999.

  • It may a bit unsolicited but here is a screenshot from chirpstack LoraWAN server. It show that, on uplinks, date and time almost stay that same. On downlinks it always show the correct timing.

  • Try modifying the code in line 1728 of the /sx1302_hal/packet_forwarder/src/lora_pkt_fwd.c file. Change to strftime(stat_timestamp, sizeof stat_timestamp, "%F %T %Z", localtime(&t)); and change the code on line 2042 to strftime(stat_timestamp, sizeof stat_timestamp, " %F %T %Z", localtime(&t));

    Modify this and recompile the sx1302_hal source code. See if it still causes the same problem.

    Can I ask you a few questions? You can answer selectively.

    Are you in Moscow? Where did you download the programme you compiled from? Because the program provided by elecrow doesn't print the time of the uplink. Can you provide the code you are compiling now?

  • I am in Moscow time zone, +3GMT as it is known. But usually I set things to UTC as to avoid issues from time zone to time zone.
    I downloaded from here:
    https://github.com/Elecrow-RD/LR1302_loraWAN/tree/master
    I came to this link through your Wiki (https://wiki.elecrow.com/index.php?title=LR1302_LoRaWAN_Gateway_Module). Yet, the command shown there (git clone https://github.com/Elecrow-RD/LR1302_loraWAN/LR1302_HAL) gives a 404 on github, so I just browsed a little and came to link shown above.

Sign In or Register to comment.