Skip to content

[Recuration] Receiving Real-Time Bus Information with Arduino (1)

creating a device that receives current bus information via WiFi communication and displays it

josephsr

Published November 02, 2023

Original author: 수박쨈 · South KoreaOriginal source (new tab)

[Recuration] Receiving Real-Time Bus Information with Arduino (1)

Components

Hardware components

x 1

wizfi250 is used

Software Apps and online services

Project description

Hello! This project I'm going to try involves creating a device that receives current bus information via WiFi communication and displays it.

Recently, I've been encountering WiFi more often, and I've been experimenting with various things using WiFi communication with Arduino. One thing I've noticed while using WiFi with Arduino is that there are many hidden pieces of information that have yet to be explored.

If you search for Arduino WiFi information in South Korea, you won't find a lot of resources. Even if you look around, you'll mostly find guides on "retrieving weather information," and it turns out that the world of APIs is deeper and more boundless than you might think.

The content I'll be covering in this post is about retrieving bus information with Arduino. I believe that if you're a South Korean citizen with a smartphone, you've probably installed at least one bus information app. I certainly have!

<Let's try it with Arduino>

It's an important app for daily commute, school commutes, or even dating (because punctuality matters, right?).

<Let's avoid doing this in the future!>

Now, for those of you who find it a waste of time to open the app at home, I want to create a one-button bus notifier for you. Mornings are a battle against time, after all.

I'll be dividing this into two posts, and for now, I'll explain how to use the API.

Required Parts List

  • OrangeBoard WiFi: 1 (Using the WizFi250 library)

Using the Gyeonggi Bus Information System To use the Gyeonggi Bus Information System, you need to first access their website. The address is as follows:

Gyeonggi Bus Information - http://www.gbis.go.kr/

When you click on "공유서비스" (Share Services), you can see information on how to develop the Gyeonggi Bus Information OpenAPI. The manual provides instructions on how to use it, and in the test section, you can see how data is displayed with arbitrary values.

However, when using the API, you always need a public key, and you also need a public key when using the Gyeonggi Bus Information System.

You can obtain this public key from the Public Data Portal.

To get the public key, you need to sign up. After signing up and logging in, search for the following API.

The "기반정보 관리" (Basic Information Management) API contains various data related to buses, such as routes and bus stops. You need this text file to know the station-specific ID and route-specific ID, which are required for bus information retrieval.

Click "활용신청" (Apply for Usage), and on the resulting page, you can obtain the public key.

The public key can be found in the top right corner under "마이페이지" (My Page) -> "오픈API" (Open API). Please note that the public key becomes valid only after 1 hour from application.

In addition to the above API, there is also a "버스도착정보 조회" (Bus Arrival Information Inquiry) API, which I initially applied for both, but it seems that after applying, you can use either one.

Once you have completed these steps, go back to the Gyeonggi Bus Information page and retrieve the data containing information about bus routes, bus stops, and so on.

After obtaining the text file, you'll see numbers and letters without spaces that you can't understand.

From here, you need to find the route ID and station ID through a search. The search method is as follows:

"Bus Number|Station Name"

For example, if you want to see information about the 17 bus at the Seohyeon Station, you can search for "17|Seohyeon Station." Next to it, you'll find a 9-digit number | 9-digit number. 123456789 represents the route ID for bus 17, and 987654321 represents the station ID for Seohyeon Station.

Once you've found these values, you can test them on the test page. Enter the public key, the route ID you found, and the station ID, then send the request. If done correctly, you should see the results displayed.

So far, you've completed over half of the process. Now, the only thing left is to use Arduino code to display this information on the serial monitor!

The detailed request information can be found in the manual.

Software Coding In the code, SSID, PASS, APIKEY, ROUTEID, and STATIONID are the parts that users need to input directly. They stand for WiFi name, WiFi password, public key, route ID, and station ID, respectively.

Once you input this data and upload it, you can open the serial monitor and see the information displayed in a single line.

Bus information APIs have a daily traffic limit as shown in the image above. Therefore, infinite requests are not possible, and making requests every few seconds may also result in traffic limitations. If you plan to use it for real, you need to allocate your time wisely.

In the code provided, requests are set to be made every 60 seconds, but you can change this as needed.

One of the downsides of the Arduino serial monitor is that it can't display Korean characters. So, it won't be able to show the information on the bus signboards, and even during the retrieval process, Korean characters might not display properly. This is something to consider when using the Arduino serial monitor.

In this post, we used the API to display data in the serial monitor. In the next post, we'll extract the desired information through parsing and display it on LEDs to create a device!

Title: Receiving Real-Time Bus Information with Arduino (2) Overview

Hello! Following the previous post, I'm writing another one right away.

In the previous post, I briefly explained how to use the Gyeonggi Bus Information System API to retrieve data on the OrangeBoard WiFi.

In this post, I'll parse the information we've received and display only the data I want on an LCD to complete the project.

Even though it may lack in appearance, it works well in terms of functionality, so you can use it in practice without any issues!

I'm actually planning to use this myself. (I used it for a day, and while it may not be very impressive, it was very useful for checking bus times.)

What I feel when I work is that the time for commuting to and from work is crucial. For many, the time for school commutes is equally important.

Preparing and searching for the bus I'm taking during rush hours, turning on my smartphone, and opening the app to find it is not a simple task.

Similarly, checking bus times on my smartphone during the evening commute might seem easy but can be cumbersome.

I've created this project for those for whom time is precious!

With just a simple double button press, you can roughly check the time and current location of the bus you're about to take (checking the next and the one after that).

(This project may not be very helpful for those who take the subway.)

Except for the WiFi board, all the modules can be easily obtained, so I think it can be easily built!

Documents

Comments

Similar projects you might like

Comments