PCB Design for RAK3312
Table
| Function | GPIO | Schematic Net | Notes |
|---|---|---|---|
| SEN66 SDA | 9 | I2C1_SDA | Pull-up R6 to 3.3 V |
| SEN66 SCL | 40 | I2C1_SCL | Pull-up R7 to 3.3 V, 100 kHz max recommended |
| RGB red cathode | 41 | LED_R | Low-side active-low LED drive |
| RGB green cathode | 42 | LED_G | Low-side active-low LED drive |
| RGB blue cathode | 38 | LED_B | Low-side active-low LED drive |
| BOOT | 0 | BOOT | Pulled up by R11, SW2 pulls low |
| RESET | RESET | RESET | Pulled up by R5, SW1 pulls low |
Ini
[env:rak3312_esp32s3] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 upload_speed = 921600 lib_deps = Wire
Cpp
#include <Arduino.h> #include <Wire.h> #include <WiFi.h> #define PIN_SEN66_SDA 9 #define PIN_SEN66_SCL 40 #define PIN_LED_R 41 #define PIN_LED_G 42 #define PIN_LED_B 38 #define SEN66_ADDR 0x6B #define SEN66_READ_INTERVAL_MS 5000UL static unsigned long lastRead = 0; void setRgb(bool r, bool g, bool b) { // LED cathodes are GPIO-driven; LOW turns channel on. digitalWrite(PIN_LED_R, r ? LOW : HIGH); digitalWrite(PIN_LED_G, g ? LOW : HIGH); digitalWrite(PIN_LED_B, b ? LOW : HIGH); } bool i2cProbe(uint8_t addr) { Wire.beginTransmission(addr); return Wire.endTransmission() == 0; } bool sen66SendCommand(uint16_t cmd) { Wire.beginTransmission(SEN66_ADDR); Wire.write((uint8_t)(cmd >> 8)); Wire.write((uint8_t)(cmd & 0xFF)); return Wire.endTransmission() == 0; } void setup() { Serial.begin(115200); delay(500); Serial.println("RAK3312 carrier firmware starting"); pinMode(PIN_LED_R, OUTPUT); pinMode(PIN_LED_G, OUTPUT); pinMode(PIN_LED_B, OUTPUT); setRgb(false, false, true); WiFi.mode(WIFI_OFF); Wire.begin(PIN_SEN66_SDA, PIN_SEN66_SCL, 100000); if (i2cProbe(SEN66_ADDR)) { Serial.println("SEN66 detected at 0x6B"); setRgb(false, true, false); // SEN6x start continuous measurement command; verify against final SEN66 datasheet/API. sen66SendCommand(0x0021); } else { Serial.println("SEN66 not detected"); setRgb(true, false, false); } } void loop() { if (millis() - lastRead >= SEN66_READ_INTERVAL_MS) { lastRead = millis(); bool present = i2cProbe(SEN66_ADDR); Serial.printf("SEN66 %s\n", present ? "present" : "missing"); setRgb(!present, present, false); } }
Bash
pio run pio run -t upload pio device monitor
Platform
Pin Mapping
platformio.ini
src/main.cpp
Build and Flash