ESP32-C3 ESP-C3-13 2MB PlatformIO RGB LDR Example
ESP32 C3 ü PlatformIO da kullanmak için custom_partition kullanılmıştır. Proje dosyasında partitions_custom.csv dosyası incelendiğinde 2MB için özelleştirildiği görülecektir.
ESP32-C3 ESP-C3-13 2MB Partition Table
2MB için partitions_custom.csv dosyası içeriği;
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x1C0000,
spiffs, data, spiffs, 0x1D0000,0x30000,
ESP32-C3 ESP-C3-13 2MB platformio.ini
[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
board_build.f_flash = 80000000L ; flash freq
board_build.flash_mode = qio ; flash mode
board_upload.flash_size = 2MB ; max. size in MB
board_upload.maximum_size = 2097152 ; max. size
; board_uload.maximum_ram_size = 327680 ; max. RAM size
board_build.partitions = partitions_custom.csv ; partitial scheme
upload_speed = 921600 ; uload speed
monitor_speed = 115200 ; port BAUD
lib_deps =
https://github.com/knolleary/pubsubclient
https://github.com/bblanchon/ArduinoJson
board = esp32-c3-devkitm-1
framework = arduino
board_build.f_flash = 80000000L ; flash freq
board_build.flash_mode = qio ; flash mode
board_upload.flash_size = 2MB ; max. size in MB
board_upload.maximum_size = 2097152 ; max. size
; board_uload.maximum_ram_size = 327680 ; max. RAM size
board_build.partitions = partitions_custom.csv ; partitial scheme
upload_speed = 921600 ; uload speed
monitor_speed = 115200 ; port BAUD
lib_deps =
https://github.com/knolleary/pubsubclient
https://github.com/bblanchon/ArduinoJson
ESP32-C3 ESP-C3-13 2MB Wifi MQTT Example
/*
07.01.2024
ESP32 C3
2MB
iothook.com
mesebilisim.com
electrocoder
https://github.com/electrocoder/IOThook
*/
#include <Arduino.h>
#include <WiFi.h> // esp
#include <WiFiMulti.h> // esp
#include <PubSubClient.h> // mqtt
const char *ssid = "ssid";
const char *password = "password";
const char *HTTP_MQTT_SERVER = "iothook.com";
const int MQTT_PORT = 1883;
const String writeApiKey = "writeApiKey";
int field_1 = 0;
int numberOfResults = 3;
int fieldNumber = 1;
WiFiClient wifi_client;
PubSubClient pub_sub_client(wifi_client);
const char *mqtt_topic_telemetry = "v1/devices/me/telemetry"; // mqtt topic
void setup()
{
Serial.begin(115200);
while (!Serial)
{
delay(100);
}
Serial.println();
Serial.println("***");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
pub_sub_client.setServer(HTTP_MQTT_SERVER, MQTT_PORT);
while (!pub_sub_client.connected())
{
if (pub_sub_client.connect("qw", writeApiKey.c_str(), ""))
{
Serial.println("Connected");
}
}
} // setup
void loop()
{
int in1, in2, in3;
in1 = analogRead(A2);
in1 = analogRead(A3);
in1 = analogRead(A0);
String data = "{in1:" + String(in1) + ",in2:" + String(in2) + ",in3:" + String(in3) + "}";
pub_sub_client.publish(mqtt_topic_telemetry, data.c_str());
Serial.print(in1);
Serial.print(", ");
Serial.print(in2);
Serial.print(", ");
Serial.println(in3);
delay(1000);
} // loop
Tüm Proje Github IoTHook reposunda RGB_LDR projesinde paylaşılmıştır.