Giter Site home page Giter Site logo

gfurtadoalmeida / esp32-driver-mcp320x Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 2.0 783 KB

ESP32 driver for Microchip MCP3204 and MCP3208 12-bit ADCs.

License: MIT License

CMake 3.49% C 92.86% PowerShell 3.65%
esp32 esp-idf espressif microchip mcp3204 mcp3208 adc driver

esp32-driver-mcp320x's People

Contributors

gfurtadoalmeida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

onurylcn valioiv

esp32-driver-mcp320x's Issues

Voltage calculation suffers from integer division in float context

The voltage calculation for a reference voltage less than 4096 will always return 0 and any reference voltage other than 4096 will return an inaccurate voltage.

Here is a patch :

diff --git a/components/esp32_driver_mcp320x/src/mcp320x.c b/components/esp32_driver_mcp320x/src/mcp320x.c
index ce6e6fe..5af377d 100644
--- a/components/esp32_driver_mcp320x/src/mcp320x.c
+++ b/components/esp32_driver_mcp320x/src/mcp320x.c
@@ -40,7 +40,8 @@ mcp320x_t *mcp320x_install(mcp320x_config_t const *config)
     mcp320x_t *dev = (mcp320x_t *)malloc(sizeof(mcp320x_t));
     dev->spi_handle = spi_device_handle;
     dev->mcp_model = config->device_model;
-    dev->millivolts_per_resolution_step = config->reference_voltage / MCP320X_RESOLUTION;
+    dev->millivolts_per_resolution_step = (float)config->reference_voltage / (float)MCP320X_RESOLUTION;

 
     return dev;

Voltage not properly displayed

When I run the code, the displayed voltage couldn't go greater than somewhere around 70 mV. The hex value in rx buffer was responding properly to the input voltage though, so I modified the code a little bit. Change diff.patch -> diff.html
diff.patch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.