Skip to content

Instantly share code, notes, and snippets.

#Store number features in variables
redcolor=0
orangecolor=1
smooth=0
rough=1
apple=0
orange=1
#Put all data points in an array - features and labels in seperate arrays
features=[[redcolor,smooth],[orangecolor,rough],[redcolor,smooth],
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> //Library to handle Web Server commands
#include <WiFiClient.h>
int irpin = D1;
int buzzerPin = D2;
ESP8266WebServer server(80); //Declare a server object
String name = "";
String Mobile = "";
String Address = "";
String Email = "";
void setup() {
Serial.begin(9600); //starting the data transfer at 9600 baud rate
}
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)
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
message = client.messages \
.create(
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
client = Client(account_sid, auth_token)
message = client.messages \
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
const char* mqtt_server = "192.168.XX.XXX";// Your Raspberry Pi IP address
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
import paho.mqtt.client as paho
broker="192.168.xx.xx" #IP of your Raspberry Pi
#define callback
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
import time
import Adafruit_SSD1306
from PIL import Image
# Raspberry Pi pin configuration:
RST = 24
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)
import time
import Adafruit_ADXL345
accel = Adafruit_ADXL345.ADXL345()
print('Printing X, Y, Z axis values, press Ctrl-C to quit...')
while True:
# Read the X, Y, Z axis acceleration values and print them.
x, y, z = accel.read()
print('X={0}, Y={1}, Z={2}'.format(x, y, z))