Audio (128) Datatype (18) Demo (65) Development (269) Document (70) Driver (20) Emulation (71) Game (626) Graphics (240) Library (24) Network (87) Office (24) Utility (336) Video (22)
Total files: 2000
Full index file Recent index file
Part of AROS World |
Pisensors | | Description: | C source library: DHT, DS18B20, BME280, OLED | | Download: | pisensors_src.aarch64-aros.lha (TIPS: Use the right click menu if your browser takes you back here all the time) | | Size: | 194kb | | Version: | 0.4 | | Date: | 22 Oct 26 | | Author: | Rhun | | Submitter: | Rhun | | Email: | rafal1982/yahoo com | | Requirements: | piAROS (AROS AArch64), Raspberry Pi 3/4 | | Category: | library | | Replaces: | library/pisensors_src.aarch64-aros.lha | | License: | Other | | Distribute: | yes | | FileID: | 3543 | | | | | Comments: | 0 | | Snapshots: | 0 | | Videos: | 0 | | Downloads: | 98 (Current version) | | 141 (Accumulated) | | Votes: | 1 (0/0) (30 days/7 days) | |
[Show comments] [Show snapshots] [Show videos] [Show content] [Replace file] PiSensors is a C source library for reading sensors on the Raspberry Pi
GPIO header under piAROS (Raspberry Pi 3 / 3B+ / 4).
Version 0.4 supports:
- DHT11, DHT22 / AM2302 temperature, humidity (any GPIO)
- DS18B20 temperature, several sensors on one pin
(1-Wire, any GPIO; also DS18S20, DS1822)
- BME280 temperature, humidity, pressure (I2C)
- BMP280 temperature, pressure (I2C)
- OLED display 0.96" 128x64, SSD1306 (also SH1106) (I2C)
It is a source / link library, not a system .library: there is nothing
to install. Add the source files to your project, or link the included
libpisensors.a, and read a sensor with a few lines of C:
DHT11 / DHT22 on GPIO4 (header pin 7):
struct PiDhtReading d;
char t[16], h[16];
pig_open();
if (pidht_read(4, 0, &d) == PIG_OK)
printf("DHT%d: %s C, %s %%n", d.type,
pig_tenths_to_str(t, d.temp10),
pig_tenths_to_str(h, d.hum10));
All DS18B20 sensors on GPIO4:
UBYTE rom[8][8];
struct PiDsReading s;
int i, n = pids_search(4, 0, rom, 8);
for (i = 0; i < n; i++)
if (pids_measure(4, 0, rom[i], &s) == PIG_OK)
printf("%s Cn", pig_tenths_to_str(t, s.temp10));
BME280 / BMP280 on the I2C bus:
struct PiBme280 bme;
struct PiBme280Reading r;
char p[16];
if (pibme280_open(&bme, PIBME280_ADDR_AUTO, 0) == PIG_OK &&
pibme280_read(&bme, &r) == PIG_OK)
printf("%s hPan", pig_tenths_to_str(p, r.pres10));
Text on an OLED display:
struct PiOled o;
if (pioled_open(&o, PIOLED_ADDR_AUTO, 0) == PIG_OK)
{
pioled_text(&o, 0, 20, "Hello", 3, 1);
pioled_update(&o);
}
pii2c_close();
DHT11 / DHT22 driver (pidht):
- automatic sensor type detection, 2-second read guard
- clear error codes; on a timeout it tells where the reading stopped
- the data pin is only ever driven low, never high
DS18B20 driver (pids18b20):
- finds all sensors on one pin by their 64-bit numbers (ROM codes)
- CRC check of every reading; the 85.0 C power-up value is recognised
and measured again
- interrupts are disabled only inside one bit (max. 75 us), never for
a whole reading; pids_start() lets a window program measure in the
background instead of waiting 750 ms
- the data pin is only ever driven low, never high
BME280 / BMP280 driver (pibme280):
- tells a BMP280 (no humidity) from a BME280 by its chip ID - cheap
boards are often mixed up by sellers
- finds the sensor at 0x76 or 0x77 by itself
- Bosch's integer compensation formulas, checked against the datasheet
- forced mode: the sensor sleeps between readings and does not warm up
OLED display driver (pioled):
- SSD1306 0.96" and SH1106 1.3", address 0x3C / 0x3D found by itself
- text in a 5x7 font in several sizes (with degree sign), pixels,
lines, rectangles; picture rotated by 180 degrees on request
- powered from 3.3 V - no level shifter needed
I2C bus (pii2c), usable for your own I2C drivers:
- hardware I2C controller on GPIO2/3 (header pins 3 and 5)
- checks that SDA/SCL are not stuck low before taking the pins,
gives them back as they were when closed
- automatic retries and bus recovery after a disturbance
- only one program can use the bus at a time, so two programs cannot
garble each other's transfers; the bus is freed when a program ends
GPIO layer (pigpio), usable for your own drivers:
- pin access with safety checks: only GPIO 2..27 can be changed, pins
used by UART / I2C / SPI are refused unless you pass PIG_FORCE
- microsecond timer that also works with interrupts disabled
- board detection; Raspberry Pi 5 is refused (GPIO is in the RP1 chip)
All values are integers (temperature 215 = 21.5 C, pressure 10133 =
1013.3 hPa) - no floating point needed.
Included, as source and ready-built:
- SensorPins graphical demo (Zune): shows which header pins to use
for a DHT, DS18B20 or BME/BMP280, warns about wrong
choices, reads the sensor live and can show the values
on an OLED display too
- DHTRead reads a DHT11 / DHT22 (Shell)
- DSRead finds and reads DS18B20 sensors (Shell)
- BMERead reads a BME280 / BMP280 (Shell)
- I2CScan lists the devices on the I2C bus (Shell)
- OLEDDemo small weather station: BME280 values on an OLED (Shell)
- libpisensors.a, build.sh for the AROS cross compiler
- manual.txt API reference, wiring, troubleshooting
Planned: SCD40 (CO2), OLED preview in SensorPins.
Connecting sensors is done at your own risk. Read the safety chapter in
manual.txt before wiring anything. GPIO pins are 3.3 V only - never
connect 5 V to a GPIO pin. A bare DS18B20 or the waterproof cable
version needs a 4.7 kOhm resistor between DATA and 3.3 V.
Copyright (c) 2026 rhun. MIT licence. Provided "as is", without
warranty of any kind.
|