View main.cpp
#include <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <Cloud4RPi.h> | |
#include "DHT.h" | |
#ifndef LED_BUILTIN | |
#define LED_BUILTIN 2 | |
#endif | |
#define DHTPIN 2 // Digital pin connected to the DHT sensor |
View coffee-pump.py
import sys | |
import traceback | |
import time | |
import json | |
from urllib.request import Request, urlopen | |
from urllib.error import URLError, HTTPError | |
import RPi.GPIO as GPIO | |
import cloud4rpi | |
from hcsr04sensor import sensor |
View ds18b20.py
# -*- coding: utf-8 -*- | |
# The DS18B20 sensor should be connected as follows: | |
# | |
# / GND |────────────> GND | |
# | DATA |─────────┬──> GPIO4 | |
# \ VCC |─┬─[4k7]─┘ | |
# └──────────> 5V | |
# DS18B20 (bottom view) | |
# |
View main.cpp
#include <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <Cloud4RPi.h> | |
const String deviceToken = "__YOUR__DEVICE_TOKEN__"; | |
char wifiSSID[] = "__SSID__"; | |
char wifiPassword[] = "__PASSWORD__"; | |
void ensureWiFiConnection(); |
View secure-mqtt.py
# -*- coding: utf-8 -*- | |
from time import sleep | |
from socket import gethostname | |
import cloud4rpi | |
# Put your device token here. To get the token, | |
# sign up at https://cloud4rpi.io and create a device. | |
DEVICE_TOKEN = '__YOUR_DEVICE_TOKEN__' |
View DHT22.py
# -*- coding: utf-8 -*- | |
import sys | |
import time | |
import cloud4rpi | |
import rpi | |
import Adafruit_DHT | |
# Put your device token here. To get the token, | |
# sign up at https://cloud4rpi.io and create a device. |
View service_install.sh
#!/bin/bash | |
readonly PYTHON_PATH=/usr/bin/python3 | |
readonly SERVICE_NAME=cloud4rpi | |
quit_on_error() { | |
test "0" = $? || { | |
exit 1 | |
} | |
} |
View minimal.py
# -*- coding: utf-8 -*- | |
from time import sleep | |
import sys | |
import cloud4rpi | |
# these functions will be called by device when sending data | |
def room_temp(): | |
return 25 |