Skip to content

Instantly share code, notes, and snippets.

View samuelbles07's full-sized avatar

Samuel Siburian samuelbles07

View GitHub Profile
@samuelbles07
samuelbles07 / button.cpp
Last active June 30, 2019 07:53
Workshop Road to RIoT 2019
#include <Arduino.h>
#include <ESPectro32_Board.h>
void setup() {
pinMode(ESPECTRO32_LED_PIN, OUTPUT);
pinMode(ESPECTRO32_BUTTON_A_PIN, INPUT);
}
void loop() {
if (digitalRead(ESPECTRO32_BUTTON_A_PIN) == LOW) {
@samuelbles07
samuelbles07 / get_wifi.py
Created June 23, 2019 09:59
Get raspberry pi wifi mac address
from uuid import getnode as get_mac
def getMacAddr():
mac = get_mac()
h = iter(hex(mac)[2:].zfill(12))
mc = ":".join(i + next(h) for i in h)
return mc
#include <WiFi.h>
#include <PubSubClient.h>
const char* ssid = "YOUR-SSID";
const char* password = "YOUR-PASSWORD";
const char* mqtt_server = "broker.mqtt-dashboard.com";
WiFiClient myClient;
PubSubClient client(myClient);
long lastMsg = 0;
// the number of the LED pin
const int ledPin = 15; // 16 corresponds to GPIO16
// setting PWM properties
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;
void setup(){
// configure LED PWM functionalitites