pasquale887
Published

Smart-Kitchen Psoc CY8CKIT-041-41XX

A Smart-Kitchen based on Psoc and an old heatbed. With a LCD screen you can check the temperature of the dish and choose from some ricipes.

IntermediateFull instructions providedOver 3 days204
Smart-Kitchen Psoc CY8CKIT-041-41XX

Things used in this project

Hardware components

Infineon CY8CKIT-041-41XX
×1
LCD I2C 20x4
Or any screen based on the I2C protocol
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Ultrabase 3D Printer Platform Heatbed for Anycubic Mega/Mega S/Mega Pro
This will be our heatbed. I salvaged mine from an old broken 3d printer, but any heatbed is fine
×1
Transformer 12v 30A
This allows you to feed the plate correctly
×1
Relè module 12V 30A
This allows you to control the feed to the heatbead
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
Wooden slabs 40x30cm
Optional. For the structure
×2
Wooden slabs 40x10cm
Optional. For the structure
×2
Wooden slabs 30x10cm
Optional. For the structure
×2
Wood nails
Optional. For the structure
×20

Software apps and online services

PSoC Creator
Cypress PSoC Creator
Tinkercad
Autodesk Tinkercad
For the 3d model
Fritzing
For the Scheme

Hand tools and fabrication machines

circular saw
Optional. For the structure

Story

Read more

Custom parts and enclosures

3d model Structure

Schematics

Scheme

Fritzing Scheme

Code

Psoc Cretor Project

C/C++
No preview (download only).

Main Code

C/C++
Thius is the main code (main.c)
/* ========================================
 *
 * Copyright YOUR COMPANY, THE YEAR
 * All Rights Reserved
 * UNPUBLISHED, LICENSED SOFTWARE.
 *
 * CONFIDENTIAL AND PROPRIETARY INFORMATION
 * WHICH IS THE PROPERTY OF your company.
 *
 * ========================================
*/
// Pasquale Pepe

#include "project.h"
#include <cypins.h>
#include "stdio.h"
#include "unistd.h"
#include "signal.h"
#include "string.h"
#include "stdlib.h"

static int temperature;
static int humidity;
int tempR;

_Bool rag = 1;


char mss[100];
char msstr[100];
char msstest[100];
int i;

int page = 1; //Set Home-Screen
int maxpage=3; //Set Max number of pages

uint32 timecook=0;//ms
uint32 timebefore;
int timeatt=0;//ms

int DHTread() //Read function of Temperature and Humidity (DHT11)
{     

    uint8 IState;
   IState=CyEnterCriticalSection();  
   uint8 bits[5]; 
	uint8 cnt = 7; 
	uint8 idx = 0; 
   int   calc=0; 
   int   timeout=0; 
   for (i=0; i< 5; i++)  
       bits[i] = 0; 
   DHT_Write(0u); 
   CyDelay(19); 
   DHT_Write(1u); 
   while(DHT_Read()==1) 
   { 
       timeout++; 
       if(timeout>500) 
           goto r99;  //DHT error function 
   } 
   while(DHT_Read()==0) 
   {         
       timeout++; 
       if(timeout>500) 
           goto r99; //DHT error function 
   } 
   calc=timeout; 
   timeout=0; 
   while(DHT_Read()==1); 
   for (i=0; i<40; i++) 
	{ 
       timeout=0; 
       while(DHT_Read()==0); 
       while(DHT_Read()==1) 
           timeout++; 
       //Data acquiring point 
       if ((timeout) > (calc/2)) 
           bits[idx] |= (1 << cnt); 
       if (cnt == 0)   // next byte? 
   	{ 
   		cnt = 7;    // restart at MSB 
   		idx++;      // next byte! 
   	} 
   	else cnt--; 
   } 
   humidity    = bits[0];  
   temperature = bits[2];  
   CyExitCriticalSection(IState); 
   CyDelay(1); 
   return 0; 
   r99:    //Goto label for error in DHT reading 
       humidity    = 99;  
     //  temperature = 99;  
       CyExitCriticalSection(IState); 
       return 99; 
}



int pagevoid(){
       DHTread(); 
     CharLCD_ClearDisplay();
        sprintf(mss,"%i'C ",temperature);
        if ( temperature<tempR){
           sprintf(msstr,"Rq  %i'C ",tempR); 
          CharLCD_PosPrintString(0u,12u,msstr);
        } else{
             CharLCD_PosPrintString(0u,13u,"       ");
        }
        
        CharLCD_PosPrintString(0u,1u,mss); //Y-X
     
        if (page == 1){
        CharLCD_PosPrintString(2u,6u,"< POLLO >");
        } else if (page==2){
          CharLCD_PosPrintString(2u,6u,"< THE' >");  
        }else if (page==3){
             CharLCD_PosPrintString(2u,6u,"< PASTA >"); 
        }
        
     
        
return 99;
}

