Skip to content

Instantly share code, notes, and snippets.

View gsampallo's full-sized avatar

Guillermo Sampallo gsampallo

View GitHub Profile
@gsampallo
gsampallo / demoRelay.ino
Created September 20, 2018 23:05
DemoRelay
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "wifi";
const char* password = "clave";
const char* mqtt_server = "mqtt_server";
int devicePin = 2;
WiFiClient espClient;
@gsampallo
gsampallo / stats.py
Created October 20, 2019 13:04
Raspberry Pi System Stats
#
# Raspberry Pi System Stats
# Save temperature, cpu usage and others to ThingSpeak channel
# Check the article: https://www.gsampallo.com/blog/2019/10/20/estadisticas-de-sistemas-de-raspberry-pi/
#
import subprocess
import json
import requests
p = subprocess.Popen(['iostat','-c','-o','JSON'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
void loop() {
estado = digitalRead(sensor); //se lee el estado del sensor
Serial.print("Estado del sensor = ");
Serial.println(sensor);
//Vaciamos la pantalla
oled.crearDisplay();
oled.setTextColor(WHITE);
oled.setCursor(0,0);
oled.setTextSize(2);
@gsampallo
gsampallo / conectarse_red.ino
Created July 10, 2020 16:28
DPRE - Cómo conectarse a una red WiFi con ESP8266
#include <ESP8266WiFi.h>
const char* ssid = "NOMBRE_RED";
const char* password = "PASSWORD_RED";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid,password);
@gsampallo
gsampallo / webserver.ino
Created July 10, 2020 16:31
DPRE - Crear un servidor web con NodeMCU/ESP8266 y que responda solicitudes.
#include <ESP8266WiFi.h>
const char* ssid = "NOMBRE_RED";
const char* password = "PASSWORD_RED";
WiFiServer servidor(80);
void setup() {
Serial.begin(115200);
@gsampallo
gsampallo / webserver_led.ino
Created July 10, 2020 21:35
DPRE - Control de un led desde el navegador
#include <ESP8266WiFi.h>
const char* ssid = "SSID_NETWORK";
const char* password = "PASSWORD_NETWORK";
WiFiServer servidor(80);
int pinLed1 = 5; //D1
void setup() {
@gsampallo
gsampallo / publicar_mqtt.ino
Created July 20, 2020 19:12
DPRE - Publicar datos en un tema
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
//Reemplace por los datos de la red iot
const char* ssid = "Nombre_red";
const char* password = "Clave_red";
const char* mqtt_server = "Servidor_MQTT";
WiFiClient espClient;
@gsampallo
gsampallo / suscribirse_mqtt.ino
Created July 21, 2020 14:51
DPRE - Suscribirse a un tema con MQTT
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
//Reemplace por los datos de la red iot
const char* ssid = "Nombre_red";
const char* password = "password";
const char* mqtt_server = "mqtt_server";
WiFiClient espClient;
@gsampallo
gsampallo / enviar_mensaje.ino
Last active August 16, 2020 18:30
Simple ejemplo para enviar una notificación push a un telefono por medio de Pushbullet desde NodeMCU.
/*
* Send Push notification from NodeMCU with Pushbullet API
* https://www.gsampallo.com/2020/07/09/envio-de-notificaciones-desde-nodemcu-con-pushbullet/
* Guillermo Sampallo 2020
*/
#include <ESP8266WiFi.h>
const char* ssid = "SSD_NETWORK";
const char* password = "PASSWORD_NETWORK";
@gsampallo
gsampallo / digital_pot.ino
Created September 13, 2020 21:51
How to use a digital potenciometer with Arduino (MCP 4131-103)
/*
* How to use a digital potenciometer with Arduino
* Link to article: https://www.gsampallo.com/?p=952
*/
#include <SPI.h>
byte address = 0x00;
int CS = 10;
void setup() {