Seafox_C
Created December 7, 2022

DMI Dog Machine Interface

Can I monitor my dog's health from the moister content of her nose? Let's find out and create a DMI (Dog Machine Interface).

43

Things used in this project

Hardware components

Cypress PSoC 4100S Pioneer Kit
×1

Software apps and online services

PSoC Creator
Cypress PSoC Creator
Python IDE

Hand tools and fabrication machines

Tape, Double Sided
Tape, Double Sided

Story

Read more

Code

Visualise_CAPSENSE_Sensor_Python3

Python
Open in the Python IDE, pip install the necesarry modules
Receives the data from a COM port and will make a graph from that data.
import serial
import time
import matplotlib.pyplot as plt

# Open the serial port
ser = serial.Serial('COM4', baudrate=115200)
print('SerialPort is Read')

# Initialize an empty list to store the sensor data
CAP_Sensor_Data = []

# Read the data from the serial port for 20 seconds
start_time = time.time()
while time.time() - start_time < 20:
    # Read a line of data from the serial port
    line = ser.readline().decode().strip()
    
    # Check if the line is non-empty
    if line:
        # Convert the line to an integer and append it to the list
        CAP_Sensor_Data.append(int(line))

# Subtract the minimum value from each element in the list
min_value = min(CAP_Sensor_Data)
CAP_Sensor_Data = [val - min_value for val in CAP_Sensor_Data]

# Print the list
print(CAP_Sensor_Data)

# Plot the data as a graph
plt.plot(CAP_Sensor_Data)
plt.xlabel('Time')
plt.ylabel('Sensor Data')
plt.title('Sensor Data Over Time')
plt.show()

DMI_Python

Python
Pythonscript to run te voice commands. Please note you need wifi to enable the voice API
import serial
import time
from gtts import gTTS
import os

# Define the text messages that you want
text_messages = [
    'Let me out Human!',
    'Fulfill your oath and let me out',
    'You may think youre the boss, but we both know who really is in charge. Let me out!',
    'Please let me out to catch the squirrels',
    'Come on, my leash is calling my name. Let me out!',
    'Lets go Human, Time to walk!',
    'I have an urgent matter to attend to. Please let me out.',
    'Please, get out the couch and let me out you lazy human',
    'Let me out, you need the exercise',
    'For the love of god, let me out',
    'Let me out, Let me out,Let me out, Let me out,Let me out, Let me out',
    'I swear, if you dont let me out now, I will chew up your shoes!',
    'You know what they say about idle paws, right? Let me out!',
    'I cant hold it any longer, let me out or you will regret it!',
    'If you dont let me out, Ill start barking and the neighbors will know why.',
    'I have an urgent matter to attend to. Please let me out.',
    'I need to go outside to get some inspiration for my next novel. Let me out!'
]


# Set the language and COM port
language = 'en'
COM_Port = 'COM6'

# Initialize a counter variable to keep track of which message to play
counter = 0

# Open the serial port
ser = serial.Serial(COM_Port, baudrate=115200)
print('SerialPort is Read')

# While loop to continuously read the serial port
while True:
    # Read a line of data from the serial port
    line = ser.readline().decode().strip()

    # Check if the received text is 'h'
    if line == 'h':
        os.system("TASKKILL /F /IM wmplayer.exe")
        time.sleep(2)

        # Use the counter variable to select the appropriate text message
        text = text_messages[counter]

        # Generate the speech file using the selected text message
        myobj = gTTS(text=text, lang=language, slow=False)
        myobj.save("Speech.mp3")
        os.system("Speech.mp3")

        # Increment the counter variable to select the next message next time
        counter += 1
        if counter >= len(text_messages):
            counter = 0


# Close the serial port
ser.close()

PSoC_Designer_Project_RAW_sensor_data_to_COM

C/C++
This will send the raw data of the capacitive button to the COM port.
Unzip it and open it with Psoc Creator software
No preview (download only).

PSoC_Designer_Project_DMI

C/C++
Unarchive it and use the PSoC designer to open it
No preview (download only).

Credits

Seafox_C

Seafox_C

10 projects • 48 followers
I'm 29 years old and live in Belgium. I love the Arduino community and like to learn and make projects.

Comments