Simple display with RaspberryPi Zero W

Hi,

I wanted to have a permanent display with the most essential data, wind and temperature, for me as a sailor to decide to go out on the lake.

Based on a RaspberryPi Zero W, a 2004a LCD with 20x4 characters, a 3d printed case and some code I build this display.
Cost: Raspberry Pi Zero W 12,- Euro, I2C 20x4 LCD 6,- Euro, 3d printing filament 1,70 Euro, screws and micro USB cable from the junk drawer. In total about 20 Euros.

 #!/usr/bin/python
# -*- coding: utf-8 -*-

import socket
import lcddriver
from time import *


def wind_bft(ms):
  _bft_threshold = (0.3, 1.6, 3.4, 5.5, 8.0, 10.8, 13.9, 17.2, 20.8, 24.5, 28.5, 32.7)

  if ms is None:
    return None
  for bft in range(len(_bft_threshold)):
    if ms < _bft_threshold[bft]:
      return bft
  return len(_bft_threshold)


def cardir(compassdir):
  _cardir_threshold = ("N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N")
  if compassdir is None:
    return None
  compassdir = _cardir_threshold [int((compassdir + 11.25)/22.5)]
  return compassdir


UDP_IP = ""
UDP_PORT = 50222

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))

lcd = lcddriver.lcd()
lcd.lcd_clear()

lcd.lcd_display_string("KB1 weather station", 1)
lcd.lcd_display_string("data aquisition in", 2)
lcd.lcd_display_string("progress.", 3)

while True:
    datab, addr = sock.recvfrom(1024) 
    data = str(datab)
    position = data.find ("obs_st")
    if position > 0:
      lcd.lcd_clear()
      data = data.replace("b'{","")
      data = data.replace('"serial_number":"','')
      data = data.replace('"type":"','')
      data = data.replace('"hub_sn":"','')
      data = data.replace('"obs":[[','')
      data = data.replace(']],"firmware_revision":',',')
      data = data.replace('"firmware_revision":','')
      data = data.replace('"','')
      data = data.replace("}'","")
      splitlst = data.split(",")
      data = ""

      
      Line1Str = "Avg. " + str(round(float(splitlst[5]),1)) + " m/s " + str(wind_bft(float(splitlst[5]))) + " bft"
      Line2Str = "Gust " + str(round(float(splitlst[6]),1)) + " m/s " + str(wind_bft(float(splitlst[6]))) + " bft" 
      Line3Str = "Dir. " + cardir(float(splitlst[7])) + " (" + str(splitlst[7]) + "\u00DF)"
      Line4Str = "Temp " + str(round(float(splitlst[10]),1)) + " \u00DFC"

      lcd.lcd_display_string(Line1Str, 1)
      lcd.lcd_display_string(Line2Str, 2)
      lcd.lcd_display_string(Line3Str, 3)
      lcd.lcd_display_string(Line4Str, 4)
14 Likes

Looks very nice. I like to see that kind of projects :slight_smile: :+1:

Very nice! Hats off!

Congratulations and welcome to the forum. I use the 7 inch display and some day I’ll move to a bigger screen. It’s fun building these things.

Really nice :slight_smile: - I like the bft after the wind speed, nice and simple and a nice screen…

Andy

Thank you all for the positive feedback :smiley: