PiCo Documentation
Welcome to the PiCo technical reference. This covers hardware specifications, API documentation, library usage, and complete code examples for all boards in the PiCo family.
New to PiCo? Start with the Learn section for step-by-step tutorials before diving into this reference.
Board Comparison
| Feature | PiCo NANO | PiCo CORE | PiCo WIFI | PiCo PRO |
|---|---|---|---|---|
| MCU | ATmega328P | ATmega2560 | ESP32 | STM32H743 |
| Clock | 16 MHz | 16 MHz | 240 MHz | 480 MHz |
| Flash | 32 KB | 256 KB | 4 MB | 2 MB |
| SRAM | 2 KB | 8 KB | 520 KB + 8 MB PSRAM | 1 MB |
| Digital I/O | 22 | 54 | 38 | 168 |
| ADC | 8 ch / 10-bit | 16 ch / 10-bit | 18 ch / 12-bit | 36 ch / 16-bit |
| WiFi / BT | — | — | 802.11 b/g/n + BT 5 | — (module option) |
| CAN / Ethernet | — | — | — | CAN FD + Ethernet |
| Temp range | 0–70°C | 0–70°C | –40–85°C | –40–85°C |
| Price (MAD) | 199 | 349 | 449 | 749 |
API Reference — Core Functions
PiCo CORE and NANO expose the standard Arduino API. The functions below are available on all boards.
pinMode(pin, mode)
Configures a pin as INPUT, OUTPUT, or INPUT_PULLUP.
C++
pinMode(13, OUTPUT); // set pin 13 as output
pinMode(2, INPUT_PULLUP); // internal pull-up resistor
digitalWrite / digitalRead
C++
digitalWrite(13, HIGH); // set pin HIGH (5V)
digitalWrite(13, LOW); // set pin LOW (0V)
int val = digitalRead(2); // returns HIGH or LOW
analogRead / analogWrite
C++
int raw = analogRead(A0); // 0–1023 (10-bit)
float v = raw * (5.0 / 1023.0); // convert to volts
analogWrite(9, 128); // PWM: 0–255 (50% duty)
Serial (UART)
C++
Serial.begin(115200); // UART0 at 115200 baud
Serial.print("value: ");
Serial.println(42);
// PiCo CORE has 4 hardware UARTs:
Serial1.begin(9600); // pins TX1/RX1
Serial2.begin(9600); // pins TX2/RX2
I²C (Wire)
C++
#include <Wire.h>
void setup() {
Wire.begin(); // join I²C bus as master
}
// Write a byte to device at address 0x27
Wire.beginTransmission(0x27);
Wire.write(0x00); // register
Wire.write(0xFF); // value
Wire.endTransmission();
// Read 2 bytes from address 0x68
Wire.requestFrom(0x68, 2);
byte hi = Wire.read();
byte lo = Wire.read();
SPI
C++
#include <SPI.h>
const int CS = 10;
void setup() {
SPI.begin();
pinMode(CS, OUTPUT);
digitalWrite(CS, HIGH);
}
void spiWrite(byte reg, byte val) {
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
digitalWrite(CS, LOW);
SPI.transfer(reg);
SPI.transfer(val);
digitalWrite(CS, HIGH);
SPI.endTransaction();
}
Timers & PWM
PiCo CORE has 6 hardware timers providing 15 PWM outputs. Default PWM frequency is 490Hz (pins 5, 6: 980Hz).
C++
// Change Timer2 prescaler for ~31kHz PWM on pins 9, 10
TCCR2B = TCCR2B & B11111000 | B00000001; // 31372 Hz
// Hardware timer interrupt (Timer1, 1 Hz)
#include <TimerOne.h>
Timer1.initialize(1000000); // 1 second in microseconds
Timer1.attachInterrupt(myISR);
PiCo Sensor Libraries
Install via Arduino Library Manager or clone from github.com/PiCoAcademy.
| Library | Sensor | Protocol | Install name |
|---|---|---|---|
| PiCo_DHT | DHT11/22 Temp + Humidity | 1-Wire | PiCo_DHT |
| PiCo_BMP | BMP280 Pressure + Temp | I²C / SPI | PiCo_BMP |
| PiCo_US | HC-SR04 Ultrasonic | Trigger/Echo | PiCo_US |
| PiCo_MPU | MPU6050 Gyro/Accel | I²C | PiCo_MPU |
| PiCo_LCD | 16×2 LCD (I²C) | I²C | PiCo_LCD |
Example: MQTT (PiCo WIFI)
Publish sensor data to an MQTT broker using the PiCo WIFI board and the PubSubClient library.
Arduino / C++ · PiCo WIFI
#include <WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
const char* SSID = "YourWiFi";
const char* PASSWORD = "YourPass";
const char* BROKER = "broker.hivemq.com";
WiFiClient net;
PubSubClient mqtt(net);
DHT dht(4, DHT22);
void connectWiFi() {
WiFi.begin(SSID, PASSWORD);
while (WiFi.status() != WL_CONNECTED) delay(500);
}
void connectMQTT() {
while (!mqtt.connected()) {
mqtt.connect("PiCoWIFI");
delay(1000);
}
}
void setup() {
Serial.begin(115200);
dht.begin();
connectWiFi();
mqtt.setServer(BROKER, 1883);
connectMQTT();
}
void loop() {
if (!mqtt.connected()) connectMQTT();
mqtt.loop();
float t = dht.readTemperature();
float h = dht.readHumidity();
char buf[32];
snprintf(buf, sizeof(buf), "%.1f", t);
mqtt.publish("pico/temperature", buf);
snprintf(buf, sizeof(buf), "%.1f", h);
mqtt.publish("pico/humidity", buf);
delay(10000); // publish every 10 seconds
}
Example: I²C Scanner
Scans all 127 I²C addresses and prints detected devices to Serial Monitor.
Arduino / C++
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("I2C Scanner — PiCo.ma");
for (byte addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.print("Device found at 0x");
if (addr < 16) Serial.print("0");
Serial.println(addr, HEX);
}
}
Serial.println("Scan complete.");
}
void loop() {}