void takefood(){ //Final function when the food is ready
    Rele_Write(0);
    tempR=0;
    timecook=0;
  
    CharLCD_ClearDisplay();
    CharLCD_PosPrintString(1u,8u,"TAKE");
     CharLCD_PosPrintString(2u,6u,"THE FOOD");
    for (int h =0;h<5;h++){
    Led_State_Write(1);
        CyDelay(700u);
	Led_State_Write(0);
    CyDelay(700u);
    }
}


void timecontroll()
{
     timeatt = RTC_GetMinutes(RTC_GetTime()); //Actual-Timeme
    uint32 timetot = timeatt-timebefore;
    if (timecook !=0){
    if (timecook==timetot){
        takefood();
        timecook = 0;
      }
      itoa(timetot,msstest,10);
        CharLCD_PosPrintString(3u,17u,msstest);  
    }
        
}


int setrecipe(){ //Here thre are the recipes
     if (page == 1){//Pollo
           tempR =74;
        timecook=22; //22
          timebefore=RTC_GetMinutes(RTC_GetTime());
       // alarm(1320);//Set the timer for 12m for the chicken
        } else if (page==2){//THE'
         timecook=12;
         tempR = 100;
    timebefore=RTC_GetMinutes(RTC_GetTime());
       // alarm(720); //Set the timer for 12m for the water
            
        }else if (page==3){//Pasta
        tempR = 100;
        timecook=20;
         timebefore=RTC_GetMinutes(RTC_GetTime());
       // alarm(1200); //Set the timer for 12m for the water +8m for the pasta
        
        }
        return 99;
}



int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    uint32 detectedGesture = CapSense_SLIDER_NO_TOUCH;
    
    //Start all the components
    I2C_CharLCD_Start();
	CharLCD_Start(); //We use a LCD I2C 0x27 20x4
    CapSense_Start();
    RTC_Start();
    
    
    CapSense_InitializeAllBaselines();
    DHTread(); 
    tempR = temperature;
    
    CharLCD_ClearDisplay();
    CharLCD_PosPrintString(1u,6u,"WELCOME!"); //Welcome page
    CyDelay(2500u);
    CharLCD_ClearDisplay();

  
    for(;;)
    {
         
          pagevoid();//Call the Display-page Function
          timecontroll();
        
       // if (rag == 1) {
        if(tempR!=0){
            if (temperature <tempR){
             rag = 0;
             Rele_Write(1);
        Led_State_Write(1);
                 
      
        }else{
            

      
    
            Rele_Write(0);
             Led_State_Write(0);
             rag =1;
        }
        }
     
//Check if the required temperature is equal to the currente temperature,if not, heat the heatbed
        
        
        
  if(CapSense_NOT_BUSY == CapSense_IsBusy())
        {
            // Process all widgets 
            CapSense_ProcessAllWidgets();

            // Scan result verification 
           

            if (CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) //Button +
            {
               Led_State_Write(1); // LED on
                tempR ++; //Increases the required temperature
                CharLCD_PosPrintString(2u,3u,"+");
            
            }else if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)) { // Button -
                     tempR --;//decreases  the required temperature 
                     CharLCD_PosPrintString(2u,3u,"-");
                    
             
            } else{
              
                CharLCD_PosPrintString(2u,3u," ");
            }
            
            detectedGesture = CapSense_DecodeWidgetGestures(CapSense_LINEARSLIDER0_WDGT_ID);
            
             switch(detectedGesture){
            case CapSense_ONE_FINGER_FLICK_RIGHT:
                if(page<maxpage){
               page++;
                } else{
                   page = 1; 
                }
                break;
            case CapSense_ONE_FINGER_SINGLE_CLICK:
               setrecipe();
                  CharLCD_PosPrintString(3u,6u,"                    "); //Clear the row
                 CharLCD_PosPrintString(3u,6u,"OK");
                break;
            case CapSense_ONE_FINGER_FLICK_LEFT:
                if(page!=1){
               page--;
                } else{
                   page = 3; 
                }
            
                break;
            }
            
            
            

            // Start next scan 
            CapSense_ScanAllWidgets();
        }
        CyDelay(1000u);
        RTC_Update();
    }
           
        
      
   		
    }


/* [] END OF FILE */

CharLCD_I2C

C/C++
The custom component for the LCD
No preview (download only).

Main Code

C/C++
Thius is the main code (main.c)
No preview (download only).

Credits

pasquale887

pasquale887

3 projects • 6 followers

Comments