Help Read GPIO pin in Python
Hello everyone. I have been attempting to read the analog signal from the GPIO pin of the MetamotionR board. I am using the pymetawear library on a raspberry pi.
This is the sesnor I am attempting to read: https://www.sparkfun.com/products/12650?_ga=2.112552772.1984315370.1584943763-165751714.1579836749
Reading the sesnor from the GPIO pin with the MetaWear android app does work. However when I try to test it in python I am stuck.
I have been modifying the gpio.py script in the pymetawear modules folder. Here is my code:
https://github.com/booman171/gpio/blob/master/gpio.py
Note, this file is a copy of the the gpio.py file from the modules folder within a clone of the pymetawear library, in which I am editing. I have been playing around with the code around line 100 but nothing seems to work.
There error message is as follows:
Traceback (most recent call last):
File "gpio.py", line 217, in <module>
gp.notifications(handle_gpio_notification)
File "gpio.py", line 197, in notifications
super(GpioModule, self).notifications(data_handler(callback))
File "/usr/local/lib/python3.7/dist-packages/pymetawear/modules/base.py", line 135, in notifications
data_signal = self.data_signal
File "gpio.py", line 100, in data_signal
return libmetawear.mbl_mw_gpio_get_pin_monitor_data_signal(self.board, '0')
ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
Any help is welcome.
Comments
Please check this out for help: https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/master/test/test_gpio.py
I have been looking through that example, thank you. I managed to get passed my initial issue, but still can't access the signal.
This is my code:
The output is:
There should be some output here. Any thoughts?
This looks all correct. You only read the signal once so you got one sample. Please read our tutorials, some signal need timers to be read more than once:
https://mbientlab.com/tutorials/CPPDevelopment.html#reading