Introduction: ESP8266 Weather & KVG Infoscreen
This is a simple Infoscreen for Weatherforecast via darksky.net and bus stop live screens for busses in Kiel via "KVG Echtzeitabfahrten".
The infoscreen is based on a NodeMCU (ESP8266) and a ILI9341 LCD Display.
Step 1: Parts and Tools Required
- NodeMCU Board, contains ESP8266 Wifi Module (AliExpress, Ebay, Amazon)
- 2,8" touch LCD 320x240px (AliExpress, Ebay, Amazon)
- Any cheap power bank, ideally with a power switch (AliExpress, Ebay, ...)
- Some cm of wire
- Some material for the case, e.g. wood
Soldering Iron & solder
- If available a CNC machine for the case
Step 2: Connection
The connection between NodeMCU and display is shown above. You only need a few short lines for the connection:
Display <-> NodeMCU
- VCC <-> 3.3V
- GND <-> GND
- CS <-> D8
- RESET <-> 3.3V
- DC <-> D3
- SDI <-> D7
- SCK <-> D5
- LED <-> 3.3V
- SDO <-> D6
- T_CLK <-> D5
- T_CS <-> D2
- T_DIN <-> D7
- T_DO <-> D6
- T_IRQ <-> D1
Step 3: Preparation of the Arduino IDE
I used the Arduino IDE (v1.8.2) for programming.
Install ESP8266 Arduino support
After downloading the IDE you have to tell the software to support ESP8266 modules:
- Go into File > Preferences.
- Insert following line into "Additional Board Manager URLs" field:
- Go to Tools > Board > Boards Manager…
- Search for ESP8266 and install “esp8266by ESP8266 Community".
- Go to Tools > Board and select your ESP8266 board. If you have bought one of the boards I mentioned above you should select NodeMCU 1.0 (ESP-12E Module).
- After driver installation select the right port for the NodeMCU at Tools > Port.
Install CH340 drivers
If not present, you should now install the CH340 drivers for your OS. You can find the drivers via google or e.g. here.
Install needed Arduino libraries
Go to Sketch > Include Library > Manage Libraries... and install the following libraries:
- ArduinoJson by Benoit Blanchen
- Json Streaming Parser by Daniel Eichhorn
We also need to install additional libraries, which can't be found in the library manager. There are two ways of installing. The easiest is to copy the libraries included in my GitHub project into your Arduino "library" folder and restart the Arduino IDE. The other is to download the needed libraries from GitHub and install it:
Download the project from GitHub
Step 4: Customization of the Source Code
If you have installed the libraries manually, you have first to edit the file "User_Setup.h" of the TFT_eSPI library. Otherwise, you could skip the next two lines.
- Line 17: activate ILI9341_DRIVER
- Line 83-86: define Pins for Display like it is shown in the Connection part
Now open the ESP_InfoDisplay.ino file with the Arduino IDE and customize your software:
In line 108 set the SSID and Password
You need the KVG bus stop number for your preferred bus stop. This can be done by opening the following website, where you put a part of your bus stop name after the "query=", e.g. "query=Dreiecks"
Now you should see a list with your bus stop name. Open the source code of the site and you see something like "li stop="23">Dreiecksplatz" where 23 is your bus stop number. You can now put this number in line 172/175/178 of the main file or look into the file KVGliveAPI.h and append your bus stop nr to the literal list (like "static const int Dreiecksplatz = 23;") and use this name (KVGliveAPI::KVGstop::Dreiecksplatz) in line 172/175/178 of the main file.
If you want to have more/fewer bus stops you only have to edit the switch statement starting from line 170 and change the maximum mode number in line 138.
Weather API access and location
To access the darksky.net API you need a secret key which is 100% free. You only have to register at darksky.net for developers. After logging in you see a field with the title "Your secret key". This 32 character hex key you have to copy into line 61 of the file DarkSkyAPI.h between the slashes.
If you want to change the weather location you only have to edit line 16 of the file DarkSkyAPI.cpp and line 25 for the name of the location.
Now you can compile and upload the program to the ESP8266 (and it should work! :) )
Step 5: Building the Case
19an.gro99 made it!
We have a be nice policy.
Please be positive and constructive.