Skip to content

Commit

Permalink
change of gain for ADC in i2c-power
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Sep 26, 2023
1 parent a450ad0 commit 37b70f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion platformio/stima_v3/i2c-power/src/i2c-power-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ correctly during I2C communication.

#define ADC_I2C_ADDRESS ADC_VDD_I2C_ADDRESS

// max value in mV to be applied before partitor to get max ADC input (6.144 V)
// max value in mV to be applied before partitor to get max ADC input (2.048 V)
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_MAX_PANEL (30000)
#define CONFIGURATION_DEFAULT_ADC_VOLTAGE_MAX_BATTERY (15000)

Expand Down
7 changes: 7 additions & 0 deletions platformio/stima_v3/i2c-power/src/i2c-power.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@ void init_pins(void);
*/
void init_wire(void);

/*!
\fn void init_adc(void)
\brief Init ADC converter.
\return void.
*/
void init_adc(void);

/*!
\fn void init_spi(void)
\brief Init SPI library.
Expand Down
6 changes: 6 additions & 0 deletions platformio/stima_v3/i2c-power/src/i2c-power.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void setup() {
init_buffers();
init_wire();
init_rtc();
init_adc();
#if (USE_TIMER_1)
init_timer1();
#endif
Expand Down Expand Up @@ -260,6 +261,11 @@ void init_wire() {
Wire.onReceive(i2c_receive_interrupt_handler);
}

void init_adc() {
//+/-2.048V range = Gain 2 (default)
adc1.setGain(GAIN_TWO);
}

void init_spi() {
#if (ENABLE_SDCARD_LOGGING)
SPI.begin();
Expand Down

0 comments on commit 37b70f7

Please sign in to comment.