0
Any tips on getting started with a Python project like this for the Niro EV charging port?

As an owner of a Kia Niro EV, I'm interested in using Python to build an app that can monitor the status of the charging port and charging level. Does anyone have experience using Python to tap into the Niro's charging APIs and data? I'm wondering what libraries would be best to use for connecting to the port and extracting real-time charging data. Any tips on getting started with a Python project like this for the Niro EV charging port?


Python 22-09-23, 7:26 a.m. sitecoreqedge
0
One option is to use an OBD-II adapter to connect directly to the charging port and vehicle CAN bus. For this, you'll need an adapter like the ELM327 OBD reader that can interface with Python code over Bluetooth or USB. There are Python libraries like PYOBD and OBDS that make it straightforward to connect to the OBD adapter and monitor real-time data from the vehicle. The specific data available will depend on what PID (parameter ID) codes are supported by the Niro EV. But commonly accessible information includes:
  • Battery state of charge
  • Charging voltage/amperage
  • Estimated time remaining during charging session
  • Charging status (charging, completed, error codes)
By polling the appropriate PIDs from the OBD port, you can build up a detailed view of the charging status and progress. The PYOBD library also allows you to define callback functions to trigger custom actions when certain values change. For example, you could send a notification if the charging encounters an unexpected error, or when the charging session completes. Connecting directly to the OBD port gives you a wealth of raw data for monitoring. Another approach is to tap into the telematics APIs provided by Kia/Hyundai for their connected UVO services. This may require more involved authentication, but gives you access to charging data through the cloud. Kia has a developer portal that documents the available APIs - you can use the Python Requests library to call these REST APIs with the proper headers and authorization tokens. The endpoints related to EV charging status include:
  • Get the battery charge level percentage
  • Get estimated EV driving range/distance
  • Get status of charging (in progress, interrupted, complete)
So by polling the UVO cloud service APIs on a schedule, you can extract similar charging details. The advantage here is avoiding any need for direct OBD adapter hardware. The downside is relying on an outside service rather than raw OBD data direct from the vehicle CAN bus. In either case - direct OBD or UVO API - you'll want to structure your Python script or Jupyter notebook to:
  1. Initialize connection/credentials to access the data source
  2. Define functions for extracting the desired charging parameters
  3. Set up a loop to poll the latest data at regular intervals
  4. Process and visualize the data as needed, like graphing the charge level over time
  5. Trigger any alerts or notifications based on value thresholds
  6. Safely close connections and store data when finished
For visualizing the charging progress, you can use Python charting libraries like Matplotlib or Plotly Express. Real-time data can be displayed in live-updating plots to monitor the charge curve. You could also push data to tools like Grafana or Power BI to build custom dashboards. The kia niro ev charging port uses the SAE J1772 standard for Level 1 and 2 AC charging. So with the proper adapter cables, you should be able to apply a similar Python monitoring approach to other EVs beyond just the Niro EV.
22-09-23, 7:31 a.m. sitecoreqedge


Log-in to answer to this question.