Google Cloud¶
BigQuery¶
I will be using BigQuery for storing the following data:
- primary temperature measurements and error messages
- chat IDs for Telegram bots.
Python API
-
To run the client library, you must first set up authentication.
- Create the service account:
gcloud iam service-accounts create bgtest -
Grant role
adminto the service account. -
Generate the key file:
-
Set
GOOGLE_APPLICATION_CREDENTIALSenv var:
- Create the service account:
Google Functions¶
I will use Google Function for the following tasks:
- process messages from IoT devices
- handle http requests from Telegram
- regular notification via Cron.
How to deploy a Cloud Function
When deploying a new Cloud Function you nedd to specify –trigger
Example of Google Function with trigger-topic:
gcloud functions deploy function_name \
--gen2 \
--region=region_name \
--trigger-topic=topic_name \
--runtime=python310 \
--source=path_to_directory \
--entry-point=function_name \
--allow-unauthenticated
Example of Google Function with trigger-http:
gcloud functions deploy function_name \
--gen2 \
--region=region_name \
--trigger-http \
--runtime=python310 \
--source=path_to_directory \
--entry-point=function_name \
--allow-unauthenticated
If you wish to delete an exicting Google Function do this:
Job Sheduler¶
For receiving data from sensors every day at the exact time you need to use Cron to shedule jobs.
Setup cron job that sends a request at 6:00, 15:00, 18:00 (London time) every day: