Skip to content

Instantly share code, notes, and snippets.

c4r-gists c4r-gists

Block or report user

Report or block c4r-gists

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@c4r-gists
c4r-gists / coffee-pump.py
Created Mar 15, 2019
Water level control on RaspberryPi using HCSR04 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
@c4r-gists
c4r-gists / ds18b20.py
Created Jul 20, 2018
DS18B20-Fahrenheit
View ds18b20.py
# -*- coding: utf-8 -*-
# The DS18B20 sensor should be connected as follows:
#
# / GND |────────────> GND
# | DATA |─────────┬──> GPIO4
# \ VCC |─┬─[4k7]─┘
# └──────────> 5V
# DS18B20 (bottom view)
#
@c4r-gists
c4r-gists / main.cpp
Created Feb 19, 2018
pio-nodeMCU-MQTT
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__'
@c4r-gists
c4r-gists / DHT22.py
Last active Feb 7, 2018
How to send temperature and humidity using DHT22(11) sensor
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.
@c4r-gists
c4r-gists / service_install.sh
Last active Nov 29, 2017
Cloud4RRi service installation script for Debian-based systems (http://docs.cloud4rpi.io/start/rpi/#installing-as-a-service)
View service_install.sh
#!/bin/bash
readonly PYTHON_PATH=/usr/bin/python
readonly SERVICE_NAME=cloud4rpi
quit_on_error() {
test "0" = $? || {
exit 1
}
}
@c4r-gists
c4r-gists / minimal.py
Last active Feb 7, 2018
Minimal example of Cloud4RPi client library usage on python
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
You can’t perform that action at this time.