Configuring ESP8266 Wifi Shield/UNO with raspberry pi mqtt

So I got these esp8266 wifi shields and im trying to connect them to the wifi in order to have them receive mqtt messages from my pi.

And I followed this tutorial to get it connected to my network:

Im following this tutorial to send it mqtt messages:

I can send messages to the Arduino and I see the logs in the serial monitor but for some reason there is no voltage across either pin 3 and ground or pin 4 and ground. I’ve added logs inside the ifs so I know they’re getting called properly but voltage.

I get the raising and lowering logs in the serial monitor when I send the mqtt messages.

Here’s my code:

#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
//#include <Adafruit_INA219.h>

#define in1 3 //We are not using PWM for this demo.
#define in2 4

// Connect to the WiFi
const char* ssid = "myssid";
const char* password = "mypwd";
IPAddress mqtt_server(192, 168, 1, 113);
WiFiClient espClient;
PubSubClient client(espClient);
const byte ledPin = 0; // Pin with LED on Adafruit Huzzah UNNECESSARY
void callback(char* topic, byte* payload, unsigned int length) {
 Serial.print("Message arrived [");
 Serial.print("] ");
 for (int i=0;i<length;i++) {
  char receivedChar = (char)payload[i];
  if (receivedChar == '0')
  // ESP8266 Huzzah outputs are "reversed"
  digitalWrite(ledPin, HIGH);
  if (receivedChar == '1')
   digitalWrite(ledPin, LOW);
void reconnect() {
 // Loop until we're reconnected
 while (!client.connected()) {
 Serial.print("Attempting MQTT connection...");
 // Attempt to connect
 if (client.connect("ESP8266 Client")) {
  // ... and subscribe to topic
 } else {
  Serial.print("failed, rc=");
  Serial.println(" try again in 5 seconds");
  // Wait 5 seconds before retrying
void setup(){
 client.setServer(mqtt_server, 1883);
 pinMode(ledPin, OUTPUT);//UNNECESSARY

void setupMotor(){
    //set the pins for output
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
 //set the pins low - this will keep the motor from moving.
 digitalWrite(in1, LOW);
 digitalWrite(in2, LOW);

void raiseCurtain() {
 Serial.println("raising curtains");
  //set the pins low - this will keep the motor from moving.
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  //Spin Motor in one direction UP
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  delay(5000); //let it spin for about 10 seconds
void lowerCurtain() {
 Serial.println("lowering curtains");
    //Spin Motor in the other direction DOWN
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  delay(5000); //let it spin for about 10 seconds

  //Stop the motor
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);


void loop(){
 if (!client.connected()) {

Just to skinny things down, have you been able to just send test commands from the serial monitor to the arduino that control the desired pins?

OK how would I send a command thru the SM to control a pin?

OK how would I send a command thru the SM to control a pin?

Just looking at the board you have, you might have a problem with that. Does that board have any type of serial interface?

It does on the side pins. There is some talk about the whole serial comments bit in this instructable but I'm not well versed in the subject enough to figure out out:

I can tell you that in order to upload the above code I have to set pins 3&4 to ON and 1&2 OFF. And then in order to receive the matter message I bring them all back to OFF.

Here are the confusing bits:

This shield has a peculiarity in the contacts P1 and P2 of the DIP Switch and this particularity, in fact it generates a great doubt in the people who try to use the shield.


Step 5: Web Server With ESP8266 ESP-12E UART Wireless WIFI Shield TTL Converter for Arduino

As a primary requirement to continue this step, you should have performed step 2.

As I mentioned earlier, in order to use the shield with the Arduino through the native serial (pins D0 and D1), it is necessary that a code be loaded into the shield and that Arduino be loaded another code to send, receive and interpret the data trafficked through the native serial

I just tried it with dip switches 1&2 ON && 3&4 OFF and it also receives mqtt and logs in the SM. Just as it does with all dip switches OFF.

But still I get no voltage across the shield pins 3&4 which are the ones I need for driving my stuff.

P1, P2, P3, P4 is about the 4 DIP switches marked as box E.


Yes that I know. what I don’t know is how to interpret it because maybe the reason why the shield pins are not getting high voltages is related to that?

high voltages?
what are you talking about?

The mqtt message received by the Arduino calls for either raising or lowering the curtains by digitalWrite(high) to a particular pin. The message is received, the serial print is logged in the SM signaling the correct function is called but the voltage between that said pin and Gnd should go to 5V, but it doesn't.

oh wait, I think i just realized that the sketch is uploaded to the esp8266 mcu not the at328. So how would I send commands from the ESP8266 to my shield pins? Or do i just use my esp8266 pins? But the ESP8266 only puts out 3.3V.

I DO get voltages across GPIO3 & GND on the ESP8266 chip:

So how do I make the esp8266 send high to a UNO pin? I need 5V.

an option: upload AT firmware 1.7.2 into the esp8266 and use my WiFiEspAT library in the 328p