25  IoT Code Snippet Library

Copy-Paste Ready Code for Common IoT Tasks

25.1 Code Snippet Library

Tip100+ Ready-to-Use Code Snippets

Browse or search our curated collection of IoT code snippets. Each snippet is tested, documented, and includes explanations of key concepts.


25.2 Snippet Browser


25.3 Quick Reference Tables

25.3.1 Common Pin Configurations

Module SPI (SCK/MISO/MOSI/SS) I2C (SDA/SCL) UART (TX/RX)
ESP32 DevKit 18/19/23/5 21/22 1/3
ESP32-S3 12/13/11/10 8/9 43/44
ESP8266 14/12/13/15 4/5 1/3
Arduino Uno 13/12/11/10 A4/A5 0/1

25.3.2 Library Quick Reference

Task Library Install Command
MQTT PubSubClient pio lib install "PubSubClient"
JSON ArduinoJson pio lib install "ArduinoJson"
HTTP HTTPClient Built-in (ESP32)
LoRa LoRa pio lib install "LoRa"
BLE ESP32 BLE Built-in (ESP32)
Wi-Fi Wi-Fi Built-in

25.4 Contributing Snippets

Have a useful code snippet? Follow this format:

**Title**: Brief descriptive title
**Category**: Sensors/MQTT/HTTP/BLE/LoRa/Power/Data/Security
**Platform**: Arduino/ESP32/ESP8266/Raspberry Pi
**Difficulty**: Beginner/Intermediate/Advanced
**Tags**: relevant, searchable, keywords
**Description**: What this snippet does
**Code**: Working, tested code
**Explanation**: Key concepts and gotchas
NoteKeep Learning