Skip to content

adriencater/ambient-messaging

Repository files navigation

ambient-messaging

POC Demo

Components

Architecture

Installation on RPi

curl https://get.pimoroni.com/inky | bash
git clone https://github.com/adriencater/ambient-messaging.git
cd ambient-messaging
pip3 install -r requirements.txt

⚠ This POC has absolutely no security feature.

Quickstart

1. Setup the client on RPi + Inkyphat, run:

AM_CLIENT_NAME=myself AM_MQTT_HOST=broker.hivemq.com python3 -m ambientmessage.client
  • Replace myself with your actual nickname

2. Setup a server on your laptop, run:

AM_MQTT_HOST=broker.hivemq.com python3 -m ambientmessage.server

3. Send a message:

  • Open a browser to: http://localhost:9999/

  • Or use this bash script (no need of a server) and send a message to myself (replace with your actual nickname)

    AM_MQTT_HOST=broker.hivemq.com python3 sandbox/mqtt-send.py myself "Hello World"

4. Watch your client for a new message !

Next, you can setup your own federative server on teh internets !

Usage (Real world)

Server

  • Setup your own MQTT Broker, eg. mosquitto: https://mosquitto.org, or use an existing MQTT Broker

  • Run the AM Server (HTTP & REST Service):

    AM_MQTT_HOST=<mqtt-broker-host> AM_MQTT_USER=<mqtt-broker-user> AM_MQTT_PASS=<mqtt-broker-pass> python3 -m ambientmessage.server

Client (RPi + Inkyphat)

  • Run the AM Client (MQTT Client & Inkyphat controller):
    AM_CLIENT_NAME=<recipient-id> AM_MQTT_HOST=<mqtt-broker-host>  AM_MQTT_USER=<mqtt-broker-user> AM_MQTT_PASS=<mqtt-broker-pass> python3 -m ambientmessage.client
    The recipient-id is the identifier of the recipient (eg. damien).

Application

  • Send a message via the Web App: http://server-host:9999/

  • Send a message directly via MQTT:

    AM_MQTT_HOST=<mqtt-broker-host> AM_MQTT_USER=<mqtt-broker-user> AM_MQTT_PASS=<mqtt-broker-pass> python3 sanbox/mqtt-send.py <recipient-id> "Hello World"

    The recipient-id is the identifier of the recipient (eg. damien).

  • 📨 Watch for messages on the Inkyphat display !

Core

  • Use the core component in the python interpreter:
    $ python3
    >>> from ambientmessage import core
    >>> core.display_text('Hello\nWorld')

TODO

  • Use a MCU as an alternative to RPi Zero

  • Use MQTT Client directly on the browser and remove the need of an AM Server !
    https://github.com/mqttjs/MQTT.js#browser (websocket only)

  • Run client as a service of systemd

    sudo pip install --system -r requirements.txt
    sudo systemctl link $PWD/[email protected]
    sudo systemctl enable ambient-messaging@yourname
    sudo systemctl start ambient-messaging@yourname
    sudo systemctl status ambient-messaging@yourname
    journalctl -f -u ambient-messaging
  • Prevent the Wifi of the RPi to go asleep:

    echo '
    Description=Disable wlan0 powersave
    After=network-online.target
    Wants=network-online.target
    
    [Service]
    Type=oneshot
    ExecStart=/sbin/iw wlan0 set power_save off
    
    [Install]
    WantedBy=multi-user.target' | sudo tee /etc/systemd/system/wifi-always-on.service
    
    sudo systemctl enable /etc/systemd/system/wifi-always-on.service
    sudo reboot

    Then, run iwconfig to check that it shows Power Management:off:

    lo        no wireless extensions.
    
    wlan0     IEEE 802.11  ESSID:"My Wifi SSID"
              Mode:Managed  Frequency:2.437 GHz  Access Point: 44:44:44:44:44:44
              Bit Rate=5.5 Mb/s   Tx-Power=31 dBm
              Retry short limit:7   RTS thr:off   Fragment thr:off
              Power Management:off
              Link Quality=56/70  Signal level=-54 dBm
              Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
              Tx excessive retries:82  Invalid misc:0   Missed beacon:0
    

About

ambient-messaging

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published