0

I have an Arduino Uno attached to a Parallax Boe-Bot shield, and plugged into the shield breadboard, the Parallax WX ESP8266 Wi-Fi SIP.

When I attach the DO/DI pins of the ESP8266 board to the RX/TX pins of the Uno, it does not work without a very narrow range of resisters in a voltage divider configuration. I'm trying to learn more about electronics and I would like to know, why these specific values in this specific case?

The DI/DO pins of the SIP are documented as "SIP - output high (set by Vin voltage, either 3.3 or 5.0 V), low 0 V. Input high >Vin/2, input low

When I attach the Parallax shield 5V to the SIP Vin, and the DO to a 220 resister to RX, and also DO to a 1K resister to ground, and DI to 220 to TX and also DI to 1K to ground, serial communications works fine.

If I use the shield 3.3V to SIP Vin, it does not work.

If instead of 220 / 1K, I use 470 / 2K, or 4.7K / 10K, for example, it doesn't work.

If I only set up the voltage divider on the RX pin, it doesn't work.

However, if instead, with either 5V or 3.3V to the SIP Vin, and no resisters, I can run the Uno TX direct to the SIP DI, and the SIP DO to a digital pin, and run that digital pin with SoftwareSerial, for example.

I can run both DI and DO directly with SoftwareSerial, and either 5V or 3.3V to supply Vin.

It's only when I want to connect DO/DI direct to use the Uno's UART (because I don't want serial-driving interrupts to interfere with servo pulses) that I have to carefully select these resisters (through trial and error) and be sure to power with the 5V. Some combinations get communication with errors, but just these specific values (out of the resisters I happen to have on hand) work.

I understand that it is something to do with 3.3V vs TTL serial, but I would like the details. (I will be picking up a logic level converter to try in place of the voltage divider.)

EDIT:

By "not working" -- in all but two cases, with fresh batteries, the SIP seems to get data from the Uno TX, and the DO lamp on the SIP flashes, but Serial.read() sees nothing on the Uno regardless of configured rates. In one of the two cases (I can't recall which) unintelligible, incomplete data is read on the RX pin, and in the last, good case -- where both pins have voltage dividers and the SIP is powered by the 5V line of the Arduino shield (for the Boe-bot) -- with those specific resister values -- the data from the SIP DO is received on the Serial, from pin RX.

  • 1
    A schematic would be in order here. Your question is a bit vague with a few alternative configurations and voltages. Please post a specific configuration that is causing you problems. – Nick Gammon Dec 9 '17 at 5:02
  • I'll add some diagrams. – Jim Flood Dec 9 '17 at 6:33
2

The output of a voltage divider is:

Vout = Vin * R2 / (R1 + R2)

Where R2 is the resistor in your case which is connected to ground.

See: Sparkfun - voltage dividers

Now in your example of 220 / 1k you have a multiplier of:

Vout = Vin * 1000 /1220 = Vin * 0.82

If both boards are running at 5V you don't need the voltage divider at all, but if you do use it the output would be:

Vout = 5 * 0.82 = 4.1

Now the Atmega328P chip on the Uno has the electrical characteristics defined in the datasheet, amongst others is that a digital pin high has to have a minimum of 0.6 * Vcc (if Vcc is in the range 2.4V to 5.5V)

So if Vcc is 5V (which it is on the Uno) you have to have 0.6 * 5 (that is, 3V) as the minimum for it to be recognised as high.

So, using the voltage divider of 220/1k you have a high still being 4.1V which is in the range 3 to 5V.

However if you have the board set to 3.3V then the output of the voltage divider will be 3.3 * 0.82 = 2.76V which is too low to be recognized as high.

For sending serial from a 3.3V board to a 5V board, simply omit the voltage divider, and then the 3.3V (for high) is in range (it has to be 3+ volts).

However for sending from a 5V board to a 3.3V board you do need a voltage divider (or level shifter) because 5V is too much for a 3.3V board. You can use a voltage divider calculator to simplify the maths.

Something like 1k/1.8k would be about right.

Vout = 5 * 1800 / 2800 = 3.21

According to the documentation for the Parallax WX ESP8266 Wi-Fi Module:

(9) Level shifters and buffers

To ensure maximum compatibility with a wide range of 3.3V and 5V microcontrollers and development boards, the Parallax Wi-Fi module includes voltage level shifters and buffers to ensure that the logic voltage levels at the SIP header are set by the VIN voltage level. If you supply 3.3V to VIN, then the IO pins logic voltage level will be 3.3V. If you supply 5V to VIN, then the IO pins logic voltage level will be 5V

I don't see why you need to use a voltage divider or level shifter in the first place.


References

  • That is what I read elsewhere, but that is not how this hardware combination behaves. Of the combinations I listed, only 220 / 1K works, and only if both are connected (only one divider from DO to RX will not work). 470 / 2K gives 4V and does not work. There must be some other consideration for pins 0 and 1 on the Uno, which happen to be wired to the internal UART. I will pick up a 1.8k resistor and try that, though. – Jim Flood Dec 9 '17 at 4:30
  • If you look at the Uno reference schematic there is a 1k resistor in series with both D0 and D1 and the UART. However I don't quite see how that would alter your results. – Nick Gammon Dec 9 '17 at 5:00
  • Can you clarify what "does not work"? Sending from the SIP to the Uno? Vice-versa? At what operating voltages? – Nick Gammon Dec 9 '17 at 5:01
  • Also see amended answer regarding the level shifting requirements. – Nick Gammon Dec 9 '17 at 5:19
  • I didn't see that level shifters / buffers note -- thx. By "does not work", the SIP DO/DI LEDs flash, and it appears to get a command, but the Uno does not read any response on Serial. SoftwareSerial reads it fine on another pin. In one case of resisters (I'll have to double check which) Serial gets a read error, but in other cases, nothing is detected. – Jim Flood Dec 9 '17 at 6:22

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.