Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Implementation of Industrial Automation HAT #32

Open
un1997 opened this issue Jun 11, 2024 · 1 comment
Open

Python Implementation of Industrial Automation HAT #32

un1997 opened this issue Jun 11, 2024 · 1 comment

Comments

@un1997
Copy link

un1997 commented Jun 11, 2024

I'm trying to make use of the HAT for gathering digital and analog input and giving outputs with a Python program and AWS IoT. This would run indefinitely and send and receive information from my script ideally.
When i try to implement the same in the following manner.

def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to AWS IoT")
client.subscribe(MQTT_TOPIC_SUBSCRIBE)
else:
print("Connection to AWS IoT failed")

def on_message(client, userdata, msg):
print(f"Received message from topic {msg.topic}: {str(msg.payload.decode('utf-8'))}")
message = json.loads(msg.payload)
if "desiredTemperature" in message:
desired_temperature = message["desiredTemperature"]
print(f"Setting desired temperature to: {desired_temperature}")
set_temperature(desired_temperature)

def read_sensors():
temperature = ind.get0_10In(STACK_LEVEL, TEMP_INPUT_CHANNEL)
humidity = ind.get0_10In(STACK_LEVEL, HUMIDITY_INPUT_CHANNEL)
return temperature, humidity

I get an error stating "An error occurred in the publish thread: [Errno 2] No such file or directory: '/dev/i2c-1'

The program works ideally when i comment out any code with regards to the megaind library and use dummy data.

@alexburcea2877
Copy link
Member

Did you enable the I2C port?
Do your tests with the "megaind" command line first to validate the setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants