Hi Everyone,
Newbie question:
My Hologram Nova is attached to a Raspberry Pi, and the goal is to send the sensor data to a Firebase database, specifically Cloud Firestore.
I’ve read through the main Routing article, https://support.hologram.io/hc/en-us/articles/360035696573 but without concrete examples, I don’t know where to go.
Here’s my current Python code…
Send a message from the Raspberry Pi to the Hologram Cloud:
import sys
from Hologram.HologramCloud import HologramCloud
if __name__ == '__main__':
hologram = HologramCloud(dict(), network='cellular')
print(f'Cloud type: {str(hologram)}')
recv = hologram.sendMessage('{temperature: 75, humidity:60}',
topics = ['TOPIC1','TOPIC2'],
timeout = 3)
print('RESPONSE MESSAGE: ' + hologram.getResultString(recv))
And if I was just on WiFi, not using my Nova, the code to POST sensor data to Firebase is:
import requests
import json
project_id = 'MY-PROJECT-ID'
web_api_key = 'MY-WEB-KEY'
collection_name = 'SensorData'
url = f'https://firestore.googleapis.com/v1/projects/{project_id}/databases/(default)/documents/{collection_name}/?key={web_api_key}'
payload = {
'fields': {
'temperature': { 'doubleValue': 75},
'humidity': {'doubleValue': 60}
}
}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
response = requests.post(url, data=json.dumps(payload), headers=headers)
print(f'response = {response}')
Ideally, I’d like to understand how to make a Route in my Hologram Dashboard that POSTs the data to Firebase.
Any help is appreciated!
Thanks,
Ryan