Solving Incorrect Time Display on Meshtastic Devices

技术

If you’re using a Meshtastic device and notice that the time is always incorrect, particularly where the minutes and seconds are correct, but the hour value is wrong, this is likely a timezone issue. This problem can be frustrating, especially if accurate time synchronization is critical for your application.

After an investigation, it was determined that this issue stems from how Meshtastic handles timezone settings, and it specifically requires a POSIX timezone format.

The good news is that you can fix this by modifying the timezone settings appropriately. Below is a detailed guide on how to troubleshoot and solve this issue.

Investigation Summary

Upon noticing the incorrect time on your Meshtastic device, you might initially assume that it’s just a simple time zone misconfiguration. The typical steps you might try include setting or resetting the timezone. However, if you do this and the problem persists—i.e., the minutes and seconds remain accurate, but the hour is still wrong—then it’s likely that the timezone string is not being properly interpreted by the Meshtastic firmware.

After further research, you will discover that Meshtastic requires the timezone to be in a POSIX format. This format differs from the typical timezone names like “Asia/Hong_Kong” or “Asia/Shanghai” that you might be used to seeing.

Steps to Resolve the Problem

Here is a step-by-step approach you can use to correct the time on your Meshtastic device:

  1. Identify Your Timezone

    • Meshtastic uses the POSIX timezone format to set the correct local time. To resolve the time issue, the first thing you need to do is identify the correct POSIX timezone format for your location.
    • Fortunately, there is a helpful resource that contains the required POSIX timezone strings: POSIX Timezone Database CSV File.
    • Open the link above and search for your local timezone. For example, if you are in Hong Kong, you will find the corresponding timezone is HKT-8. If you are in Shanghai, you will use CST-8.
  2. Access Your Meshtastic Device Configuration

    • To modify the timezone setting, you need to connect to your Meshtastic device. You can use the Meshtastic app (on mobile or desktop) or Meshtastic CLI if you prefer command-line access.
    • If you are using the Meshtastic CLI, you can connect to the device via USB and execute commands. Make sure you have the CLI installed, and connect to your device by using the appropriate serial port.
  3. Set the Correct Timezone

    • Most users will use the Meshtastic app to set the timezone. In the app, you can find the timezone settings under Settings -> Device -> Time Zone.
    • Alternatively, if you are using the Meshtastic CLI, use the following command to set the timezone: Use the following command to set the timezone on your device. The command is slightly different based on the interface you use:
      • Using Meshtastic CLI: Run the command below to update the timezone:
        meshtastic --set time.zone "HKT-8"
        This command sets the device’s timezone to Hong Kong Time (HKT) with an offset of -8 hours.
      • Alternatively, if you are in Shanghai, you can set the timezone to CST by running:
        meshtastic --set time.zone "CST-8"
        Note that the POSIX format may look different from typical time zone names, and it’s important to use the correct format.
  4. Reboot the Device

    • After changing the timezone setting in the app, the module itself does not reboot automatically. You will need to manually reboot the device to apply the new timezone setting.
  5. Verify the Change

    • After setting the new timezone and rebooting the device, verify the change by checking the display on your Meshtastic device. You can either look at the OLED screen directly or use the CLI to query the device configuration.
    • For verification via CLI, run:
      meshtastic --get time
      This command will return the current device time, and you should now see the correct local hour displayed along with correct minutes and seconds.
    • Alternatively, you can use the USER button (also known as the BOOT button) on the device to navigate to the last page of the screens. This screen displays the current time, battery voltage level, Channel Utilization, and GPS info.

Example

For a concrete example, consider the time discrepancy you observed in the images you shared:

  • The minutes and seconds were correct, but the hour was consistently off. Initially, you tried to set the timezone using general formats like Asia/Hong_Kong, but the incorrect hour persisted.
  • After consulting the POSIX timezone database, you updated the timezone to HKT-8 for Hong Kong or CST-8 for Shanghai. These timezone strings worked correctly, and the displayed time was then synchronized properly.

Additional Notes

  • Why POSIX Format?: The POSIX format is widely used in embedded systems because it allows for precise control over timezone offsets, daylight savings, and other factors. Meshtastic’s firmware expects the timezone to be given in this specific format, which is why other typical formats may not work correctly.
  • Common Pitfalls: Ensure you are entering the timezone string correctly, as even minor deviations can lead to persistent errors. For instance, using HKT-8 instead of Asia/Hong_Kong is crucial.
  • Testing: After setting the timezone, consider testing your configuration over a period of time, especially if you need consistent synchronization with other devices.

Conclusion

The incorrect time display issue on Meshtastic devices is a common hurdle and is primarily due to incorrect timezone configuration. By setting the timezone in the proper POSIX format, as detailed above, you can ensure that the hour, minutes, and seconds display accurately.

Referencing the POSIX Timezone CSV File is an important step in finding the correct timezone format for your specific region.

By following these steps, including manually rebooting the device after setting the timezone, you should be able to correct the time display issue and have your Meshtastic device displaying the correct local time.