robert-hh / ads1x15

Micropython driver for ADS1115 and ADS1015
90 stars 25 forks source link

modifications for current Raspbian Stretch (Debian Stretch) release and python module error #3

Closed jimlynnjulian closed 6 years ago

jimlynnjulian commented 6 years ago

data = array("h", 0 for _ in range(_BUFFERSIZE)) <-error " generator has to be placed in parentheses if not the only argument."

data = array("h", (0 for _ in range(_BUFFERSIZE))) <- accepted

The 'machine' module was installed but is not detected. (sudo) pip install machine. Installation process normal and concludes correctly, still, a "No module named machine" occurs.

Running Python 2.7 on Raspberri Pi Raspbian Stretch (Debian), current verison. I leave the module file, 'ads1x15.py' in the same directory as the test script taken from github. Should I have made some other preparation for using the module?

robert-hh commented 6 years ago

I'm a little bit confused. The ADS1x15 was intended to be used on small devices like an ESP8266 or ESP32 with MicroPython. That's where the machine module exists. I have my doubts whether it works on WIndows. The machine module in micropython-lib is useful for Linux and provides at least the Pin and Timer method. The machine module in the simple sample script is using to define the Pins for the I2C interface, or the IRQ signal. If the Windows or RasPi environment has other means to define the I2C (and the iRQ), that has to be used. the definition of the array can be changed. It works as well with MicroPython.

data = array("h", (0 for _ in range(_BUFFERSIZE)))

It could also be written as:

data = array("h", [0] * _BUFFERSIZE)
jimlynnjulian commented 6 years ago

I'm using my Windows laptop to run a Raspberry Pi, in headless mode. As I said, I installed the machine module, without issues, on a Raspberry Pi 3B+ running the Raspbian Stretch O/S and Python 2.7. I've corrected the title. What is the machine module doing in the import list? From what I can determine, the module is part of a packaging tutorial.

jimlynnjulian commented 6 years ago

This has, for the time being, become moot. I think I have a damaged device. Good luck.

robert-hh commented 6 years ago

The machine module is the interface to the hardware abstraction layer of MicroPython for these small micros, which run Python without an (visible) operating system. See http://docs.micropython.org/en/latest/pyboard/library/machine.html. It is only included in the example scripts, not in the core ads1x15.py module. I see that the machine module in micropython-lib supports the Pin and Timer methods, but not I2C. And RasPi Python has neither machine nor I2C.

I changed the array statements in the readme.md file.

robert-hh commented 6 years ago

I searched for Raspberry Pi and I2C, and not surprisingly the I2C access is somewaht different. You may use the structure of the ADS1x15 driver. but the low level fucntions for register read & write have to be changed.

jimlynnjulian commented 6 years ago

Hello,

Thank you for your help. I decided the unit may have been damaged and am using a new one. Everything is fine. The software I configured a few years ago, but forgot, now works.

Thank you again, Jim Julian

Cogito ergo sum. René Descartes circa 1685 “I think, therefore, I am.”

Sum ergo cogito. Google 2004 “So, I’m thinking...”