This file contains hidden or 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
| /** | |
| * Displays text sent over the serial port (e.g. from the Serial Monitor) on | |
| * an attached LCD. | |
| */ | |
| #include <ESP8266WiFi.h> | |
| #include <Wire.h> | |
| #include <LiquidCrystal_I2C.h> | |
| //https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library | |
| #define _MAX_TEXT_BUFFER_ 1024 |
This file contains hidden or 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
| function calculate_initial_capacity_percentage(voltage) | |
| { | |
| //voltage is adc 10bit | |
| voltage = voltage * 5 / 1024; // แปลงค่า Raw ที่ส่งมาเป็น แรงดัน | |
| capacity = 0; | |
| if (voltage > 4.2){ | |
| capacity = 100; | |
| }else if(voltage < 3.2 ){ | |
| capacity = 0; | |
| }else if (voltage > 4 ){ |
This file contains hidden or 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 "ESPert.h" | |
| #include <Wire.h> | |
| #include <Adafruit_Sensor.h> | |
| #include <Adafruit_ADXL345_U.h> | |
| ESPert espert; | |
| Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); | |
| //byte bitmap [] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x93,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x93,0x0 |
This file contains hidden or 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
| /* | |
| 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 |
This file contains hidden or 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
| /* | |
| 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 |
This file contains hidden or 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
| /* | |
| 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 |
This file contains hidden or 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 <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); |
This file contains hidden or 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 <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' |
This file contains hidden or 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
| //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; |
This file contains hidden or 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
| //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); | |
| } |
OlderNewer