This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myTopic = "users/jensa/led"; | |
const myServer = "mqtt.toytronics.com"; | |
const client = new Paho.MQTT.Client(myServer,8883, "myClientId" + new Date().getTime()); | |
client.onConnectionLost = onConnectionLost; | |
client.onMessageArrived = onMessageArrived; | |
console.log("Start connection!"); | |
var connectOptions = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sensorPin = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include <Wire.h> | |
#include <i2cdetect.h> | |
#include <Adafruit_LIS3DH.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_DotStar.h> | |
#include "Adafruit_SHT31.h" | |
#include "Adafruit_LTR329_LTR303.h" | |
// There is only one pixel on the board |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////// | |
//©2011 bildr | |
//Released under the MIT License – Please reuse change and share | |
//Simple code to output a PWM sine wave signal on pin 9 | |
////////////////////////////////////////////////////////////////// | |
#define fadePin 9 | |
void setup(){ | |
pinMode(fadePin, OUTPUT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "esp_http_client.h" | |
#include "esp_camera.h" | |
#include <WiFi.h> | |
#include "Arduino.h" | |
#include "Base64.h" | |
#include "mbedtls/base64.h" | |
#include <NTPClient.h> | |
#include <WiFiUdp.h> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useSubscription } from 'mqtt-react-hooks'; | |
export default function Subscriber() { | |
/* Message structure: | |
* topic: string | |
* message: string | |
*/ | |
const { message } = useSubscription([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { useMqttState } from 'mqtt-react-hooks'; | |
export default function Status() { | |
/* | |
* Status list | |
* - Offline | |
* - Connected | |
* - Reconnecting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Socket.IO chat</title> | |
<style> | |
body { margin: 0; padding-bottom: 3rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; } | |
#form { background: rgba(0, 0, 0, 0.15); padding: 0.25rem; position: fixed; bottom: 0; left: 0; right: 0; display: flex; height: 3rem; box-sizing: border-box; backdrop-filter: blur(10px); } | |
#input { border: none; padding: 0 1rem; flex-grow: 1; border-radius: 2rem; margin: 0.25rem; } | |
#input:focus { outline: none; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const http = require('http'); | |
const server = http.createServer(app); | |
const { Server } = require("socket.io"); | |
const io = new Server(server); | |
app.get('/', (req, res) => { | |
res.sendFile(__dirname + '/index.html'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logo from './logo.svg'; | |
import './App.css'; | |
import { Connector } from 'mqtt-react-hooks'; | |
import Status from './Status'; | |
const mqttOptions = { | |
username: 'username', | |
password: 'password', // Passwords are buffers | |
} |