Special Feature

For this micromouse, we decided on our special feature being the addition of communication capabilities of the micromouse, this would work using bluetooth or wifi in order to enable the micromouse to be remote controlled and also to send/export data from the micromouse. Full details referring to the technicals behind this bluetooth can be found on Jake’s Blog Post.

Uses

Firstly we can use the bluetooth to send movement requests to the micromouse, this allows any device with the valid app to communicate with the micromouse and

  • Remote Control
    • The ability to allow us to steer the micromouse, this can be very useful when the micromouse is stuck in a confined area and act as a redundancy incase the IR line tracking system goes wrong.
  • Mapping
    • By tracking every movement the micromouse makes, it will be possible repeat the exact movements and more importantly allow the app to export a map of the route the micromouse took.

Code

In order to communicate to the bluetooth, some code is required, the basics goes as follows:

#include <SoftwareSerial.h>
#include <ArduinoBlue.h>

const unsigned long BAUD_RATE = 9600;

const int BLUETOOTH_TX = 18;
const int BLUETOOTH_RX = 19;
const int BLE_EN = 7;

SoftwareSerial bluetooth(BLUETOOTH_TX, BLUETOOTH_RX);
ArduinoBlue phone(bluetooth); 

void setup() {
    pinMode(BLE_EN, OUTPUT);
    digitalWrite(BLE_EN, LOW);
    bluetooth.begin(BAUD_RATE);
    delay(1000);
    bluetooth.write("AT+NAME=EG252");
}

void loop() {
    // main program will go here
}

We can then send data via serial which will be sent via the BLE112.

In order to communicate via WiFi a different set of code is required. This code sets up a the micromouse as a wifi peripheral such that the micromouse itself runs the web server. By connecting to the micromouse’s local IP address (which can be found on the wifi in settings) you are greeted by a simple HTML response.

Also by accessing the /wifi route, you are then show a list of all the arguments passed into the HTTP request. These routes can be extended as much as you want, and the /wifi route shows you how to handle GET and POST requests which enables us to extend this in order to leverage the ability to send and receive data. Eg by utilising Ajax in Javascript we can build a simple API to send a stream of data from one route to another enabling real-time updates about the micromouse.

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char *ssid = "Micromouse November";

const char *password = "totallySecret";

ESP8266WebServer server(80);

void handleRoot() {

  server.send(200, "text/html", "<h1>You are connected</h1>");

}

void handleWifi() {
  String message = "";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";

  for ( uint8_t i = 0; i < server.args(); i++ ) {
    message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
  }

  server.send ( 200, "text/plain", message );
  button = 1;
}



void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  
  server.on("/", handleRoot);
  server.on("/wifi", handleWifi);
  
  server.begin();
}

void loop() {
  server.handleClient();
  delay(10);
}

App

A basic design for the app can be seen below showing what the basic functionality of the app would contain.

Using Wi-Fi requires a simple web browser which nearly every internet connected device has.

Costs

The SH-HC-08 referred to in the blog post referenced to earlier is a breakout board and isn’t the product to be used on the final system. There is no need to change software between these two devices.

The BLE112-A-V1 costs €9.56 which as of 7/5/21 is £8.30

The ESP8266 costs $6.95 which as of 7/5/21 is £5.01

In the end we chose to go with Wifi simply because it is more versatile, in that it can be used to handle multiple clients at once, also doesn’t require an app due to web browser and it is cheaper.

Design a site like this with WordPress.com
Get started