Skip to content

Instantly share code, notes, and snippets.

#include <Arduino.h>
#include <SPI.h>
#include <Ethernet2.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <DFRobot_ADS1115.h>
DFRobot_ADS1115 ads(&Wire);
// Update these with values suitable for your network.
@raspberrypi66
raspberrypi66 / handyDecoy.ino
Created March 11, 2022 04:56
สำหรับ Add อุปกรณ์ Handysense เข้า Dashboard
#include <Arduino.h>
#include <ArduinoJson.h>
#include <EEPROM.h>
#include <StreamUtils.h>
#include <Update.h>
#ifdef DEBUG
#define DEBUG_PRINT(x) //Serial.print(x)
#define DEBUG_PRINTLN(x) //Serial.println(x)
#else
#include <Wire.h>
#include "ClosedCube_HDC1080.h"
#define PWRPIN 26
#define RSTPIN 27
#define LEDPIN 2
#define SENSES_ID 178
#define SENSES_KEY "g9plf6uynqd7"
#define SENSES_SLOT 1
//define pin usage
#define IN1 2
#define IN2 4
void setPWM(int ch, int duty) {
//map value from 0-100 to 0-1023
int new_duty = map(duty, 0, 100, 0, 1023);
ledcWrite(ch, new_duty);
}
//download lib from Library Manager Search ESP32 Servo
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
// 16 servo objects can be created on the ESP32
int pos = 0; // variable to store the servo position
// Recommended PWM GPIO pins on the ESP32 include 2,4,12-19,21-23,25-27,32-33
int servoPin = 22;
#include <Adafruit_NeoPixel.h>//Adafruit neopixel
#define PIXELPIN 6 // connect to DI pin on LED Ring
#define NUMPIXELS 16
//Neopixel Ring Vcc to 5V ,Gnd to Gnd and DI to pin PIXELPIN define above
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIXELPIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>//Arduinojson By Benoit Blanchon version "5.13.5"
const char* ssid = "...@ makerlab"; // your network SSID (name of wifi network)
const char* password = "@Pinnqwerty"; // your network password
const char* server = "www.aismagellan.io"; // Server URL
String tokenID= "90b411d0-87e9-11e8-9738-71bdb0d8f3b4";//token ID from aismagellan
String readString = String(100);
/*
Basic ESP8266 MQTT example
This sketch demonstrates the capabilities of the pubsub library in combination
with the ESP8266 board/library.
It connects to an MQTT server then:
- publishes "hello world" to the topic "outTopic" every two seconds
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary
@raspberrypi66
raspberrypi66 / cloud.ino
Created July 13, 2018 07:41
For photography
/*
Basic ESP8266 MQTT example
This sketch demonstrates the capabilities of the pubsub library in combination
with the ESP8266 board/library.
It connects to an MQTT server then:
- publishes "hello world" to the topic "outTopic" every two seconds
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary
@raspberrypi66
raspberrypi66 / WeMos_mqttpub.ino
Created July 12, 2018 05:57
Example to publish to mqtt server from esp8266
/*
Basic ESP8266 MQTT example
This sketch demonstrates the capabilities of the pubsub library in combination
with the ESP8266 board/library.
It connects to an MQTT server then:
- publishes "hello world" to the topic "outTopic" every two seconds
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary