Skip to content

Commit 72b4765

Browse files
authored
Merge pull request #7 from vanniaz/master
Corrected scale factors and added ESP32
2 parents d9745d0 + dc76ca8 commit 72b4765

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

MCP3X21.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ MCP3021::MCP3021(uint8_t slave_adr):
6666
}
6767

6868
uint16_t MCP3021::toVoltage(uint16_t data, uint32_t vref) {
69-
return (vref * data / 1023);
69+
return (vref * data / 1024);
7070
}
7171

7272
MCP3221::MCP3221(uint8_t slave_adr):
7373
MCP3X21(slave_adr) {
7474
}
7575

7676
uint16_t MCP3221::toVoltage(uint16_t data, uint32_t vref) {
77-
return (vref * data / 4095);
77+
return (vref * data / 4096);
7878
}

examples/MCP3021/MCP3021.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MCP3021 mcp3021(address);
99
void setup() {
1010
Serial.begin(115200);
1111

12-
#if defined(ESP8266)
12+
#if defined(ESP8266) || defined(ESP32)
1313
Wire.begin(SDA, SCL);
1414
mcp3021.init(&Wire);
1515
#else

examples/MCP3221/MCP3221.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MCP3221 mcp3221(address);
99
void setup() {
1010
Serial.begin(115200);
1111

12-
#if defined(ESP8266)
12+
#if defined(ESP8266) || defined(ESP32)
1313
Wire.begin(SDA, SCL);
1414
mcp3221.init(&Wire);
1515
#else

0 commit comments

Comments
 (0)