Skip to content

Instantly share code, notes, and snippets.

@hsiboy
Created July 5, 2023 10:07
Show Gist options
  • Save hsiboy/cab1bce8be8431e1403f25199bb482a0 to your computer and use it in GitHub Desktop.
Save hsiboy/cab1bce8be8431e1403f25199bb482a0 to your computer and use it in GitHub Desktop.
Scrapes the json from dump1090 and pushes the info to an LCD display connected via RS232
import json
import serial
# Configure the serial port
ser = serial.Serial('/dev/ttyUSB0', 9600) # Replace '/dev/ttyUSB0' with the correct serial port and baud rate
# Parse the JSON data from Dump1090
def parse_dump1090_data(json_data):
aircraft_data = json.loads(json_data)
for aircraft in aircraft_data:
icao = aircraft['hex']
altitude = aircraft['altitude']
speed = aircraft['speed']
print(f"ICAO: {icao}, Altitude: {altitude}, Speed: {speed}")
# Send the information to the LCD display via RS232
lcd_message = f"ICAO: {icao}\nAltitude: {altitude}\nSpeed: {speed}\n"
ser.write(lcd_message.encode()) # Send the message as bytes
# Read and process the JSON data from Dump1090
def read_dump1090_data():
url = 'http://localhost:8080/data.json' # Replace with the correct URL for your Dump1090 instance
try:
response = requests.get(url)
if response.status_code == 200:
parse_dump1090_data(response.text)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
# Main program loop
while True:
read_dump1090_data()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment