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 <ModbusMaster.h> | |
#define RS485_RX_PIN (27) | |
#define RS485_TX_PIN (26) | |
ModbusMaster sensor; | |
void setup() { | |
Serial.begin(115200); |
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 <Arduino.h> | |
#include <WiFi.h> | |
#include <TinkerC6.h> | |
#include <ModbusMaster.h> | |
#include <PubSubClient.h> | |
#include "esp_pm.h" | |
#include "esp_wifi.h" | |
#include "driver/uart.h" | |
#include "soc/uart_struct.h" |
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 <TinkerC6.h> | |
#include <ModbusMaster.h> | |
ModbusMaster sensor; | |
void setup() { | |
Serial.begin(115200); | |
// Enable I2C Power Output (Sensor ON) | |
TinkerC6.Power.enable12V(); |
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 | |
- If the first character of the topic "inTopic" is an 1, switch ON the ESP Led, | |
else switch it 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
#include <TinkerC6.h> // เรียกใช้ไลบรารี่ Tinker C6 | |
void setup() { | |
Serial.begin(115200); // เริ่มใช้งาน Serial Monitor | |
TinkerC6.Power.enable12V(); // สั่งเปิดใช้ไฟเลี้ยง 12V | |
} | |
void loop() { | |
float mA = TinkerC6.Analog.getCurrent(); // อ่านค่าช่อง 4-20mA เก็บลงตัวแปร mA | |
Serial.printf("Analog is %.02f mA\n", mA); // แสดงผลค่าใน Serial Monitor |
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 <TinkerC6.h> // เรียกใช้ไลบรารี่ Tinker C6 | |
void setup() { | |
Serial.begin(115200); // เริ่มใช้งาน Serial Monitor | |
TinkerC6.RS485.begin(9600); // เริ่มใช้งาน RS485 | |
} | |
void loop() { | |
TinkerC6.RS485.enable(); // เปิดใช้งานส่วน RS485 | |
TinkerC6.RS485.println("Hello, RS485 !"); // ส่งข้อความออก RS485 |
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 <TinkerC6.h>// เรียกใช้ไลบรารี่ Tinker C6 | |
void setup() { | |
Serial.begin(115200); // เริ่มใช้งาน Serial Monitor | |
Serial.println("--- Begin ---"); // แสดงข้อความใน Serial Monitor | |
Serial.println("Enter to Light Sleep 5 sec"); // แสดงข้อความใน Serial Monitor | |
Serial.flush(); // รอจนกว่าจะส่งข้อมูลไปที่ Serial Monitor เสร็จ | |
TinkerC6.Power.enterToLightSleep(5000); // เข้า Light Sleep Mode เป็นเวลา 5 วินาที | |
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 <TinkerC6.h> // เรียกใช้ไลบรารี่ Tinker C6 | |
void setup() { | |
} | |
void loop() { | |
TinkerC6.Power.enable12V(); // สั่งเปิดใช้ไฟเลี้ยง 12V | |
TinkerC6.Power.enterToLightSleep(5000); // หน่วงเวลา 5 วินาที ด้วย Light Sleep Mode | |
TinkerC6.Power.disable12V(); // สั่งปิดไฟเลี้ยง 12V | |
TinkerC6.Power.enterToLightSleep(5000); // หน่วงเวลา 5 วินาที ด้วย Light Sleep Mode |
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 <TinkerC6.h> // เรียกใช้ไลบรารี่ Tinker C6 | |
void setup() { | |
Serial.begin(115200); // เริ่มใช้งาน Serial Monitor | |
} | |
void loop() { | |
int soc = TinkerC6.Power.getSOC(); // อ่านค่า % แบตเตอรี่ เก็บลงตัวแปร soc | |
float v_cell = TinkerC6.Power.getBatteryVoltage(); // อ่านค่าแรงดันแบตเตอรี่ เก็บลงตัวแปร v_cell | |
Serial.printf("Batt SOC: %d%%\tVolt: %.02fV\n", soc, v_cell); // แสดงผลค่าใน Serial Monitor |
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 "driver/gpio.h" | |
#include "driver/twai.h" | |
void setup() { | |
Serial.begin(115200); | |
twai_general_config_t g_config = { // สร้างต้วแปร g_config ใช้กำหนดค่าเกี่ยวกับบัส CAN | |
.mode = TWAI_MODE_NORMAL, | |
.tx_io = GPIO_NUM_26, // กำหนดขา TX ต่อกับ 26 | |
.rx_io = GPIO_NUM_27, // กำหนดขา TX ต่อกับ 27 |
NewerOlder