Share My Creation [IoT] Lighthouse58

Discussion in 'B4J Share Your Creations' started by rwblinn, Sep 26, 2016.

  1. rwblinn

    rwblinn Well-Known Member Licensed User

    Lighthouse58 is an Internet of Things learning case based upon the LEGO® Lighthouse Point 31051.
    The goal was to enhance the features of the Lighthouse by integrating and controlling devices, e.g. top light, OLED display with a clock & actual weather (at the Lighthouse position gathered from Weather Underground), motion detector, outdoor lights, room lights, lights dimming, ambient light, LEDs.
    Its original build has been enhanced to accommodate the various devices. In addition a newly designed Control Unit holds the controllers. Controlled by a Raspberry Pi 2B with TinkerForge Master Bricks & Bricklets. Communication between the controller and the devices is done via MQTT (TinkerForge Brick MQTT Proxy).

    Lighthouse58 can be controlled via:
    • Browser Dashboard developed with Node-RED (included in Raspbian Jessie).
    • Windows Client Dashboard developed with B4J.
    • Multi Client Browser Dashboard running as a server, developed with B4J, on the Control Unit.
    Lookup the project description about the details [In progress including the B4J solutions].

    B4J Windows Client - Dashboard to control the various objects with its devices.
    [​IMG]
    B4J Windows Client - Lighthouse Configuration
    [​IMG]
    B4J Windows Client
    • Messaging based on MQTT using TinkerForge messages. No linkage with Node-RED, means the B4J solution runs without Node-RED.
    • Each object (lighthouse, pier ...) is defined as a class module, with a movable non-modal form. The title-bar contains icon buttons. Forms created with B4J Visual designer.
    • Switches are clickable image-views with tool-tips.
    • CSS styling applied in various ways (CSSUtils library, external CSS file, API javaObject) plus setting dedicated non B4J exposed properties using JavaFX API (look at the ColorPicker or Slider).
    • Remote Control (shutdown, get system information) of the Raspberry Pi using the jkSSH2 library (many thanks for providing). A great way to remote control the Raspberry Pi (will apply this to other solutions based on the Raspberry Pi).
    • Weather Information from Weather Underground displayed in gauges using the jGauges library (many thanks for providing).
    • MQTT Console listing selected (for the bricklets used) messages.
    • Settings defined as a map stored in external settings file.
    • Lighthouses Configuration form (TableView with textfields; RGB color builder with sliders; Lighthousetype holding information)
    B4J Windows Client - Download B4J Source here.
    The list of libraries used can be found in folder libraries.

    B4J Server - Multi Client Control running on the Control Unit (Raspberry Pi).
    Example shows a Windows Browser (Firefox) and Browser (Firefox) on Android Smartphone.
    [​IMG]

    B4J Server

    • Responsive design using w3.css framework (material design).
    • Multiple clients can control the dashboard. The state of the controls is updated in the browser for each connected client.
    • Request Weather Information from Weather Underground and display in a Dialog.
    • Trigger Control Unit system check (displayed as status message in a label on each connected client) and shutdown.
    • Dialogs for showing selected Lighthouse information and About box.
    • Messaging based on MQTT using TinkerForge messages. No linkage with Node-RED, means the B4J solution runs without Node-RED.
    • Settings defined as a map stored in external settings file - the same file is used by the Windows Client.
    • Server application runs on the Control Unit (Raspberry Pi). Access via Browser with URL http://ip-adress-raspberry-pi:51042
    • The library TFMQTT is used to control the TinkerForge Bricklets. Other libraries are jserver,jmqtt, json.
    TODO (planned at later stage): Manage Lighthouses (add, update, delete).

    B4J Server - Download B4J Source here.
    Additional information to be found in the documented source.

    Summary
    Compared to the current Node-RED Browser solution, B4J offers more options for developing additional functionality, client types (Windows, Server, Android), code can be reused across B4X solutions.

    Version Control
    20161009:UPD B4J Server solution completed.
    20161006:NEW Server solution first draft; UPD B4J Windows client completed.
    20161001:NEW Lighthouse configuration; UPD Lighthouse with Lighthouse selection & information.
    20160929:NEW MQTT console, object form icon buttons, B4J source available.
    20160926:NEW first version published.
     
    Last edited: Oct 9, 2016
  2. rwblinn

    rwblinn Well-Known Member Licensed User

    Update #1 20160929 (see post #1)
    Added MQTT Console, Icon Buttons to several object forms, B4J source made available for download.
     
    Last edited: Oct 6, 2016
    Cableguy and Erel like this.
  3. rwblinn

    rwblinn Well-Known Member Licensed User

    Update #2 20161001 (see post #1)
    Added Lighthouses Configuration form (TableView with textfields; RGB color builder with sliders; Lighthousetype holding information).
    Updated the Lighthouse form with Lighthouse selection, Lighthouse information.

    Getting close to completion :)
     
    Last edited: Oct 6, 2016
  4. rwblinn

    rwblinn Well-Known Member Licensed User

    Update #3 20161006 (see post #1)
    B4J Windows Client solution is completed.
    B4J Server solution: Development started. Source shared.
    The biggest challenge was to enable multi client control via Browser. This means when a client presses a button to turn f.e. the Pier Outdoor Light on, the button state is also updated on all clients connected. The same applies for showing values like Illuminance, Motion detected but also the state of the Lighthouse Toplight.
    The solution was
    • to build a shared module (LighthouseShared) for functions like MQTT, timers etc but also to keep the state of buttons and
    • to use the websocket module (Lighthouse) to handle the Browser updates (via various callsubdelayed).
    Now that this is working, can start to complete functions like request system status and shutdown.
    Have not made up my mind yet, how to display the Weather information in gauges - probably via Google Chart.

    In addition started to build in B4J a TinkerForge MQTT library - used for the B4J Server solution. Will be included in the next B4J Windows Client updated after completing the B4J Server solution.
     
    Erel likes this.
  5. rwblinn

    rwblinn Well-Known Member Licensed User

    Update #4 20161009 (see post #1)
    Completed the B4J Server solution running on the Raspberry Pi.
    The server solution has w3.css as the CSS framework with responsive design including dialogs (see index.html).
    Tested the multi client control via Browser on several devices (Windows 10, Raspberry Pi newest Raspian Jessie with Pixel, Smartphone running Android).
    Code developed for the B4J Windows Client has been reused for the B4J Server solution - pretty much copy and paste enabling rapid development.

    Whats next
    Received several requests for publishing this IoT showcase. Will keep posted on the outcome.
     
Loading...