Skip to content

Instantly share code, notes, and snippets.

View assistant.py
from Adafruit_IO import MQTTClient
import RPi.GPIO as IO
ADAFRUIT_IO_USERNAME = "xxxxxxxxxx"
ADAFRUIT_IO_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
IO.setwarnings(False)
IO.setmode(IO.BOARD)
IO.setup(11,IO.OUT)
View firebase.py
import RPi.GPIO as GPIO
from time import sleep
from firebase import firebase
import Adafruit_DHT
sensor = Adafruit_DHT.DHT11
pin = 4
firebase = firebase.FirebaseApplication('https://YOUR_FIREBASE_URL.firebaseio.com/', None)
firebase.put("/", "/temp", "0.00")
View ADXL_LP.ino
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_ADXL345_U.h>
Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345);
float val_x=0,val_y=0,val_z=0;
float sig_x=0,sig_y=0,sig_z=0;
float alpha=0.1;
void setup()
{
Serial.begin(115200);
View Analog-LP-filter.ino
double sig=0,alpha=0.2;
void setup() {
Serial.begin(115200);
}
void loop() {
int val=analogRead(A0);
sig = (alpha*(double)val) + ((1.0-alpha)*sig);
Serial.print(val);
Serial.print(",");
View subscribe.py
import paho.mqtt.client as paho
broker="192.168.xx.xxx" #IP of your Raspberry Pi
def on_message(client, userdata, message):
print("received message =",str(message.payload.decode("utf-8")))
client= paho.Client("client-001")
client.on_message=on_message
print("connecting to broker ",broker)
View publish.py
import Adafruit_DHT
import paho.mqtt.client as paho
broker="192.168.xx.xxx"
sensor = Adafruit_DHT.DHT11
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
def hum_temp():
View mqtt rpi.py
import time
import paho.mqtt.client as paho
broker="192.168.x.xxx" #IP of your Raspberry Pi
#define callback
def on_message(client, userdata, message):
time.sleep(1)
print("received message =",str(message.payload.decode("utf-8")))
client= paho.Client("client-001")
client.on_message=on_message
View dht with rpi.py
import sys
import RPi.GPIO as GPIO
import os
from time import sleep
import Adafruit_DHT
import urllib2
DEBUG = 1
# Setup the pins we are connect to
soilpin = 14
View NodeMCU-OTA-LED.ino
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
// Replace with your network credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
const int ESP_BUILTIN_LED = D0;
View NodeMCU-NetBIOS.ino
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266NetBIOS.h>
const char* ssid = "............";
const char* password = "..............";
ESP8266WebServer wwwserver(80);
String content;