OpenXsensor with Arduino Nano

I recently moved from the Arduino Pro Mini’s to the Nano because of several things:

  • Stable clock @ 16Mhz with low voltages, needed for multi in one sensor configuration.
  • 3.3v output, also used for VREF (Reference voltage for analog sensors, Voltage, Current etc.)
  • Directly programmable via USB
  • Cheaper then Pro Mini’s

https://github.com/openXsensor/openXsensor

Configuring a current sensor to be used with ETHOS

 

A big not for who wants to build current sensors for use with ETHOS.

As for now, OpenXsensor sends out negative values arround 0 amps.
These negative values are seen as invalid in Ethos.
Therefore Ethos will eventually call out sensor lost announcements.

To prevent this, we need to be sure OpenXsensor only sends out 0 or positive values.

in the file: openXsensor/oXs_out_frsky.cpp

Search for the following at line 597:

 

#if defined(ARDUINO_MEASURES_A_CURRENT) && (ARDUINO_MEASURES_A_CURRENT == YES)  
    if ( oXs_Current.currentData.milliAmps.available) {
      oXs_Current.currentData.milliAmps.available = false ; 
      sport_currentData.value = oXs_Current.currentData.milliAmps.value  / 100 ;
      sport_currentData.available = true ;
    }  
#elif defined(AN_ADS1115_IS_CONNECTED) && (AN_ADS1115_IS_CONNECTED == YES ) && defined(ADS_MEASURE) && defined(ADS_CURRENT_BASED_ON)
    if ( oXs_ads1115.adsCurrentData.milliAmps.available ) {
      oXs_ads1115.adsCurrentData.milliAmps.available = false ;
      sport_currentData.value = oXs_ads1115.adsCurrentData.milliAmps.value  / 100 ;
      sport_currentData.available = true ;
    }  
#endif

and change it to:

#if defined(ARDUINO_MEASURES_A_CURRENT) && (ARDUINO_MEASURES_A_CURRENT == YES)  
    if ( oXs_Current.currentData.milliAmps.available) {
      oXs_Current.currentData.milliAmps.available = false ; 
      sport_currentData.value = oXs_Current.currentData.milliAmps.value  / 100 ;
      if (sport_currentData.value >= 0) {
        sport_currentData.available = true ;
      }
    }  
#elif defined(AN_ADS1115_IS_CONNECTED) && (AN_ADS1115_IS_CONNECTED == YES ) && defined(ADS_MEASURE) && defined(ADS_CURRENT_BASED_ON)
    if ( oXs_ads1115.adsCurrentData.milliAmps.available ) {
      oXs_ads1115.adsCurrentData.milliAmps.available = false ;
      sport_currentData.value = oXs_ads1115.adsCurrentData.milliAmps.value  / 100 ;
      if (sport_currentData.value >= 0) {
        sport_currentData.available = true ;
      }
    }  
#endif

 

 

 

You may also like...