Majed Abouhatab, P.E.
Published © LGPL

WeMos D1 Mini Controlling RC Car And Relaying Video Stream

"Every Device Makes Its Own Wi-Fi" - Not Clint Eastwood

AdvancedFull instructions provided10 hours783
WeMos D1 Mini Controlling RC Car And Relaying Video Stream

Things used in this project

Hardware components

Wemos D1 Mini
Espressif Wemos D1 Mini
×1
RC Car
×1
Wireless Security Camera
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2
PlatformIO IDE
PlatformIO IDE
Wireshark

Story

Read more

Code

main.cpp

Arduino
#include <ESP8266WiFi.h>
#include <WebSocketsServer.h>

WebSocketsServer webSocket = WebSocketsServer(81);

int R = 12, F = 13, L = 14, B = 15;

void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length)
{
  switch (type)
  {
  case WStype_CONNECTED:
    tone(LED_BUILTIN, 1);
    break;
  case WStype_DISCONNECTED:
    noTone(LED_BUILTIN);
    break;
  case WStype_TEXT:
  {
    int PinValue = payload[0] - '0';
    digitalWrite(payload[1] == 'F' ? F : B, PinValue);
    if (payload[2] == 'L')
      digitalWrite(L, PinValue);
    if (payload[2] == 'R')
      digitalWrite(R, PinValue);
    break;
  }
  default:
    break;
  }
}

void setup()
{
  for (int p : {LED_BUILTIN, L, B, R, F})
    pinMode(p, OUTPUT);
  WiFi.softAP("WeMos", "Vive La Resistance");
  webSocket.begin();
  webSocket.onEvent(webSocketEvent);
}

void loop()
{
  webSocket.loop();
}

platformio.ini

INI
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
lib_deps = links2004/WebSockets@^2.3.6

Credits

Majed Abouhatab, P.E.

Majed Abouhatab, P.E.

52 projects • 40 followers
Electronics Professional Engineer, Pilot, Skydiver, Runner, and World Traveler.

Comments