Maks Surguy
Published © MIT

Pi Zero WAN (PiWANOVA)

Pi Zero WAN provides low bandwidth communications in remote places.

IntermediateProtip10 hours2,840

Things used in this project

Hardware components

Raspberry Pi Zero
×1
Hologram Nova
Hologram Nova
×1

Software apps and online services

Raspbian
Hologram Dashboard
Laravel

Story

Read more

Schematics

Pi Zero + Nova + wifi devices

Pizerowan ktjenhiooy

System Overview

Schematic uth2dpvpgb

Pi Zero and Hologram Nova

These two look so good together!
Img 0915 2fpfqduhnd

Code

receive-data.py

Python
Create a folder that will store the JSON file. Run the script on Raspberry Pi with Nova. Post a message in Hologram Dashboard and see if it appears in the JSON file!
#
# Example of using a supported modem to receive messages
# from the Hologram Cloud.
#
# Author:  Maks Surguy http://twitter.com/msurguy
#
# Copyright 2018 - Maks Surguy
#
# LICENSE: Distributed under the terms of the MIT License
#

from Hologram.HologramCloud import HologramCloud

import sys
import time

def popReceivedMessage():
    recv = hologram.popReceivedMessage()
    if recv is not None:
        print("Data received!")
        # write the JSON object from the received data. The path to JSON file should be within your Laravel Server application's storage folder
        with open("/home/pi/INTERNAL/projects/PiWANOVA/storage/json/dashboard.json", "w") as text_file:
            text_file.write(str(recv))

def handle_polling(timeout, fx, delay_interval=0):
    try:
        if timeout != -1:
            print 'waiting for ' + str(timeout) + ' seconds...'
            end = time.time() + timeout
            while time.time() < end:
                fx()
                time.sleep(delay_interval)
        else:
            while True:
                fx()
                time.sleep(delay_interval)
    except KeyboardInterrupt as e:
        sys.exit(e)


if __name__ == "__main__":
    print ""
    print ""
    print "* Note: You can obtain device keys from the Devices page"
    print "* at https://dashboard.hologram.io"
    print ""

    #device_key = raw_input("What is your device key? ")

    credentials = {'devicekey': "device-key-here"}

    hologram = HologramCloud(credentials, network='cellular')

    hologram.event.subscribe('message.received', popReceivedMessage)

    hologram.network.connect()

    hologram.openReceiveSocket()
    print ('Ready to receive data on port %s' % hologram.receive_port)

    try:
        while True:
            handle_polling(40, popReceivedMessage, 1)
            # repeat polling every 60 seconds
            time.sleep(60)

    except KeyboardInterrupt as e:
        print 'Closing socket...'
        hologram.closeReceiveSocket()
        hologram.network.disconnect()
        sys.exit(e)

dashboard.json

JSON
Send this JSON file to the NOVA device through the Hologram Dashboard
{
  "news": "There will be trail maintenance in this area starting January 5th. Some trails might be closed!",
  "forecast": {
    "current": {
      "temp": "54F"
    },
    "3day": {
      "0": {
        "temp": "64F",
        "conditions": "cloudy"
      },
      "1": {
        "temp": "28F",
        "conditions": "snow"
      },
      "2": {
        "temp": "44F",
        "conditions": "rain"
      }
    }
  }
}

Pi Zero as access point

HTML
https://cdn-learn.adafruit.com/downloads/pdf/setting-up-a-raspberry-pi-as-a-wifi-access-point.pdf

Laravel Guestbook Repo

Server side application for PiWANOVA

Credits

Maks Surguy

Maks Surguy

1 project • 3 followers
Grad student, Masters of Science in Technology Innovation program at UW

Comments