diff --git a/index.html b/index.html index 10dafd5..718e474 100644 --- a/index.html +++ b/index.html @@ -127,18 +127,7 @@

Installation# You might want to switch back to non-admin R library(devtools) -#> Loading required package: usethis -install_github("mnr/rpigpior") -#> Downloading GitHub repo mnr/rpigpior@HEAD -#> ── R CMD build ───────────────────────────────────────────────────────────────── -#> checking for file ‘/private/var/folders/sw/tfbr78mn7knfkl4ll9tx40m80000gn/T/Rtmp1oLMSF/remotes5f2e65f6eb16/mnr-rpigpior-58b1907/DESCRIPTION’ ... ✔ checking for file ‘/private/var/folders/sw/tfbr78mn7knfkl4ll9tx40m80000gn/T/Rtmp1oLMSF/remotes5f2e65f6eb16/mnr-rpigpior-58b1907/DESCRIPTION’ -#> ─ preparing ‘rpigpior’: -#> checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information -#> ─ checking for LF line-endings in source and make files and shell scripts -#> ─ checking for empty or unneeded directories -#> ─ building ‘rpigpior_0.1.0.tar.gz’ -#> -#> +install_github("mnr/rpigpior")

Once you’ve installed, use library just like any other R package:

 library(rpigpior)
