Circuit explanation-

  1. Arduino Uno connected to multiple sensors and to 16 x 2 LCD.
  2. Uno's TX pin to ESP-01 RX pin.
  3. Uno has been programmed to read values from sensors and display them on LCD along with printing them on Serial Monitor.
  4. ESP-01 has been programmed to receive values from Serial Monitor and transmit it to ADAFRUIT MQTT server.

Problem - However when i am using USB to power the Uno it is successfully displaying data on LCD as well as to Serial Monitor and values are succesfully being send on the MQTT server after being read from Uno's serial. But when Uno is battery powered, serial communication stops.

I have tried adding 2 decoupling capacitors of 100uF to 12V battery supply. Battery are rechargeable cells.

What could be the issue?

  • 2
    Sure that was done, because your question lacks important information. How much current can your battery supply? How are the Uno and the ESP connected to the supply? Have you investigated, if the serial communication stop is really the problem or just a symptom? For example you may have got a reset due to a dip in the power supply. Maybe try to add a life signal like toggling an LED every half second, or let the led blink once at startup, so that you can see, if there was a reset. – chrisl Mar 28 at 19:35
  • Uno is not resetting that i am sure. Right now I am using a 12v/1Amp adapter to power up the Uno and still problem persists. Is even 1A not enough ? – Rohan Mar 28 at 19:44
  • And how is the ESP connected? It uses a lot of power, especially when connecting to a network. I remember something like up to 600mA, but I'm not sure about that. – chrisl Mar 28 at 19:48
  • 2
    how can esp-01 communicate over Serial without common ground? – Juraj Mar 28 at 19:56
  • 2
    I think you should not power an ESP from the 3.3V pin of an Uno. According to the datasheet of the LP2985 (the voltage regulator on the Uno Rev3) it can provide only 150mA at max. And as Juraj wrote, if you want circuit to interact in some way, you need a common ground or a circuit with something like an optocoupler. There is no electrical circuit with only 1 wire between the devices. – chrisl Mar 28 at 19:59

I will put the solution from the comments into an answer.

All devices, that should interact through electrical wires with each other, must have a common ground. Ground is the point, from which the voltage is measured, and the devices need a reference, that is not only valid for themselves, but also valid for the communication partner.

You can think of the following analogy: Image that you and a friend have each one ball, that you are throwing into the sky (a positive height/voltage) and catching it again (zero height/voltage --> ground). While you stand on the parking lot, your friend is standing on a high building. As long as you both only play this with yourself, it is easy for you to throw and catch the ball, because you can easily measure the height of the ball and it will always behave the same. But know imagine, that you want to play together. The height/voltage, that your ball reaches is still positive for you. But from the perspective of your friend it will look, like a large negative height/voltage. How should your friend interpet that and how should he now play with you?

In some electrical circumstances you don't want to connect the grounds of two devices together (maybe because of noise on the ground line). Then you have to achieve galvanic isolation, so no electrical connection between those two. An optocoupler is a device, that can achieve this. Basically it's just an LED and a phototransistor in one casing. From one device you power the LED. Due to the LEDs light, the phototransistor (which is connected to the other device) will become conductive. In combination with a pullup/pulldown resistor on the phototransistor you can have communication without common grounds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.