Skip to content

Talking to the MCP342x family of ADC via I2C from Clojure JVM

License

Notifications You must be signed in to change notification settings

helins/linux.i2c.mcp342x.clj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux.I2C.MCP342X, driver for A/D

Clojars Project

Cljdoc

Clojure library for talking to the MCP342x family of A/D converters using I2C :

  • MCP3421
  • MCP3422
  • MCP3423
  • MCP3424
  • MCP3425
  • MCP3426
  • MCP3427
  • MCP3428

Relies on helins/linux.i2c.

Usage

This is an overview.

The detailed API is available on Cljdoc.

In short, without error handling :

(require '[helins.linux.i2c         :as i2c]
         '[helins.linux.i2c.mcp342x :as mcp342x])


(with-open [bus (i2c/bus "/dev/i2c-1")]

  (i2c/select-slave bus
                    (mcp342x/address true
                                     false
                                     true))

  (mcp342x/configure bus
                     {:mcp342x/channel    2
                      :mcp342x/mode       :continuous
                      :mcp342x/pga        :x1
                      :mcp342x/resolution :16-bit})

  (mcp342x/read-channel bus
                        :16-bit)

  => {:mcp342x/channel    2
      :mcp342x/micro-volt 913000
      :mcp342x/mode       :continuous
      :mcp342x/pga        :x1
      :mcp342x/resolution :16-bit})

License

Copyright © 2017 Adam Helinski

Licensed under the term of the Mozilla Public License 2.0, see LICENSE.

About

Talking to the MCP342x family of ADC via I2C from Clojure JVM

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published