viktorvano / IoT-Elevator

Using STM32 and ESP8266 to control an elevator with an Android app and with natural speech via SpeechRecognitionAI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IoT-Elevator

Using STM32 and ESP8266 to control an elevator with an Android app and with natural speech via SpeechRecognitionAI.

Video: https://youtu.be/aTKumJoA4KU
Speech Recognition AI: https://github.com/viktorvano/SpeechRecognitionAI
Similar ESP8266 project (similar STM32 code): https://github.com/viktorvano/Remote-Robot

Wiring Diagram

alt text

Code Snippets

[STM32 C code] You have to change your WiFi SSID credentials:

#define WiFi_Credentials	"AT+CWJAP=\"WiFiSSID\",\"WiFiPASSWORD\"\r\n"

[Android Studio - Java]

public class MainActivity extends AppCompatActivity {

    public static String elevatorIP = "192.168.2.172";//change this IP address according to your ESP8266

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        Button button = findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sendDataToServer(elevatorIP, "elevator");
            }
        });
    }

    private void sendDataToServer(String IP, String message)
    {
        try
        {
            // need host and port, we want to connect to the ServerSocket at port 7777
            Socket socket = new Socket();
            socket.setSoTimeout(800);
            socket.connect(new InetSocketAddress(IP, 80), 800);
            System.out.println("Connected!");

            // get the output stream from the socket.
            OutputStream outputStream = socket.getOutputStream();
            // create a data output stream from the output stream so we can send data through it
            DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

            System.out.println("Sending string to the ServerSocket");

            // write the message we want to send
            dataOutputStream.writeUTF(message);
            dataOutputStream.flush(); // send the message
            dataOutputStream.close(); // close the output stream when we're done.

            System.out.println("Closing socket.");
            socket.close();
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

Photos

Elevator

alt text

STM32, ESP8266, step down module and 5V Relay

alt text

alt text

alt text

About

Using STM32 and ESP8266 to control an elevator with an Android app and with natural speech via SpeechRecognitionAI.

License:Apache License 2.0


Languages

Language:C 97.9%Language:Makefile 1.7%Language:Assembly 0.3%Language:Java 0.1%