Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here


Home Forums Mayfly Data Logger ESP8266

Viewing 5 reply threads
  • Author
    • #12783

        Has anyone successfully connected an ESP8266 to the Mayfly? Just looking for some direction.

        My end goal is to have an xBee to wifi gateway. If I can get it to work, I’ll connect the ESP to TX0/RX0 and have the xBee in the socket. Right now, I’m trying to connect an ESP8266 ESP-01 to the TX1/RX1 pins. Do the TX1/RX1 pins transmit at 3.3V? I can provide more information as to how I’ve got things connected and the code I’m trying to test.

        Thank you in advance.

      • #12785
        Sara Damiano

          All of the Mayfly pins are at 3.3V.

          I’ve done a decent amount with a Mayfly and an ESP8266 using the “AT” firmware on the ESP8266. I haven’t had any problems with it.

        • #12789

            Sara, thank you for your response. I’m glad to hear it is possible. Here’s what I’ve got thus far.

            Mayfly <—-> ESP8266 ESP-01
            Rx1 <——-> Tx
            Tx1 <——-> Rx
            Gnd <——-> Gnd
            Sw3 <——-> VCC & CH_PD

            I attached a screenshot of the Serial Monitor with the results I get back from the ESP when I send AT commands to it. Do I have a baud rate issue?

            To test if the ESP was working, I connected it to an Arduino UNO via an Aideepen Adapter Module. The ESP worked and the responses were as they should be.

            I’ll continue to play around with my setup and see if I can figure it out. Any insight would be greatly appreciated.

            The second image attached is the Serial Monitor when I changed the code to Serial1.begin(74880);

          • #12794


              I changed the default baud rate on the ESP8266 from 115200 to 9600 and things started working. The AT command I used was AT+UART_DEF=9600,8,1,0,0

              Here is where I found this command:

              Just curious why the ESP8266 wasn’t working at 115200? Does the Mayfly not support this baud rate?

            • #12795
              Sara Damiano

                Yes, I’ve had problems with the Mayfly receiving data at 115200. The Mayfly is only running at 8MHz and Atmel says the error rate at that baud and crystal combination is 8.5%. The error is a much bigger problem on the receiving end than the sending end. So the serial port monitor and the ESP8266 understand what the Mayfly is saying at 115200, but the Mayfly has a hard time hearing back from the esp at that speed. And it gets especially bad when running a program like yours that’s trying to synchronously write and read from both serial ports at the same time. So when the Mayfly said “AT” to the ESP8266, the esp actually echoed “AT” and then said “OK” but the Mayfly misheard and it got garbled into that “au?” (AT) and “C?j5” (OK). After AT+RST you’ll always see some junk because the ESP8266 prints out some notes when it boots at a different baud rate than it’s normal talk speed.

                So.. in short:
                – If you just want to talk to the ESP8266 and don’t care about what it says back, you’re fine doing just as you are

                – If you want to talk to the ESP and can handle listening to it in your program without simultaneously printing it to Serial, you’re probably also alright, but somethings might be garbled

                – If you want to talk to the ESP and echo its responses and make sure they’re always correct, you need to slow the ESP down.

                To change the baud rate of the ESP8266: (for 9600, 8N1)

              • #12796
                Sara Damiano

                  Oops. Sorry. I’d typed that and didn’t see your response. But yes, slowing down the ESP8266 is the way to go if you want to make sure everything is heard correctly.

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.