GithubHelp home page GithubHelp logo

aschuma / esp32_ssd1306_metaefa Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 3.0 384 KB

This MicroPython code, executed on an ESP32 OLED SSD1306 board, displays departure tables by utilizing the VVS Rest API (META EFA)

License: MIT License

Python 100.00%
micropython python esp32 ssd1306 timetable vvs fahrplan python3 public-transport

esp32_ssd1306_metaefa's Introduction

                                                                                
                              _|_|_|      _|_|                  _|_|            
  _|_|      _|_|_|  _|_|_|          _|  _|    _|    _|_|      _|        _|_|_|  
_|_|_|_|  _|_|      _|    _|    _|_|        _|    _|_|_|_|  _|_|_|_|  _|    _|  
_|            _|_|  _|    _|        _|    _|      _|          _|      _|    _|  
  _|_|_|  _|_|_|    _|_|_|    _|_|_|    _|_|_|_|    _|_|_|    _|        _|_|_|  
                    _|                                                          
                    _|   

The aim of this project is to display the departure data of one or more VVS stations (Haltestellenmonitor) on an ESP32 microcontroller equipped with an Oled SSD1306 display. VVS is the Stuttgart public transport system. VVS provides the current timetable of relevant stations by a public available REST endpoint. Micropython is the programming language of choice for this project.

Here is what you get when you deploy the application on your ESP32 board:

Demo

The top line contains the current time. The other lines hold the tram/bus line number, the departure time, the delay and the short name of the station (RH, SMi). (The relevant tram/bus lines and stations are configurable within a configuration resource)

Please note that the hosted version of the public REST endpoint (metaEFA) used by this project is not available anymore. Information on hosting a MetaEFA server yourself can be found at https://github.com/opendata-stuttgart/metaEFA.

Links:

Onboarding

This is just a brief description of what steps have to be performed to enable the development of this application. Please consult Google to get in-depth details.

Prepare development infrastructure

Micropython - prepare the ESP32 board

  • Download the latest ESP32 micropython image from https://micropython.org/download
  • Prepare the board
    esptool.py --port /dev/cu.SLAB_USBtoUART flash_id
    esptool.py --port /dev/cu.SLAB_USBtoUART erase_flash
    esptool.py --port /dev/cu.SLAB_USBtoUART write_flash -z 0x1000 <path-to-downloaded-image>
    
    

Micropython - check board access

  • The subsequent command is for MacOS only. Similar tools are available for Linux and Windows.
    screen /dev/cu.SLAB_USBtoUART 115200
    
    After that, you will be connected to the micropython shell running on the board. You may leave the shell by typing Ctrl-A, K and y.
  • File explorer
    rshell -p /dev/cu.SLAB_USBtoUART
    
    The files on the board should be available locally at /pyboard on your dev machine. You may copy files to the board by using the cp command. More details are available here: https://github.com/dhylands/rshell

Please be aware that you can not use multiple shells simultaneously to the access the board.

Deployment

  • Copy src/config.py.template to src/config.py and adjust at least the wifi settings.
  • Copy recursively all files of src to the root directory of the board using the rshell tool or the ampy tool.
  • The board should reboot itself. If not unplug the USB cord and plug it back again.
  • In case of problems to connect to the board via screen /dev/cu.SLAB_USBtoUART 115200   press CTRL-C and CTRL-D to trigger a reboot. Then you should see some log messages.

Finally

Be aware that my primary coding language is not python. So please forgive me my bad coding style. I'm still learning python and ESP32 development.

Please feel free to issue a bug report or submit a PR. Any helping hand is welcome.

esp32_ssd1306_metaefa's People

Contributors

aschuma avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

esp32_ssd1306_metaefa's Issues

ssd1306 - observed once: ENODEV 19 /* No such device */

Observed once: (self healing, recovered itself)
Problems occurred while refreshing UI

OSError: [Errno 19] ENODEV
Traceback (most recent call last):
  File "timer.py", line 15, in <lambda>
  File "main.py", line 85, in <lambda>
  File "main.py", line 42, in paint
  File "ssd1306.py", line 76, in invert
  File "ssd1306.py", line 104, in write_cmd
OSError: [Errno 19] ENODEV
Traceback (most recent call last):
  File "timer.py", line 15, in <lambda>
  File "main.py", line 85, in <lambda>
  File "main.py", line 42, in paint
  File "ssd1306.py", line 76, in invert
  File "ssd1306.py", line 104, in write_cmd
OSError: [Errno 19] ENODEV
...

#define ENODEV 19 /* No such device */

In addition the active rest service indicator is shown twice (now also on top of the screen)

service - departure ordering

The order returned be efa rest is the planed departure time...

  • 21:56 S1 03 SMitte
  • 21:54 U2 00 SMitte
  • 22:03 S2 00 SMitte
  • 22:08 S1 00 SMitte
  • 22:09 U2 00 SMitte
  • 22:14 S3 01 SMitte
    ... this must be adusted by the delay time (3rd column)

ssd1306 - add driver libraries

  • Add ssd1306 libraries.
  • Check whether a driver exists supporting more fonts
  • Provide boot code to initialise the display

code: timer.js - IndexError: list index out of range

since esp32-20190125-v1.10

Traceback (most recent call last):
 File "timer.py", line 11, in 
 File "main.py", line 88, in 
 File "main.py", line 71, in paint
IndexError: list index out of range
Traceback (most recent call last):

efa - use the stream of the underlying http connection and pass the bytes directly to the json parser

data = io.StringIO(request.text)

Background:

My esp32 device was running out of memory when creating a json object directly from response body. Unfortunately there is not yet an api parameter to limit the response of the efa api. See opendata-stuttgart/metaEFA#15

The json stream parser stuff itself is a workaround for that. I really would like to remove that json stream parsing to reduce the overall complexity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.