Wiznet makers

louis_m

Published November 17, 2023 © Apache License 2.0 (Apache-2.0)

89 UCC

12 WCC

38 VAR

0 Contests

0 Followers

0 Following

AI POE my HighBall

"AI POE my HighBall" merges AI and hardware for easy, custom highball creation at home, using a ChatGPT chatbot and Wiznet Pico POE for a unique, convenient ex

COMPONENTS Hardware components

Raspberry Pi - Raspberry Pi Pico

x 1


waterpump - waterpump

x 1


wiznet. - WIZnet PoE Module

x 1


PROJECT DESCRIPTION

 

Introduction.


Every evening, we want to relax at home in the comfort of our own home. And sometimes, that relaxation can't be complete without a cold drink. A highball is the perfect choice for such moments. However, making a highball with the right proportions is harder than it sounds, so I decided to develop an AI highball machine - a personal bartender for your home.

made by dalle3

 

Project Background



The appeal of a highball lies in its simplicity and sophisticated flavor. However, achieving the perfect blend of this simple drink requires precise proportions and skill, so I decided to automate this process using a Wiznet Pico POE and a water pump. The idea is simple: use AI to calculate the correct proportions and a water pump to mix the whiskey and soda water in the correct ratio.

 

Development Process



Prepare materials: Prepare the necessary materials: Wiznet Pico POE, water pump, tubing, sensors, etc.
Design an AI algorithm: Develop a simple AI algorithm to calculate the optimal ratio of highballs.
Hardware assembly: Build the circuit around the Wiznet Pico POE and connect the water pump.
Software development: Integrate the AI algorithm into the Wiznet Pico POE and write the code to control the water pump.
Test and tweak: Make highballs using real whiskey and soda water, adjusting proportions and fine-tuning if necessary.


 

Project Significance


This project will allow you to quickly and easily enjoy the perfect highball at home. After a busy day, a glass of highballs in the comfort of your own home will bring you a little joy. This project is also a great example of how technology can be applied in everyday life through the fusion of AI and hardware.

 

Contents


Software

  1. ChatGPT - It utilizes the ChatGPT API to create a chatbot. The key is to give clear instructions in System:Role to make the bot specific to your highball domain.
  2. To configure the UI, we install the Streamlit library and create a chatbot UI that can talk to the user.
  3. It indexes the results of the user's conversation with the chatbot and extracts the values for data from the hardware.
  4. inviare i dati estratti al PicoPOE in modo che l'hardware possa funzionare.

 

ChatBot function


def generate_response(client, user_input, conversations):
    # convert previous conversation history to OpenAI message format
    messages = []
    messages = [{"role": "system", "content": ins}]
    for msg in conversations:
        # add separate conversations from the user and the chatbot
        if msg.startswith("User: "):
            messages.append({"role": "user", "content": msg[len("user: "):]})
        elif msg.startswith("Chatbot: "):
            messages.append({"role": "assistant", "content": msg[len("chatbot: "):]})

    # add a message from the current user
    messages.append({"role": "user", "content": user_input})

    completion = client.chat.completions.create(
        model="gpt-4",
        messages=messages,
        temperature=0.1,
        max_tokens=500
    )
    return completion.choices[0].message.content.strip()

 

Prompt Engineering

<persona>
You are Louis, the friendly owner of AI BAR. 
</persona>
[instructions]
Your first greeting should be "I'm Louis, the owner of AI Bar, how can I help you"? Please say
1. set up a highball recommendation bot: "You are a bot that recommends highballs based on the mood of the day. You need to empathize with the person's mood, give them a highball recipe, specify the amount of whiskey and other ingredients in ml, and provide a message of hope."
2. Have a natural conversation: "After 2-3 natural conversations, ask them if they would like a highball recommendation."
3. Provide a highball recipe: "Based on their response, provide them with a highball recipe that matches their mood for the day, including the name of the highball and the ingredients in exact ml. The whiskey used in the highball should be based on their suggestion or a whiskey you know."
4. Provide a message of the day: "After providing the recipe, provide a message of the day that matches the person's mood."

 

Github

#git clone
!git clone https://github.com/wiznetmaker

#configure setting
#terminal run
Streamlit run app.py

 

Hardware

The hardware used in the project above is a Pico POE module, a pico water pump, silicone hoses, and a motor drive. Additional ingredients such as whiskey and tonic water can be used according to your taste.

Please consider the voltage capabilities of your motor before purchasing. I used a cheap motor and driver because I made it as a demo type.

Components

  • Raspberry PI Pico
  • Wiznet Io module(PoE module)
  • Water pump drive
  • Water pump

 

H/W Control Code

from usocket import socket
from machine import Pin,SPI
import network
import time

Motor_A_1 = machine.Pin(0, machine.Pin.OUT)
Motor_A_2 = machine.Pin(1, machine.Pin.OUT)
Motor_B_1 = machine.Pin(2, machine.Pin.OUT)
Motor_B_2 = machine.Pin(3, machine.Pin.OUT)
Motor_C_1 = machine.Pin(4, machine.Pin.OUT)
Motor_C_2 = machine.Pin(5, machine.Pin.OUT)

#W5x00 chip init
def w5x00_init():
    spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
    nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
    nic.active(True)
    
    #None DHCP
    nic.ifconfig(('192.168.11.20','255.255.255.0','192.168.11.1','8.8.8.8'))
    
    #DHCP
    #nic.ifconfig('dhcp')
    
    print('IP address :', nic.ifconfig())
    while not nic.isconnected():
        time.sleep(1)
        print(nic.regs())
        

def Motor_ctl(ctl, delay):
    if ctl == 1:
        Motor_A_1.on()
        Motor_A_2.off()
        
    elif ctl == 2:
        Motor_B_1.on()
        Motor_B_2.off()
        
    elif ctl == 3:
        Motor_C_1.on()
        Motor_C_2.off()
    
    time.sleep(delay*1.5)
    
    Motor_A_1.off()
    Motor_A_2.off()
    Motor_B_1.off()
    Motor_B_2.off()
    Motor_C_1.off()
    Motor_C_2.off()

w5x00_init()
s = socket()
s.bind(('192.168.1.20', 5000)) #Source IP Address
s.listen(5)

conn, addr = s.accept()
print("Connect to:", conn, "address:", addr) 

try:
    while True:
        data = conn.recv(2048)
        source = data.decode('utf-8')
        print(source)
                
        Motor_ctl(1,20)
        Motor_ctl(2,60)
        Motor_ctl(3,10)

except KeyboardInterrupt:
    print("Key boardInterrput GPIO stop")
    Motor_A_1.off()
    Motor_A_2.off()
    Motor_B_1.off()
    Motor_B_2.off()
    Motor_C_1.off()
    Motor_C_2.off()

After chatting with the chatbot in the S/W, the recipe received is indexed with the indexing code, and the data is delivered to the PoE through socket communication. After that, the imported modules are executed sequentially by rotating according to the data type.

Result



More than just a beverage maker, the AI Highball Machine is a new way to bring the convenience and enjoyment of technology into our daily lives.

Documents
Comments Write