Chat freely about anything...

User avatar
By marciokoko
#86153 So Im trying to send mqtt messages to my uno using this shield:


I've wired up Rx/Tx from the UNO (bent away the shield pins) to Rx/Tx on debug port of my shield. I've uploaded this code to my ESP8266 shield and I was sending mqtt messages and receiving them on the shield and I could see the logs for raising and lowering as expected when the mqtt messages were successfully parsed by my code. I just realized that this code was in my ESP8266, not my shield, which is why the voltage on in1 and in2 pins in code was still 0. I just tried V between GPIO3 & GND on ESP chip:


and i got the 3.3V correctly.

Now I need 5V, so is there any way to get the ESP8266 to send HIGH to the Arduino UNO pins?

Code: Select all#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()) {
User avatar
By JurajA
marciokoko wrote:Could you point me to a resource on how to do that?

you know how to print to Serial Monitor. do the same to send data to other MCU.
learn how to parse input from Serial Monitor and how to choose a good format of data to parse them. then use the same to parse data from other MCU.