diff --git a/pkgdown.yml b/pkgdown.yml index a35efae..1b00e32 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -7,7 +7,7 @@ articles: how-to-RPi: how-to-RPi.html rpi_i2c: rpi_i2c.html rpi_pwm: rpi_pwm.html -last_built: 2024-02-17T00:43Z +last_built: 2024-02-17T00:45Z urls: reference: https://mnr.github.io/rpigpior/reference article: https://mnr.github.io/rpigpior/articles diff --git a/search.json b/search.json index be55656..1cd85dd 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://mnr.github.io/rpigpior/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 rpigpior authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"understanding-gpio","dir":"Articles","previous_headings":"","what":"Understanding GPIO","title":"How to write GPIO Code with rpigpiodr and R","text":"GPIO stands General Purpose Input/Output. can “see” Raspberry Pi; ’s dual row pins along one edge. two rows twenty pins total forty pins. GPIO pins can deliver 3.3 volts direct current (DC), 5 volts DC, ground, multipurpose input output pins. pins also deliver specialty functions I2C, SPI, UART, 1-wire, PWM. don’t pay attention pin functions connect things GPIO, zap Raspberry Pi. ’s bad thing.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"gpio-implies-connecting-wires","dir":"Articles","previous_headings":"","what":"GPIO implies connecting wires","title":"How to write GPIO Code with rpigpiodr and R","text":"stray world Raspberry Pi, ’s intent connect sensors devices GPIO pins. implies circuits wires. can show , assume already gone excellent tutorials Raspberry Pi foundation places LinkedIn Learning.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"reading-a-switch","dir":"Articles","previous_headings":"","what":"Reading a switch","title":"How to write GPIO Code with rpigpiodr and R","text":"Let’s talk illustration. Connecting switch Raspberry Pi","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"pins-and-identifiers","dir":"Articles","previous_headings":"Reading a switch","what":"Pins and Identifiers","title":"How to write GPIO Code with rpigpiodr and R","text":"bottom picture Raspberry Pi. Along top two rows pins expose GPIO. several ways identify pins: Physical/Board - identification scheme used rpigpior. number pin board. Pin 1 inner (lower) left side. Pin 2 outer (upper) left side. Pin 40 outer right side. diagram, ’ll see yellow wire connected. BCM - signal found Broadcom chip (BCM2835 others) used power GPIO. example, Board pin 5 (third pin left lower (inside) row) connected BCM signal line 3. ’ll often see referred GPIO03. Yes, confusing, make sense understand designers . Wiring Pi - system written admirers Arduino. Wiring Pi popular among C programming crowd. don’t use rpigpior.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"schematics","dir":"Articles","previous_headings":"Reading a switch","what":"Schematics","title":"How to write GPIO Code with rpigpiodr and R","text":"top illustration white box grid dots. called breadboard exactly look like. top bottom two horizontal rows (four rows total). holes horizontal row electrically connected together. called rails. attach five volts top right corner hole, read five volts top left corner. middle two grids separated gutter. grid five rows thirty columns. holes column connected - across grid. attached five volts first column, first row, read five volts first column, fifth row. Breadboards used wires, resistors, capacitors, switches, lights, microcircuits (transistors) quickly prototype electrical circuits. case, switch connected Raspberry Pi yellow red wire.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"connect-a-switch-to-the-raspberry-pi","dir":"Articles","previous_headings":"Reading a switch","what":"Connect a switch to the Raspberry Pi","title":"How to write GPIO Code with rpigpiodr and R","text":"illustration shows connect pushbutton Raspberry Pi. case, red wire connects board pin 17 one side pushbutton. Board pin 17 supplies 3.3 volts DC. yellow wire connects board pin 40 side pushbutton. Board pin 40 connects Broadcom microcircuit exposes GPIO21. allows Raspberry Pi read state pushbutton.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"programming","dir":"Articles","previous_headings":"","what":"Programming","title":"How to write GPIO Code with rpigpiodr and R","text":"Consider code: pass () loop, program read state board pin 40 rpi_get(40). button pushed, print(\"Button Pushed\"). pin 40 pushed, print(\"Button pushed\")","code":"library(rpigpior) while (TRUE) { if (rpi_get(40)) { print(\"Button pushed\") } else { print(\"Button not pushed\") } }"},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"setting-a-pin","dir":"Articles","previous_headings":"","what":"Setting a pin","title":"How to write GPIO Code with rpigpiodr and R","text":"Now consider new illustration, adds previous circuit. sorts new things happening. red wire connects board pin 17 lowest rail. supplies 3.3 volts. black wire connects board pin 14 next lowest rail. supplies ground. wiring switch electrically previous illustration: yellow wire connects one side switch board pin 40 () red wire connects 3.3 volt rail side switch. LED (Light Emitting Diode) added breadboard. black wire connects top rail (ground) cathode LED. 220 ohm resistor connected anode LED. connected via green wire board pin 3.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"code-to-blink-an-led","dir":"Articles","previous_headings":"","what":"Code to blink an LED","title":"How to write GPIO Code with rpigpiodr and R","text":"Given circuit, code blink LED Notice addition rpi_set(3,1). tells Raspberry Pi turn board pin 3 . rpi_set(3,0) tells Raspberry Pi turn board pin 3 . loop reads state switch rpi_get(40). button pushed, LED attached pin 3 blink; 1 second , 3 seconds .","code":"library(rpigpior) while (TRUE) { if (rpi_get(40)) { rpi_set(3,1) Sys.sleep(1) rpi_set(3,0) Sys.sleep(3) } }"},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"hello-world","dir":"Articles","previous_headings":"","what":"hello world","title":"How to write GPIO Code with rpigpiodr and R","text":", Raspberry Pi equivalent hello world program. ’ve just learned: wire simple Raspberry Pi circuit switch LED. use R programming language control LED based Raspberry Pi","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"how-to-set-up-r-for-a-raspberry-pi","dir":"Articles","previous_headings":"","what":"How to set up R for a Raspberry Pi","title":"How to Setup R on Raspberry Pi","text":"document describes set R programming language Raspberry Pi.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"a-brief-overview-of-the-raspberry-pi","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"A brief overview of the Raspberry Pi","title":"How to Setup R on Raspberry Pi","text":"Raspberry Pi Model 4 Hopefully really isn’t necessary, may wonder ’s fuss Raspberry Pi. ’s tidbits get started: ’s full-blown Linux computer, supports HDMI, ethernet, audio, camera, USB runs five volts DC. consumes somewhere around 3 6 watts. See dual rows pins? ’s General Purpose Input/Output (GPIO) pins. can read write outside world, plus support wide array sensors. lots support programming Python Depending model need, get hands Raspberry Pi somewhere $5 $45 USD.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"install-r","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Install R","title":"How to Setup R on Raspberry Pi","text":"Raspberry Pi doesn’t come R ’ll need install . might want check R4Pi, website provides precompiled binaries. R4Pi website isn’t running, simply fall back apt-get… Unfortunately, installs R Root, cause problems install.packages( ) since don’t access library folder. fixed Raspberry Pi, didn’t take notes . figure , ’ll update document. apologies.","code":"sudo apt-get update sudo apt-get install r-base r-base-core"},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"fix-the-app-menu","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Fix the App Menu","title":"How to Setup R on Raspberry Pi","text":"Unfortunately, installer places R graphic menu instead programming tools. R appears graphic menu works, ’s just annoying. move programming menu: Go RPi menu (Raspberry Pi upper left). Select Preferences Select Main Menu Editor. provides dialog. dialog, select programming. right, select New Item: dialog, fill fields : Name=R Command=R Launch terminal. OK Presto change-O. R now programming menu.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"fix-the-icon","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Fix the Icon","title":"How to Setup R on Raspberry Pi","text":"Almost done trivial stuff, Icon R app wrong. Let’s fix … Raspberry Pi menu, right click R. Choose Properties Click Icon bring chooser System Theme, select rlogo.icon","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"setup-geany","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Setup Geany","title":"How to Setup R on Raspberry Pi","text":"Apparently posit working version RStudio Raspberry Pi. creation document, ’s ready prime time. use Geany instead - ’s installed Raspberry Pi, ’s IDE, ’s better poke eye. Configuring geany R things set using Geany R. learned Geany documentation: https://wiki.geany.org/howtos/using_geany_with_r https://wiki.geany.org/howtos/configurebuildmenu Start edit -> preferences -> terminal check execute programs VTE. runs R Geany terminal rather opening separate terminal window. isn’t necessary, just nice--. Next Build -> Set Build Commands opens dialog. Enter Rscript ./%f Execute : Command. setup, run R program selecting Build -> Execute. Graphs output saved next input file. dialog, go first row. Click cell Label enter something descriptive like “R CMD.” next cell (COMMAND) enter R CMD BATCH ./f . command now appears top Build menu. Selecting option run command, capturing STDOUT xxx.Rout file. Note file names spaces.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"install-libgpiod","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Install libgpiod","title":"How to Setup R on Raspberry Pi","text":"Current versions Raspbian libgpiod installed default. get errors, use install necessary files:","code":"sudo apt-get update sudo apt-get install libgpiod-dev gpiod"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"about-i2c-on-raspberry-pi","dir":"Articles","previous_headings":"","what":"About I2C on Raspberry Pi","title":"rpi_i2c","text":"Inter-Integrated Circuit Communication Uses Serial Data Line (SDA, board pin 3) Serial Clock Line (SCL, board pin 5) RPI two hardware i2c buses. Software buses can also created","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"installing-i2c","dir":"Articles","previous_headings":"","what":"Installing I2C","title":"rpi_i2c","text":"Requires turning i2c Raspi-config use i2cdetect -y 1 show devices connected i2c bus","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"i2c-tools","dir":"Articles","previous_headings":"","what":"i2c-tools","title":"rpi_i2c","text":"i2c-tools already installed Raspberry Pi Operating System i2cset set one byte i2cget get one byte i2cdump i2cdetect -y 1 i2ctransfer send/receive multiple bytes https://github.com/epsylon3/android_external_i2c-tools/tree/gingerbread/tools","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"handling-errors","dir":"Articles","previous_headings":"i2c-tools","what":"Handling Errors:","title":"rpi_i2c","text":"stop(“must specify chip_address integer 0x08 0x77”) stop(“must specify data_address integer 0x00 0xFF”) i2cdetect command results error either installed i2c-tools need use 0 rather 1 device detected don’t see address either connected device properly correctly enabled i2c interface","code":""},{"path":[]},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"hardware-pwm-vs-software-pwm","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Hardware PWM vs Software PWM","title":"Raspberry Pi and PWM","text":"Raspberry Pi exposes two PWM channels Broadcom chip. appear lines also supply GPIO connections Broadcom ALT functions need called. PWM0 appears board pins 12 (GPIO18) 32 (GPIO12). PWM1 appears board pins 33 (GPIO13) 35 (GPIO19). causes confusing situation two ways: Don’t confuse board pin 12 GPIO12 (board pin 32). connected BCM PWM0 want use two PWM channels, certain combinations pins provide two channels. combinations board pins (12,33), (32,33), (12,35), (32,35) rpi_pwm() handles issues. stick board pin numbers, work . go astray, rpi_pwm() stop warn . Raspberry Pi analog audio output uses PWM channels. can’t use hardware PWM audio output time. Although possible create software PWM, isn’t advised due latency linux R. rpigpior supply software PWM channels.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"enabling-hardware-pwm-on-the-raspberry-pi","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Enabling hardware PWM on the Raspberry Pi","title":"Raspberry Pi and PWM","text":"Raspberry Pi OS uses device tree enable hardware PWM. ’ll need bit behind--scenes editing set . , edit /boot/config.txt root. Raspberry Pi, open terminal window Use command sudo nano /boot/config.txt. open nano text editor display contents /boot/config.txt. Add dtoverlay command end file. easiest way determine command add /boot/config.txt ask rpi_pwm() help. Set pwm_debug=TRUE select pins want use. aren’t enabled, rpi_pwm() stop provide correct dtoverlay string. looks something like dtoverlay=pwm,pin18,func-2 change depending pins chosen. want math , excellent guide available github.com/dotnet. also linux documentation discusses Enabling one PWM channel Enabling dual pwm channel Use control-o write file, control-x exit nano Reboot Raspberry Pi enact change. Note rebuild SD card reinstall Raspberry Pi OS OS card, ’ll need repeat step.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"how-to-use-rpi_pwm","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"How to use rpi_pwm()","title":"Raspberry Pi and PWM","text":"’s example: …","code":"rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 25000) # This will enable PWM0 and PWM1 with a period (frequency) of 50000 and a duty cycle of 25000. That is to say, 50% power. rpi_pwm(12, pwm_period = 50000, pwm_dutycycle = 10000) # This will turn PWM0 down to 20%"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"handling-errors","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Handling Errors:","title":"Raspberry Pi and PWM","text":"set pwm_debug = TRUE rpi_pwm() run diagnostics goes.","code":"rpi_pwm(12, pwm_period = 50000, pwm_dutycycle = 10000, pwm_debug = TRUE)"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"invalid-pwm-pin","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"Invalid PWM pin:","title":"Raspberry Pi and PWM","text":"’ve called rpi_pwm(pin_number) pin (pins) specified don’t supply hardware Pulse Width Modulation. Raspberry Pi, board pins 12, 32, 33, 35. Keep mind rpi_pwm() specifies pins board pins - GPIO BCM pins. Lots documentation refer pin numbering schemes.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"invalid-pwm-pin-combination","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"Invalid PWM pin combination:","title":"Raspberry Pi and PWM","text":"know now, Raspberry Pi two hardware PWM channels, channel connected two pins: PWM0 appears board pins 12 (GPIO18) 32 (GPIO12). PWM1 appears board pins 33 (GPIO13) 35 (GPIO19). …going use two PWM channels, need use pins connected different channels. Since board pin 12 32 connected PWM0, nonsense use rpi_pwm(pin_number = c(12,32). Instead, valid combinations: rpi_pwm(pin_number = c(12,33) rpi_pwm(pin_number = c(12,35) rpi_pwm(pin_number = c(32,33) rpi_pwm(pin_number = c(32,35) try select invalid combination pwm_debut = TRUE receive error.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"pwm-not-enabled","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"PWM not enabled:","title":"Raspberry Pi and PWM","text":"PWM channel (channels) selected yet enabled. Enabling PWM described section titled Enabling hardware PWM Raspberry Pi . error message rpi_pwm supplies string ’ll need paste /boot/config.txt.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"notes","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Notes:","title":"Raspberry Pi and PWM","text":"Linux driver implementer’s API guide chapter PWM : https://www.kernel.org/doc/html/v5.10/driver-api/pwm.html","code":""},{"path":"https://mnr.github.io/rpigpior/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Mark Niemann-Ross. Author, maintainer, copyright holder.","code":""},{"path":"https://mnr.github.io/rpigpior/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Niemann-Ross M (2024). rpigpior: Provides R Access Raspberry Pi. R package version 0.1.0, https://mnr.github.io/rpigpior/, https://github.com/mnr/rpigpior.","code":"@Manual{, title = {rpigpior: Provides R with Access to the Raspberry Pi}, author = {Mark Niemann-Ross}, year = {2024}, note = {R package version 0.1.0, https://mnr.github.io/rpigpior/}, url = {https://github.com/mnr/rpigpior}, }"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"rpigpior","dir":"","previous_headings":"","what":"Provides R with Access to the Raspberry Pi","title":"Provides R with Access to the Raspberry Pi","text":"rpigpior allows R programming language access Raspberry Pi GPIO using libgpiod. libgpiod already included Raspbian, nothing else install. rpigpior provides tools: .rpi - Returns TRUE code running Raspbian rpi_get - Returns value board level pin (1-40) error pin isn’t data line (3.3v, 5v, GROUND) rpi_set - Sets pin rpi_monitor - watches pin number rising falling events rpi_pwm - provides diagnostics support hardware pulse width modulation rpi_i2c_get - retrieve value i2c connection rpi_i2c_set - set i2c register value","code":""},{"path":"https://mnr.github.io/rpigpior/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Provides R with Access to the Raspberry Pi","text":"rpigpior hosted github. arrives cran, can install development version rpigpior GitHub : documentation tell use devtools, install.packages(\"devtools\") Raspberry Pi onerous task. However…installed R Raspberry Pi using r4pi, can use devtools just like normal. ’ve installed, use library just like R package:","code":"library(remotes) remotes::install_github(\"mnr/rpigpior\") # Start R with \"sudo R\" to install packages # install.packages(\"devtools\") # You might want to switch back to non-admin R library(devtools) #> Loading required package: usethis install_github(\"mnr/rpigpior\") #> Downloading GitHub repo mnr/rpigpior@HEAD #> ── R CMD build ───────────────────────────────────────────────────────────────── #> checking for file ‘/private/var/folders/sw/tfbr78mn7knfkl4ll9tx40m80000gn/T/Rtmp1oLMSF/remotes5f2e65f6eb16/mnr-rpigpior-58b1907/DESCRIPTION’ ... ✔ checking for file ‘/private/var/folders/sw/tfbr78mn7knfkl4ll9tx40m80000gn/T/Rtmp1oLMSF/remotes5f2e65f6eb16/mnr-rpigpior-58b1907/DESCRIPTION’ #> ─ preparing ‘rpigpior’: #> checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information #> ─ checking for LF line-endings in source and make files and shell scripts #> ─ checking for empty or unneeded directories #> ─ building ‘rpigpior_0.1.0.tar.gz’ #> #> library(rpigpior)"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"is-this-a-raspberry-pi","dir":"","previous_headings":"","what":"Is this a Raspberry Pi?","title":"Provides R with Access to the Raspberry Pi","text":"’s helpful check code running Raspberry Pi.","code":"if ( is.rpi() ) { print(\"Yes, this is a RPi\") } else { print (\"No, this is not a RPi\") }"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"reading-a-pin","dir":"","previous_headings":"","what":"Reading a pin","title":"Provides R with Access to the Raspberry Pi","text":"connect switch board pin 40, code read : assumes switch board pin 40 “pushed” closed. way, diagram located articles section website (identified package description)","code":"library(rpigpior) rpi_get(40) # reads board pin 40 rpi_get(c(7,40)) # reads board pins 7 and 40 > GPIO004 GPIO21 0 1"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"turning-pins-on-and-off","dir":"","previous_headings":"","what":"Turning pins on and off","title":"Provides R with Access to the Raspberry Pi","text":"LEDs connected board pin 19, 21, 23, code turn , one , ","code":"library(rpigpior) toggleThese <- c(19,21,23) rpi_set(toggleThese,1) Sys.sleep(1) rpi_set(toggleThese, c(1,0,1)) Sys.sleep(1) rpi_set(toggleThese, 0)"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"related-notes","dir":"","previous_headings":"","what":"Related notes:","title":"Provides R with Access to the Raspberry Pi","text":"Related mailing list: linux-gpio@vger.kernal.org","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":null,"dir":"Reference","previous_headings":"","what":"Provide information about the Operating System — is.rpi","title":"Provide information about the Operating System — is.rpi","text":"Returns TRUE code running Raspbian return information operating system.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Provide information about the Operating System — is.rpi","text":"","code":"is.rpi(onlyThis = \"IsThisRPI\")"},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Provide information about the Operating System — is.rpi","text":"onlyThis value passed onlyThis, .rpi() return logical 'onlyThis' specified, '.rpi()' return value field /etc/os-release. typical values found os-release PRETTY_NAME concatenation NAME, VERSION_ID, VERSION NAME name OS, typically \"Raspbian GNU/LINUX\" VERSION_ID version. Currently = 11 VERSION concatenation VERSION_ID (VERSION_CODENAME) VERSION_CODENAME OS Name. Currently = \"bullseye\" ID OS. Currently = \"raspbian\" ID_LIKE OS base. Currently = \"debian\" HOME_URL Currently = \"http://www.raspbian.org\" SUPPORT_URL Currently = \"http://www.raspbian.org/RaspbianForums\" BUG_REPORT Currently = \"http://www.raspbian.org/RaspbianBugs\"","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Provide information about the Operating System — is.rpi","text":"`onlyThis` specified, returns value. Otherwise returns TRUE running Raspbian","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Provide information about the Operating System — is.rpi","text":"","code":"if (FALSE) { # is.rpi() is.rpi() is.rpi(\"NAME\") }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve the value of a RPi Pin — rpi_get","title":"Retrieve the value of a RPi Pin — rpi_get","text":"Returns value one specified board-level pin number (0-40). Stops pin valid data line.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve the value of a RPi Pin — rpi_get","text":"","code":"rpi_get(pin_number)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve the value of a RPi Pin — rpi_get","text":"pin_number Raspberry Pi GPIO board level pin number 1 40. example, Pin #1 located upper left provides 3.3 volts. Pin #40 located lower right location GPIO21.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve the value of a RPi Pin — rpi_get","text":"named vector value pin number.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve the value of a RPi Pin — rpi_get","text":"","code":"if (FALSE) { # is.rpi() if (FALSE) rpi_get(1) # produces error since pin #1 is not data rpi_get(40) # returns a named vector of the state of GPIO21. i.e. return[\"GPIO21\"] = 1 rpi_get(c(7, 40)) # returns a named vector of values from pins 7 and 40 }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Return a byte from an i2c device — rpi_i2c_get","title":"Return a byte from an i2c device — rpi_i2c_get","text":"Return byte i2c device","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return a byte from an i2c device — rpi_i2c_get","text":"","code":"rpi_i2c_get(chip_address, data_address, data_size = \"b\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return a byte from an i2c device — rpi_i2c_get","text":"chip_address integer 0x03 0x77. Use i2cdetect -y 1 identify address data_address integer 0x00 0xFF. come chip documentation data_size read byte (b) word (w) data_address","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return a byte from an i2c device — rpi_i2c_get","text":"data i2c device located chip_address data_address","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return a byte from an i2c device — rpi_i2c_get","text":"","code":"if (FALSE) { # is.rpi() #' # get a byte from an i2c device located at 0x77 rpi_i2c_get(chip_address = 0x77, data_address = 0xfa, data_size = 'b') }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Write data to an i2c device — rpi_i2c_set","title":"Write data to an i2c device — rpi_i2c_set","text":"Writes byte, word, data block i2c device.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write data to an i2c device — rpi_i2c_set","text":"","code":"rpi_i2c_set(chip_address, data_address, value, data_size = \"b\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write data to an i2c device — rpi_i2c_set","text":"chip_address integer 0x03 0x77. Use i2cdetect -y 1 identify address data_address integer 0x00 0xFF. come chip documentation value byte (0xff), word (0xffff), SMBus (32 bytes) I2C Block data_size data_size must one \"b\", \"w\", \"s\", \"\"","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write data to an i2c device — rpi_i2c_set","text":"void","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write data to an i2c device — rpi_i2c_set","text":"","code":"if (FALSE) { # is.rpi() }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":null,"dir":"Reference","previous_headings":"","what":"Monitor an RPi pin — rpi_monitor","title":"Monitor an RPi pin — rpi_monitor","text":"Watch Raspberry pi GPIO pin (pins) changes.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Monitor an RPi pin — rpi_monitor","text":"","code":"rpi_monitor(pin_number, numEvents = 0, edge = \"both\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Monitor an RPi pin — rpi_monitor","text":"pin_number one pin numbers found Raspberry pi GPIO. Use actual pin numbers (.e. 1:40) numEvents number events collect. Defaults 10 edge rising|falling|","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Monitor an RPi pin — rpi_monitor","text":"list events raw text event event: RISING EDGE|FALLING EDGE line: bcm line (board pin) exhibiting change timestamp: seconds component timestamp: nanoseconds component","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Monitor an RPi pin — rpi_monitor","text":"","code":"if (FALSE) { # is.rpi() # \\donttest{ rpi_monitor(21) rpi_monitor(21, numEvents=20) # } }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":null,"dir":"Reference","previous_headings":"","what":"Converts a RPi pin number to BCM line — rpi_pinToBCM","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"Look board pin number return BCM_line line_name Pin number physical board Raspberry pi.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"","code":"rpi_pinToBCM(pin_number)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"pin_number pin found Raspberry Pi board. Numbered 1 40.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"named vector. bcm_line = broadcom line connected pin pin_name = broadcom name RXD1 GPIO21","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"checks valid range pins (1:40) valid input/output lines. prevents trying read 3.3v ground line.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"","code":"if (FALSE) { # is.rpi() rpi_pinToBCM(1) # produces error since pin #1 is not data rpi_pinToBCM(40) # returns a named vector where bcm_line = 21 and pin_name = GPIO21 }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":null,"dir":"Reference","previous_headings":"","what":"Raspberry Pi Pins — rpi_pin_desc","title":"Raspberry Pi Pins — rpi_pin_desc","text":"board-level description 40 GPIO pins found Raspberry Pi. different wiring pi BCM numbering schemes. Instead, reflects function pins physical location board.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Raspberry Pi Pins — rpi_pin_desc","text":"","code":"rpi_pin_desc"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Raspberry Pi Pins — rpi_pin_desc","text":"## `rpi_pin_desc` data frame 40 rows two columns: description. Primary function pin secondary. Secondary function pin valid_PWM_pair_1, valid_PWM_pair_2. Used rpi_pwm() determine valid PWM pins channel combinations. PWM_channel. Unambiguously relates PWM channel board pin","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Raspberry Pi Pins — rpi_pin_desc","text":"https://www.raspberrypi.com/documentation/computers/os.html#gpio---40-pin-header","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":null,"dir":"Reference","previous_headings":"","what":"Provide R with access to PWM — rpi_pwm","title":"Provide R with access to PWM — rpi_pwm","text":"Provides R programming language access Raspberry Pi hardware Pulse Width Modulation (PWM)","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Provide R with access to PWM — rpi_pwm","text":"","code":"rpi_pwm( pin_number = 12, pwm_period = 50000, pwm_dutycycle = 25000, pwm_debug = FALSE )"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Provide R with access to PWM — rpi_pwm","text":"pin_number One two pins hardware PWM. Must 12, 32, 33, 35. two pins selected, must one combinations: (12,33), (32,33), (12,35), (32,35) pwm_period length cycle. aka Frequency. 15 greater, less 1000000 pwm_dutycycle amount time cycle . pwm_debug TRUE, checks Raspberry Pi OS settings PWM provides diagnostics","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Provide R with access to PWM — rpi_pwm","text":"void `rpi_pwm()` provides extensive error checking. Possible errors include: Invalid PWM pin: Hardware PWM supplied pins 12, 32, 33, 35. Invalid PWM pin combination: combination pins select PWM0 PWM1 PWM enabled: PWM channel enabled (see https://mnr.github.io/rpigpior/articles/rpi_pwm.html fixing errors)","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Provide R with access to PWM — rpi_pwm","text":"two PWM lines available Raspberry Pi - pwm0 pwm1. Although possible create software PWM, advised due latency linux R. might helpful read article `rpi_pwm()` located [rpigpior website](https://mnr.github.io/rpigpior/articles/rpi_pwm.html).","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Provide R with access to PWM — rpi_pwm","text":"","code":"if (FALSE) { # is.rpi() rpi_pwm(12) # provides 50% PWM to pin 12 (PWM0) #' # provides 20% PWM to pin 12 (PWM0) and pin 33 (PWM1) rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 10000) }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Turn lines on or off — rpi_set","title":"Turn lines on or off — rpi_set","text":"Turn lines ","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Turn lines on or off — rpi_set","text":"","code":"rpi_set(pin_number, onOff)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Turn lines on or off — rpi_set","text":"pin_number one pin numbers found Raspberry pi GPIO. Use actual pin numbers (.e. 1:40) onOff vector length pin_number values 0 1 turn line ","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Turn lines on or off — rpi_set","text":"value returned","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Turn lines on or off — rpi_set","text":"","code":"if (FALSE) { # is.rpi() # turns pin 19 on, 21 off, and 23 on. # This corresponds to gpio09, gpio10, and gpio11 rpi_set(pin_number = c(19, 21, 23), onOff = c(1,0,1)) toggleThesePins <- c(19,21,23) rpi_set(toggleThesePins, 1) # turns all three pins on. onOff is recycled Sys.sleep(1) rpi_set(toggleThesePins, c(0,1,0)) # turns off pins 19 and 23 Sys.sleep(1) rpi_set(toggleThesePins, 0) # turns off all pins }"},{"path":"https://mnr.github.io/rpigpior/reference/rpigpior-package.html","id":null,"dir":"Reference","previous_headings":"","what":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","title":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","text":"provides R access Raspberry Pi General Purpose Input Output (GPIO) via 'libgpiod'. includes detecting gpio chip well turning pins via [gpioset()] reading state pins via [gpioget()]. additional libraries need installed; Raspbian includes 'libgpiod' part standard installation.","code":""},{"path":[]},{"path":"https://mnr.github.io/rpigpior/reference/rpigpior-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","text":"Maintainer: Mark Niemann-Ross mark@niemannross.com (ORCID) [copyright holder]","code":""},{"path":"https://mnr.github.io/rpigpior/news/index.html","id":"rpigpior-010","dir":"Changelog","previous_headings":"","what":"rpigpior 0.1.0","title":"rpigpior 0.1.0","text":"rpi_i2c_get() rpi_i2c_set() rpi_pwm() rpi_monitor() rpi_set() rpi_get() rpi_pinToBCM() is_rpi() Added NEWS.md file track changes package.","code":""}] +[{"path":"https://mnr.github.io/rpigpior/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 rpigpior authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"understanding-gpio","dir":"Articles","previous_headings":"","what":"Understanding GPIO","title":"How to write GPIO Code with rpigpiodr and R","text":"GPIO stands General Purpose Input/Output. can “see” Raspberry Pi; ’s dual row pins along one edge. two rows twenty pins total forty pins. GPIO pins can deliver 3.3 volts direct current (DC), 5 volts DC, ground, multipurpose input output pins. pins also deliver specialty functions I2C, SPI, UART, 1-wire, PWM. don’t pay attention pin functions connect things GPIO, zap Raspberry Pi. ’s bad thing.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"gpio-implies-connecting-wires","dir":"Articles","previous_headings":"","what":"GPIO implies connecting wires","title":"How to write GPIO Code with rpigpiodr and R","text":"stray world Raspberry Pi, ’s intent connect sensors devices GPIO pins. implies circuits wires. can show , assume already gone excellent tutorials Raspberry Pi foundation places LinkedIn Learning.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"reading-a-switch","dir":"Articles","previous_headings":"","what":"Reading a switch","title":"How to write GPIO Code with rpigpiodr and R","text":"Let’s talk illustration. Connecting switch Raspberry Pi","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"pins-and-identifiers","dir":"Articles","previous_headings":"Reading a switch","what":"Pins and Identifiers","title":"How to write GPIO Code with rpigpiodr and R","text":"bottom picture Raspberry Pi. Along top two rows pins expose GPIO. several ways identify pins: Physical/Board - identification scheme used rpigpior. number pin board. Pin 1 inner (lower) left side. Pin 2 outer (upper) left side. Pin 40 outer right side. diagram, ’ll see yellow wire connected. BCM - signal found Broadcom chip (BCM2835 others) used power GPIO. example, Board pin 5 (third pin left lower (inside) row) connected BCM signal line 3. ’ll often see referred GPIO03. Yes, confusing, make sense understand designers . Wiring Pi - system written admirers Arduino. Wiring Pi popular among C programming crowd. don’t use rpigpior.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"schematics","dir":"Articles","previous_headings":"Reading a switch","what":"Schematics","title":"How to write GPIO Code with rpigpiodr and R","text":"top illustration white box grid dots. called breadboard exactly look like. top bottom two horizontal rows (four rows total). holes horizontal row electrically connected together. called rails. attach five volts top right corner hole, read five volts top left corner. middle two grids separated gutter. grid five rows thirty columns. holes column connected - across grid. attached five volts first column, first row, read five volts first column, fifth row. Breadboards used wires, resistors, capacitors, switches, lights, microcircuits (transistors) quickly prototype electrical circuits. case, switch connected Raspberry Pi yellow red wire.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"connect-a-switch-to-the-raspberry-pi","dir":"Articles","previous_headings":"Reading a switch","what":"Connect a switch to the Raspberry Pi","title":"How to write GPIO Code with rpigpiodr and R","text":"illustration shows connect pushbutton Raspberry Pi. case, red wire connects board pin 17 one side pushbutton. Board pin 17 supplies 3.3 volts DC. yellow wire connects board pin 40 side pushbutton. Board pin 40 connects Broadcom microcircuit exposes GPIO21. allows Raspberry Pi read state pushbutton.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"programming","dir":"Articles","previous_headings":"","what":"Programming","title":"How to write GPIO Code with rpigpiodr and R","text":"Consider code: pass () loop, program read state board pin 40 rpi_get(40). button pushed, print(\"Button Pushed\"). pin 40 pushed, print(\"Button pushed\")","code":"library(rpigpior) while (TRUE) { if (rpi_get(40)) { print(\"Button pushed\") } else { print(\"Button not pushed\") } }"},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"setting-a-pin","dir":"Articles","previous_headings":"","what":"Setting a pin","title":"How to write GPIO Code with rpigpiodr and R","text":"Now consider new illustration, adds previous circuit. sorts new things happening. red wire connects board pin 17 lowest rail. supplies 3.3 volts. black wire connects board pin 14 next lowest rail. supplies ground. wiring switch electrically previous illustration: yellow wire connects one side switch board pin 40 () red wire connects 3.3 volt rail side switch. LED (Light Emitting Diode) added breadboard. black wire connects top rail (ground) cathode LED. 220 ohm resistor connected anode LED. connected via green wire board pin 3.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"code-to-blink-an-led","dir":"Articles","previous_headings":"","what":"Code to blink an LED","title":"How to write GPIO Code with rpigpiodr and R","text":"Given circuit, code blink LED Notice addition rpi_set(3,1). tells Raspberry Pi turn board pin 3 . rpi_set(3,0) tells Raspberry Pi turn board pin 3 . loop reads state switch rpi_get(40). button pushed, LED attached pin 3 blink; 1 second , 3 seconds .","code":"library(rpigpior) while (TRUE) { if (rpi_get(40)) { rpi_set(3,1) Sys.sleep(1) rpi_set(3,0) Sys.sleep(3) } }"},{"path":"https://mnr.github.io/rpigpior/articles/gpioCode.html","id":"hello-world","dir":"Articles","previous_headings":"","what":"hello world","title":"How to write GPIO Code with rpigpiodr and R","text":", Raspberry Pi equivalent hello world program. ’ve just learned: wire simple Raspberry Pi circuit switch LED. use R programming language control LED based Raspberry Pi","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"how-to-set-up-r-for-a-raspberry-pi","dir":"Articles","previous_headings":"","what":"How to set up R for a Raspberry Pi","title":"How to Setup R on Raspberry Pi","text":"document describes set R programming language Raspberry Pi.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"a-brief-overview-of-the-raspberry-pi","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"A brief overview of the Raspberry Pi","title":"How to Setup R on Raspberry Pi","text":"Raspberry Pi Model 4 Hopefully really isn’t necessary, may wonder ’s fuss Raspberry Pi. ’s tidbits get started: ’s full-blown Linux computer, supports HDMI, ethernet, audio, camera, USB runs five volts DC. consumes somewhere around 3 6 watts. See dual rows pins? ’s General Purpose Input/Output (GPIO) pins. can read write outside world, plus support wide array sensors. lots support programming Python Depending model need, get hands Raspberry Pi somewhere $5 $45 USD.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"install-r","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Install R","title":"How to Setup R on Raspberry Pi","text":"Raspberry Pi doesn’t come R ’ll need install . might want check R4Pi, website provides precompiled binaries. R4Pi website isn’t running, simply fall back apt-get… Unfortunately, installs R Root, cause problems install.packages( ) since don’t access library folder. fixed Raspberry Pi, didn’t take notes . figure , ’ll update document. apologies.","code":"sudo apt-get update sudo apt-get install r-base r-base-core"},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"fix-the-app-menu","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Fix the App Menu","title":"How to Setup R on Raspberry Pi","text":"Unfortunately, installer places R graphic menu instead programming tools. R appears graphic menu works, ’s just annoying. move programming menu: Go RPi menu (Raspberry Pi upper left). Select Preferences Select Main Menu Editor. provides dialog. dialog, select programming. right, select New Item: dialog, fill fields : Name=R Command=R Launch terminal. OK Presto change-O. R now programming menu.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"fix-the-icon","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Fix the Icon","title":"How to Setup R on Raspberry Pi","text":"Almost done trivial stuff, Icon R app wrong. Let’s fix … Raspberry Pi menu, right click R. Choose Properties Click Icon bring chooser System Theme, select rlogo.icon","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"setup-geany","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Setup Geany","title":"How to Setup R on Raspberry Pi","text":"Apparently posit working version RStudio Raspberry Pi. creation document, ’s ready prime time. use Geany instead - ’s installed Raspberry Pi, ’s IDE, ’s better poke eye. Configuring geany R things set using Geany R. learned Geany documentation: https://wiki.geany.org/howtos/using_geany_with_r https://wiki.geany.org/howtos/configurebuildmenu Start edit -> preferences -> terminal check execute programs VTE. runs R Geany terminal rather opening separate terminal window. isn’t necessary, just nice--. Next Build -> Set Build Commands opens dialog. Enter Rscript ./%f Execute : Command. setup, run R program selecting Build -> Execute. Graphs output saved next input file. dialog, go first row. Click cell Label enter something descriptive like “R CMD.” next cell (COMMAND) enter R CMD BATCH ./f . command now appears top Build menu. Selecting option run command, capturing STDOUT xxx.Rout file. Note file names spaces.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/how-to-RPi.html","id":"install-libgpiod","dir":"Articles","previous_headings":"How to set up R for a Raspberry Pi","what":"Install libgpiod","title":"How to Setup R on Raspberry Pi","text":"Current versions Raspbian libgpiod installed default. get errors, use install necessary files:","code":"sudo apt-get update sudo apt-get install libgpiod-dev gpiod"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"about-i2c-on-raspberry-pi","dir":"Articles","previous_headings":"","what":"About I2C on Raspberry Pi","title":"rpi_i2c","text":"Inter-Integrated Circuit Communication Uses Serial Data Line (SDA, board pin 3) Serial Clock Line (SCL, board pin 5) RPI two hardware i2c buses. Software buses can also created","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"installing-i2c","dir":"Articles","previous_headings":"","what":"Installing I2C","title":"rpi_i2c","text":"Requires turning i2c Raspi-config use i2cdetect -y 1 show devices connected i2c bus","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"i2c-tools","dir":"Articles","previous_headings":"","what":"i2c-tools","title":"rpi_i2c","text":"i2c-tools already installed Raspberry Pi Operating System i2cset set one byte i2cget get one byte i2cdump i2cdetect -y 1 i2ctransfer send/receive multiple bytes https://github.com/epsylon3/android_external_i2c-tools/tree/gingerbread/tools","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_i2c.html","id":"handling-errors","dir":"Articles","previous_headings":"i2c-tools","what":"Handling Errors:","title":"rpi_i2c","text":"stop(“must specify chip_address integer 0x08 0x77”) stop(“must specify data_address integer 0x00 0xFF”) i2cdetect command results error either installed i2c-tools need use 0 rather 1 device detected don’t see address either connected device properly correctly enabled i2c interface","code":""},{"path":[]},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"hardware-pwm-vs-software-pwm","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Hardware PWM vs Software PWM","title":"Raspberry Pi and PWM","text":"Raspberry Pi exposes two PWM channels Broadcom chip. appear lines also supply GPIO connections Broadcom ALT functions need called. PWM0 appears board pins 12 (GPIO18) 32 (GPIO12). PWM1 appears board pins 33 (GPIO13) 35 (GPIO19). causes confusing situation two ways: Don’t confuse board pin 12 GPIO12 (board pin 32). connected BCM PWM0 want use two PWM channels, certain combinations pins provide two channels. combinations board pins (12,33), (32,33), (12,35), (32,35) rpi_pwm() handles issues. stick board pin numbers, work . go astray, rpi_pwm() stop warn . Raspberry Pi analog audio output uses PWM channels. can’t use hardware PWM audio output time. Although possible create software PWM, isn’t advised due latency linux R. rpigpior supply software PWM channels.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"enabling-hardware-pwm-on-the-raspberry-pi","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Enabling hardware PWM on the Raspberry Pi","title":"Raspberry Pi and PWM","text":"Raspberry Pi OS uses device tree enable hardware PWM. ’ll need bit behind--scenes editing set . , edit /boot/config.txt root. Raspberry Pi, open terminal window Use command sudo nano /boot/config.txt. open nano text editor display contents /boot/config.txt. Add dtoverlay command end file. easiest way determine command add /boot/config.txt ask rpi_pwm() help. Set pwm_debug=TRUE select pins want use. aren’t enabled, rpi_pwm() stop provide correct dtoverlay string. looks something like dtoverlay=pwm,pin18,func-2 change depending pins chosen. want math , excellent guide available github.com/dotnet. also linux documentation discusses Enabling one PWM channel Enabling dual pwm channel Use control-o write file, control-x exit nano Reboot Raspberry Pi enact change. Note rebuild SD card reinstall Raspberry Pi OS OS card, ’ll need repeat step.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"how-to-use-rpi_pwm","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"How to use rpi_pwm()","title":"Raspberry Pi and PWM","text":"’s example: …","code":"rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 25000) # This will enable PWM0 and PWM1 with a period (frequency) of 50000 and a duty cycle of 25000. That is to say, 50% power. rpi_pwm(12, pwm_period = 50000, pwm_dutycycle = 10000) # This will turn PWM0 down to 20%"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"handling-errors","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Handling Errors:","title":"Raspberry Pi and PWM","text":"set pwm_debug = TRUE rpi_pwm() run diagnostics goes.","code":"rpi_pwm(12, pwm_period = 50000, pwm_dutycycle = 10000, pwm_debug = TRUE)"},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"invalid-pwm-pin","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"Invalid PWM pin:","title":"Raspberry Pi and PWM","text":"’ve called rpi_pwm(pin_number) pin (pins) specified don’t supply hardware Pulse Width Modulation. Raspberry Pi, board pins 12, 32, 33, 35. Keep mind rpi_pwm() specifies pins board pins - GPIO BCM pins. Lots documentation refer pin numbering schemes.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"invalid-pwm-pin-combination","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"Invalid PWM pin combination:","title":"Raspberry Pi and PWM","text":"know now, Raspberry Pi two hardware PWM channels, channel connected two pins: PWM0 appears board pins 12 (GPIO18) 32 (GPIO12). PWM1 appears board pins 33 (GPIO13) 35 (GPIO19). …going use two PWM channels, need use pins connected different channels. Since board pin 12 32 connected PWM0, nonsense use rpi_pwm(pin_number = c(12,32). Instead, valid combinations: rpi_pwm(pin_number = c(12,33) rpi_pwm(pin_number = c(12,35) rpi_pwm(pin_number = c(32,33) rpi_pwm(pin_number = c(32,35) try select invalid combination pwm_debut = TRUE receive error.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"pwm-not-enabled","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi > Handling Errors:","what":"PWM not enabled:","title":"Raspberry Pi and PWM","text":"PWM channel (channels) selected yet enabled. Enabling PWM described section titled Enabling hardware PWM Raspberry Pi . error message rpi_pwm supplies string ’ll need paste /boot/config.txt.","code":""},{"path":"https://mnr.github.io/rpigpior/articles/rpi_pwm.html","id":"notes","dir":"Articles","previous_headings":"Pulse Width Modulation on the Raspberry Pi","what":"Notes:","title":"Raspberry Pi and PWM","text":"Linux driver implementer’s API guide chapter PWM : https://www.kernel.org/doc/html/v5.10/driver-api/pwm.html","code":""},{"path":"https://mnr.github.io/rpigpior/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Mark Niemann-Ross. Author, maintainer, copyright holder.","code":""},{"path":"https://mnr.github.io/rpigpior/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Niemann-Ross M (2024). rpigpior: Provides R Access Raspberry Pi. R package version 0.1.0, https://mnr.github.io/rpigpior/, https://github.com/mnr/rpigpior.","code":"@Manual{, title = {rpigpior: Provides R with Access to the Raspberry Pi}, author = {Mark Niemann-Ross}, year = {2024}, note = {R package version 0.1.0, https://mnr.github.io/rpigpior/}, url = {https://github.com/mnr/rpigpior}, }"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"rpigpior","dir":"","previous_headings":"","what":"Provides R with Access to the Raspberry Pi","title":"Provides R with Access to the Raspberry Pi","text":"rpigpior allows R programming language access Raspberry Pi GPIO using libgpiod. libgpiod already included Raspbian, nothing else install. rpigpior provides tools: .rpi - Returns TRUE code running Raspbian rpi_get - Returns value board level pin (1-40) error pin isn’t data line (3.3v, 5v, GROUND) rpi_set - Sets pin rpi_monitor - watches pin number rising falling events rpi_pwm - provides diagnostics support hardware pulse width modulation rpi_i2c_get - retrieve value i2c connection rpi_i2c_set - set i2c register value","code":""},{"path":"https://mnr.github.io/rpigpior/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Provides R with Access to the Raspberry Pi","text":"rpigpior hosted github. arrives cran, can install development version rpigpior GitHub : documentation tell use devtools, install.packages(\"devtools\") Raspberry Pi onerous task. However…installed R Raspberry Pi using r4pi, can use devtools just like normal. ’ve installed, use library just like R package:","code":"library(remotes) remotes::install_github(\"mnr/rpigpior\") # Start R with \"sudo R\" to install packages # install.packages(\"devtools\") # You might want to switch back to non-admin R library(devtools) install_github(\"mnr/rpigpior\") library(rpigpior)"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"is-this-a-raspberry-pi","dir":"","previous_headings":"","what":"Is this a Raspberry Pi?","title":"Provides R with Access to the Raspberry Pi","text":"’s helpful check code running Raspberry Pi.","code":"if ( is.rpi() ) { print(\"Yes, this is a RPi\") } else { print (\"No, this is not a RPi\") }"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"reading-a-pin","dir":"","previous_headings":"","what":"Reading a pin","title":"Provides R with Access to the Raspberry Pi","text":"connect switch board pin 40, code read : assumes switch board pin 40 “pushed” closed. way, diagram located articles section website (identified package description)","code":"library(rpigpior) rpi_get(40) # reads board pin 40 rpi_get(c(7,40)) # reads board pins 7 and 40 > GPIO004 GPIO21 0 1"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"turning-pins-on-and-off","dir":"","previous_headings":"","what":"Turning pins on and off","title":"Provides R with Access to the Raspberry Pi","text":"LEDs connected board pin 19, 21, 23, code turn , one , ","code":"library(rpigpior) toggleThese <- c(19,21,23) rpi_set(toggleThese,1) Sys.sleep(1) rpi_set(toggleThese, c(1,0,1)) Sys.sleep(1) rpi_set(toggleThese, 0)"},{"path":"https://mnr.github.io/rpigpior/index.html","id":"related-notes","dir":"","previous_headings":"","what":"Related notes:","title":"Provides R with Access to the Raspberry Pi","text":"Related mailing list: linux-gpio@vger.kernal.org","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":null,"dir":"Reference","previous_headings":"","what":"Provide information about the Operating System — is.rpi","title":"Provide information about the Operating System — is.rpi","text":"Returns TRUE code running Raspbian return information operating system.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Provide information about the Operating System — is.rpi","text":"","code":"is.rpi(onlyThis = \"IsThisRPI\")"},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Provide information about the Operating System — is.rpi","text":"onlyThis value passed onlyThis, .rpi() return logical 'onlyThis' specified, '.rpi()' return value field /etc/os-release. typical values found os-release PRETTY_NAME concatenation NAME, VERSION_ID, VERSION NAME name OS, typically \"Raspbian GNU/LINUX\" VERSION_ID version. Currently = 11 VERSION concatenation VERSION_ID (VERSION_CODENAME) VERSION_CODENAME OS Name. Currently = \"bullseye\" ID OS. Currently = \"raspbian\" ID_LIKE OS base. Currently = \"debian\" HOME_URL Currently = \"http://www.raspbian.org\" SUPPORT_URL Currently = \"http://www.raspbian.org/RaspbianForums\" BUG_REPORT Currently = \"http://www.raspbian.org/RaspbianBugs\"","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Provide information about the Operating System — is.rpi","text":"`onlyThis` specified, returns value. Otherwise returns TRUE running Raspbian","code":""},{"path":"https://mnr.github.io/rpigpior/reference/is.rpi.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Provide information about the Operating System — is.rpi","text":"","code":"if (FALSE) { # is.rpi() is.rpi() is.rpi(\"NAME\") }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve the value of a RPi Pin — rpi_get","title":"Retrieve the value of a RPi Pin — rpi_get","text":"Returns value one specified board-level pin number (0-40). Stops pin valid data line.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve the value of a RPi Pin — rpi_get","text":"","code":"rpi_get(pin_number)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve the value of a RPi Pin — rpi_get","text":"pin_number Raspberry Pi GPIO board level pin number 1 40. example, Pin #1 located upper left provides 3.3 volts. Pin #40 located lower right location GPIO21.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve the value of a RPi Pin — rpi_get","text":"named vector value pin number.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_get.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve the value of a RPi Pin — rpi_get","text":"","code":"if (FALSE) { # is.rpi() if (FALSE) rpi_get(1) # produces error since pin #1 is not data rpi_get(40) # returns a named vector of the state of GPIO21. i.e. return[\"GPIO21\"] = 1 rpi_get(c(7, 40)) # returns a named vector of values from pins 7 and 40 }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":null,"dir":"Reference","previous_headings":"","what":"Return a byte from an i2c device — rpi_i2c_get","title":"Return a byte from an i2c device — rpi_i2c_get","text":"Return byte i2c device","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return a byte from an i2c device — rpi_i2c_get","text":"","code":"rpi_i2c_get(chip_address, data_address, data_size = \"b\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return a byte from an i2c device — rpi_i2c_get","text":"chip_address integer 0x03 0x77. Use i2cdetect -y 1 identify address data_address integer 0x00 0xFF. come chip documentation data_size read byte (b) word (w) data_address","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return a byte from an i2c device — rpi_i2c_get","text":"data i2c device located chip_address data_address","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_get.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return a byte from an i2c device — rpi_i2c_get","text":"","code":"if (FALSE) { # is.rpi() #' # get a byte from an i2c device located at 0x77 rpi_i2c_get(chip_address = 0x77, data_address = 0xfa, data_size = 'b') }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Write data to an i2c device — rpi_i2c_set","title":"Write data to an i2c device — rpi_i2c_set","text":"Writes byte, word, data block i2c device.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write data to an i2c device — rpi_i2c_set","text":"","code":"rpi_i2c_set(chip_address, data_address, value, data_size = \"b\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write data to an i2c device — rpi_i2c_set","text":"chip_address integer 0x03 0x77. Use i2cdetect -y 1 identify address data_address integer 0x00 0xFF. come chip documentation value byte (0xff), word (0xffff), SMBus (32 bytes) I2C Block data_size data_size must one \"b\", \"w\", \"s\", \"\"","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write data to an i2c device — rpi_i2c_set","text":"void","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_i2c_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write data to an i2c device — rpi_i2c_set","text":"","code":"if (FALSE) { # is.rpi() }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":null,"dir":"Reference","previous_headings":"","what":"Monitor an RPi pin — rpi_monitor","title":"Monitor an RPi pin — rpi_monitor","text":"Watch Raspberry pi GPIO pin (pins) changes.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Monitor an RPi pin — rpi_monitor","text":"","code":"rpi_monitor(pin_number, numEvents = 0, edge = \"both\")"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Monitor an RPi pin — rpi_monitor","text":"pin_number one pin numbers found Raspberry pi GPIO. Use actual pin numbers (.e. 1:40) numEvents number events collect. Defaults 10 edge rising|falling|","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Monitor an RPi pin — rpi_monitor","text":"list events raw text event event: RISING EDGE|FALLING EDGE line: bcm line (board pin) exhibiting change timestamp: seconds component timestamp: nanoseconds component","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_monitor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Monitor an RPi pin — rpi_monitor","text":"","code":"if (FALSE) { # is.rpi() # \\donttest{ rpi_monitor(21) rpi_monitor(21, numEvents=20) # } }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":null,"dir":"Reference","previous_headings":"","what":"Converts a RPi pin number to BCM line — rpi_pinToBCM","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"Look board pin number return BCM_line line_name Pin number physical board Raspberry pi.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"","code":"rpi_pinToBCM(pin_number)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"pin_number pin found Raspberry Pi board. Numbered 1 40.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"named vector. bcm_line = broadcom line connected pin pin_name = broadcom name RXD1 GPIO21","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"checks valid range pins (1:40) valid input/output lines. prevents trying read 3.3v ground line.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pinToBCM.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Converts a RPi pin number to BCM line — rpi_pinToBCM","text":"","code":"if (FALSE) { # is.rpi() rpi_pinToBCM(1) # produces error since pin #1 is not data rpi_pinToBCM(40) # returns a named vector where bcm_line = 21 and pin_name = GPIO21 }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":null,"dir":"Reference","previous_headings":"","what":"Raspberry Pi Pins — rpi_pin_desc","title":"Raspberry Pi Pins — rpi_pin_desc","text":"board-level description 40 GPIO pins found Raspberry Pi. different wiring pi BCM numbering schemes. Instead, reflects function pins physical location board.","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Raspberry Pi Pins — rpi_pin_desc","text":"","code":"rpi_pin_desc"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Raspberry Pi Pins — rpi_pin_desc","text":"## `rpi_pin_desc` data frame 40 rows two columns: description. Primary function pin secondary. Secondary function pin valid_PWM_pair_1, valid_PWM_pair_2. Used rpi_pwm() determine valid PWM pins channel combinations. PWM_channel. Unambiguously relates PWM channel board pin","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pin_desc.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Raspberry Pi Pins — rpi_pin_desc","text":"https://www.raspberrypi.com/documentation/computers/os.html#gpio---40-pin-header","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":null,"dir":"Reference","previous_headings":"","what":"Provide R with access to PWM — rpi_pwm","title":"Provide R with access to PWM — rpi_pwm","text":"Provides R programming language access Raspberry Pi hardware Pulse Width Modulation (PWM)","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Provide R with access to PWM — rpi_pwm","text":"","code":"rpi_pwm( pin_number = 12, pwm_period = 50000, pwm_dutycycle = 25000, pwm_debug = FALSE )"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Provide R with access to PWM — rpi_pwm","text":"pin_number One two pins hardware PWM. Must 12, 32, 33, 35. two pins selected, must one combinations: (12,33), (32,33), (12,35), (32,35) pwm_period length cycle. aka Frequency. 15 greater, less 1000000 pwm_dutycycle amount time cycle . pwm_debug TRUE, checks Raspberry Pi OS settings PWM provides diagnostics","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Provide R with access to PWM — rpi_pwm","text":"void `rpi_pwm()` provides extensive error checking. Possible errors include: Invalid PWM pin: Hardware PWM supplied pins 12, 32, 33, 35. Invalid PWM pin combination: combination pins select PWM0 PWM1 PWM enabled: PWM channel enabled (see https://mnr.github.io/rpigpior/articles/rpi_pwm.html fixing errors)","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Provide R with access to PWM — rpi_pwm","text":"two PWM lines available Raspberry Pi - pwm0 pwm1. Although possible create software PWM, advised due latency linux R. might helpful read article `rpi_pwm()` located [rpigpior website](https://mnr.github.io/rpigpior/articles/rpi_pwm.html).","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_pwm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Provide R with access to PWM — rpi_pwm","text":"","code":"if (FALSE) { # is.rpi() rpi_pwm(12) # provides 50% PWM to pin 12 (PWM0) #' # provides 20% PWM to pin 12 (PWM0) and pin 33 (PWM1) rpi_pwm(c(12,33), pwm_period = 50000, pwm_dutycycle = 10000) }"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":null,"dir":"Reference","previous_headings":"","what":"Turn lines on or off — rpi_set","title":"Turn lines on or off — rpi_set","text":"Turn lines ","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Turn lines on or off — rpi_set","text":"","code":"rpi_set(pin_number, onOff)"},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Turn lines on or off — rpi_set","text":"pin_number one pin numbers found Raspberry pi GPIO. Use actual pin numbers (.e. 1:40) onOff vector length pin_number values 0 1 turn line ","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Turn lines on or off — rpi_set","text":"value returned","code":""},{"path":"https://mnr.github.io/rpigpior/reference/rpi_set.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Turn lines on or off — rpi_set","text":"","code":"if (FALSE) { # is.rpi() # turns pin 19 on, 21 off, and 23 on. # This corresponds to gpio09, gpio10, and gpio11 rpi_set(pin_number = c(19, 21, 23), onOff = c(1,0,1)) toggleThesePins <- c(19,21,23) rpi_set(toggleThesePins, 1) # turns all three pins on. onOff is recycled Sys.sleep(1) rpi_set(toggleThesePins, c(0,1,0)) # turns off pins 19 and 23 Sys.sleep(1) rpi_set(toggleThesePins, 0) # turns off all pins }"},{"path":"https://mnr.github.io/rpigpior/reference/rpigpior-package.html","id":null,"dir":"Reference","previous_headings":"","what":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","title":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","text":"provides R access Raspberry Pi General Purpose Input Output (GPIO) via 'libgpiod'. includes detecting gpio chip well turning pins via [gpioset()] reading state pins via [gpioget()]. additional libraries need installed; Raspbian includes 'libgpiod' part standard installation.","code":""},{"path":[]},{"path":"https://mnr.github.io/rpigpior/reference/rpigpior-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"rpigpior: Provides R with Access to the Raspberry Pi — rpigpior-package","text":"Maintainer: Mark Niemann-Ross mark@niemannross.com (ORCID) [copyright holder]","code":""},{"path":"https://mnr.github.io/rpigpior/news/index.html","id":"rpigpior-010","dir":"Changelog","previous_headings":"","what":"rpigpior 0.1.0","title":"rpigpior 0.1.0","text":"rpi_i2c_get() rpi_i2c_set() rpi_pwm() rpi_monitor() rpi_set() rpi_get() rpi_pinToBCM() is_rpi() Added NEWS.md file track changes package.","code":""}]