Skip to content

Instantly share code, notes, and snippets.

@benstr
Created January 9, 2018 16:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benstr/f908810f8396b7f657e6cfd2cbbca559 to your computer and use it in GitHub Desktop.
Save benstr/f908810f8396b7f657e6cfd2cbbca559 to your computer and use it in GitHub Desktop.
Example using base64 encoding to send a image over cellular on a Raspberry Pi with Hologram.io
from Hologram.HologramCloud import HologramCloud
import logging
import base64
#uncomment if you want to see debugging messages.
#not suggested for larger images
#logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(message)s")
hologram = HologramCloud(dict(), authentication_type='totp', network='cellular')
b64 = base64.b64encode(open("raspi-img.jpg", "rb").read())
print len(b64)
hologram.network.connect()
send = hologram.sendMessage(b64, timeout=200)
print send
hologram.network.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment