I thought it would be fun to add an ESP8266 to a Brian toy robot from confused.com to play the voice samples that are usually played when pressing the confused.com button on the front of the toy.

The ESP8266 will be powered by a single cell lipo that I got with a quad copter, but everything for this build should be pretty easy to get your hands on.

Step 1: What You Will Need

You will need the follow to make this Instructable:

  1. confused.com toy robot
  2. esp8266 board
  3. relay
  4. vero board
  5. vero board pins or PC fan headers
  6. dupont socket headers
  7. 3.7v single cell lipo battery
  8. toggle switch to switch the esp8266 on and off
  9. short wires
  10. solder
  11. soldering iron
  12. wire strippers
  13. wire cutters
  14. screw driver
  15. drill with drill bit to make hole for toggle switch

You could do this same thing with any toy that speaks if there was room inside it for the extra bits. This robot has a very large empty bottom half which can hold all the extra electronics with ease.

Step 2: Take the Robot Apart and Connect the Wires

The first thing to do is to take the robot apart and solder two wires onto where the button is pressing again the PCB.

The robot is held together with a few screws in the top and bottom parts.

Once the robot is apart you can undo the two screws holding the ball joint in place, so that the bottom of the robot comes away from the top.

I then soldered the two wires onto the PCB. I did this with the board still screwed into the robot as it kept the board still.

One wire is connected to a switch pin labelled sw1 and the other is on a pad on the PCB right next to the blobbed chip.

Step 3: Feed the Wires Into the Bottom of the Robot

I made two little holes in the top of the base of the robot to feed the wires through from the PCB into the bottom of the robot where the esp8266, relay and lipo will be.

I used my soldering iron tip to do this, it made a bit of a mess of the job and also of my soldering iron, but I cleaned the tip up quite well and its a pretty old tip that needs replacing anyway really.

If you want a nicer way of getting the wires through, use a small drill to make two holes into the top of the base of the robot instead.

Feed the two wire into the base, and then make a small hole / slot in the top of the robot on one side (I did it on the right hand side when looking at the robot) and push the cables into the hole / slot - again I did this with my soldering iron.

Step 4: Screw the Robot Back Together

I then screwed the ball join back together and also screwed the top of the robot back together too - fitting the head back in at the same time.

The bottom half I left unscrewed and with the front and wheels still left out so that I've got room to work and install the extra electronics.

Step 5: ESP8266 With Relay

Next we need to build the ESP8266 relay, as I'm using a NodeMCU Devkit for this I found that you also need a few other bits of electronics to switch the relay on and off. I dont know if this is because my relay isn't very good or if this will happen for everyone, but its pretty simple to wire up.

I first set this out on a breadboard to make sure it would work. Then I moved this onto the vero board.

For the circuit that I used you can see this in my other instructable : https://www.instructables.com/id/Using-an-Esp8266-Arduino-to-Control-a-Relay-Using-/

I've used dupont header pins on the vero board so that the ESP8266 can be removed at a later date if needed.

I've also used old PC fan headers for the power to the ESP8266 and for connecting the relay to the vero board, but this is only because I have loads of these and don't believe in soldering wires straight to the vero board. When I do run out of these fan headers I'll go back to using vero pins.

Step 6: Install ESP8266, Relay, Battery and Toggle Switch Into the Robot

This is pretty straight forward, you just need to get everything inside. It took a bit of fiddling to get everything to stay in but once its all screwed back together nothing will fall out anyway.

Step 7: Sketch for the ESP8266 and Webpage to Control It (using MQTT)

The sketch I wrote to control the robot is pretty simple, it just connects to my Wifi then subscribes to the MQTT broker and waits for it to send a message of confused/speech 'ON'. Once it gets this message it will switch the relay on for 0.5 seconds (which will make the robot say something) then send 'OFF' back to the MQTT broker so that the robot doesn't go into a loop of saying stuff :)

#include <ESP8266WiFi.h>

#include <PubSubClient.h>

// Update these with values suitable for your network.

const char* ssid = "wifi-ssid"; const char* password = "wifi-password"; const char* mqtt_server = "mqtt-broker-ip";

WiFiClient espClient; PubSubClient client(espClient); long lastMsg = 0; char msg[50]; int value = 0; int lastvalue = 0; float temp = 0; int inPin = 5; int speechpin = 4; String speech; String strTopic; String strPayload;

void setup_wifi() {

delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }

Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); }

void callback(char* topic, byte* payload, unsigned int length) { payload[length] = '\0'; strTopic = String((char*)topic); if(strTopic == "confused/speech") { speech = String((char*)payload); if(speech == "ON") { Serial.println("ON"); digitalWrite(speechpin, HIGH); delay(100); client.publish("confused/speech","OFF",1); } else { Serial.println("OFF"); digitalWrite(speechpin, LOW); } } } void reconnect() { // Loop until we're reconnected while (!client.connected()) { Serial.print("Attempting MQTT connection..."); // Attempt to connect if (client.connect("arduinoClient_confused")) { Serial.println("connected"); // Once connected, publish an announcement... client.subscribe("confused/#"); } else { Serial.print("failed, rc="); Serial.print(client.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(5000); } } } void setup() { Serial.begin(115200); setup_wifi(); client.setServer(mqtt_server, 1883); client.setCallback(callback); pinMode(speechpin, OUTPUT); digitalWrite(speechpin, LOW);

} void loop() { if (!client.connected()) { reconnect(); } client.loop();


Then I wrote a simply webpage in php to send the MQTT the 'ON' message as follows:

$say = $_GET['submit'];

if($say == "Say Something")
{ system("mosquitto_pub -h -t 'confused/speech' -m 'ON'"); } ?>

<form method=get action=index.php>

<input name="submit" type="submit" value="Say Something" style="display: block; width: 100%; height: 100%;">


Step 8: Its Alive!

If everything is working as it should, you just need to load the webpage (that you're serving from a webserver) - and click the button and your robot should speak :)

About This Instructable




More by padeath:ESP8266 + Confused.com Brian Toy Robot Magic 8 Ball Using Esp8266 and I2c LCD Screen DS18b20 Temperature Sensor As a Thermostat 
Add instructable to: