DanielMartensson / OpenSourceLogger-Web

Use and STM32 to store measurements into a MySQL server over the web
MIT License
4 stars 0 forks source link

Future enhancement: convert ADS1115_ADS1015 into a Pi4J Analog Input provider. #2

Closed savageautomate closed 3 years ago

savageautomate commented 4 years ago

This issue is for a future enhancement.

It would be ideal if we could turn the ADS1115_ADS1015 class into a real Pi4J Analog IO provider and load the IO provider into the Pi4J context and use the AnalogInput interfaces from Pi4J V2.

The Pi4J V2 project is currently focused on the core, but at some point we will need to provide some examples of ADC and DAC providers and this could be an ideal candidate. The Pi4J V2 project still needs to figure out how to manage such extensions to the project.

I will cross-reference this issue in the Pi4J V2 repo for future reference.

DanielMartensson commented 4 years ago

This issue is for a future enhancement.

It would be ideal if we could turn the ADS1115_ADS1015 class into a real Pi4J Analog IO provider and load the IO provider into the Pi4J context and use the AnalogInput interfaces from Pi4J V2.

The Pi4J V2 project is currently focused on the core, but at some point we will need to provide some examples of ADC and DAC providers and this could be an ideal candidate. The Pi4J V2 project still needs to figure out how to manage such extensions to the project.

I will cross-reference this issue in the Pi4J V2 repo for future reference.

Yes! That's possible. I have lot's of libraries that can easily be re-written from C to Java. Just replace all uint8_t, uint16_t and uint32_t with int.

hackerjimbo commented 4 years ago

This poses an interesting question. The both the ADS1015 and ADS1115 come with kernel drivers so it's pretty straightforward to use those. So, do we really want to invest in writing user-land drivers for them?

Personally I use the MCP3008 ADC and I'm driving that using the kernel drivers. Files appear under /sys/devices and it's all just open/read work from there on in.

A more extreme example is the DHT11/DHT22/AM230x temperature/humidity sensor. This is notoriously horrid to write user-land code for because of its very specific timing requirements. It can be made to work but has a habit of failing unpredictably and is just plain nasty. Using the kernel driver means that it just works.

I'm not trying to knock anyone's work: I'm just pointing out that our efforts may be better directed elsewhere.

DanielMartensson commented 4 years ago

This poses an interesting question. The both the ADS1015 and ADS1115 come with kernel drivers so it's pretty straightforward to use those. So, do we really want to invest in writing user-land drivers for them?

Personally I use the MCP3008 ADC and I'm driving that using the kernel drivers. Files appear under /sys/devices and it's all just open/read work from there on in.

A more extreme example is the DHT11/DHT22/AM230x temperature/humidity sensor. This is notoriously horrid to write user-land code for because of its very specific timing requirements. It can be made to work but has a habit of failing unpredictably and is just plain nasty. Using the kernel driver means that it just works.

I'm not trying to knock anyone's work: I'm just pointing out that our efforts may be better directed elsewhere.

@hackerjimbo

https://github.com/DanielMartensson/STM32-Libraries

I would recommend a small quick pi4j tutorial how to rewrite Arduino/STM32 libraries to Java.

DanielMartensson commented 3 years ago

The ADS1115 works fine now.