-
Notifications
You must be signed in to change notification settings - Fork 1
HomeAPI Setup
You can think what we are about to configure in this tutorial is the server for giving the ESP32 the image data it needs to display it on the screen.
ADVANCED: Change Public Transport Api
-
Download the zip file called
HomeScreen_Build_vX.X.X.zipto your computer. Pick the newest version, you might have to expandAssetstab. -
Extract the zip file to a folder, e.g.,
C:\HomeApior your Desktop.
When you have extracted the zip file there should be a appsettings.json file inside the folder. Open it and edit the lines I have marked.
Public API's that require keys:
- https://www.weatherapi.com/ (Weather)
- https://www.trafiklab.se/api/our-apis/resrobot-v21/ (ResRobot)
{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://*:5000"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ApiConfiguration": {
"EspConfiguration": {
"InformationBoardImageUrl": "http://192.168.101.178:5000/home/default.jpg", <--- Server Address (always use ip! This should always be the ip of the computer running this application)!
"UpdateIntervalMinutes": 2,
"BlackTextThreshold": 190,
"EnableDithering": true,
"DitheringStrength": 8,
"EnhanceContrast": true,
"ContrastStrength": 10,
"IsHighContrastMode": true
},
"Keys": {
"Weather": "NOT COMMITED", <---- WeatherApi key
"ResRobot": "NOT COMMITED" <---- Swedish transit api key
},
"BaseUrls": {
"Nominatim": "https://nominatim.openstreetmap.org",
"Aurora": "http://api.auroras.live",
"Weather": "https://api.weatherapi.com/v1",
"ResRobot": "https://api.resrobot.se"
},
"DefaultCity": "Stockholm, stockholms lan",
"DefaultStation": "Stockholm C"
},
"AllowedHosts": "*"
}You must install the .NET 9 Runtime to run this app.
- Choose ".NET Runtime" (not SDK).
- For Windows, select "x64" or "Arm64" depending on your machine.
- For Mac/Linux, pick the right option for your OS.
- Run the installer and follow the instructions.
Open your Command Prompt (Windows) or Terminal (Mac/Linux) and run:
dotnet --version- If it prints something like
9.0.x, you are ready!
-
Navigate to the extracted folder.
- Example (Windows):
cd C:\HomeApi\dotnet
- Example (Mac/Linux):
cd ~/Downloads/HomeApi/dotnet
- Example (Windows):
-
Run the API:
dotnet HomeApi.dll
-
You should see output like:
Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.
- Open your web browser and go to:
http://localhost:5000/scalar - You should see an API documentation page.
- Press
Ctrl+Cin the terminal window where the app is running.
Q: I get 'dotnet is not recognized'?
The .NET runtime is not installed or not added to your PATH. Re-install it and reboot your computer.
Q: How do I change the port?
Open appsettings.json and look for URLs or configuration relating to ports. Edit as needed, or run with:
dotnet HomeApi.dll --urls "http://localhost:8080"Q: Do I need Visual Studio?
No! You only need the .NET 9 Runtime.
Q: How do I call the API?
You can use a browser for GET endpoints or tools like Postman or curl for others.