Akila Uyanwatta
Akila Uyanwatta

Reputation: 603

ATTiny serial communication does not work at 3.3V with ESP8266 (NodeMCU V3)

I am transmitting data from ATTiny85 to ESP8266(NodeMCU v3). I am powering NodeMCU using USB cable. It works fine when I power up ATTiny using 5V.

However I'm planning to transfer my project to ESP32, which is not 5V tolerant. Therefore I have to run ATTiny at 3.3V (which is possible according to datasheet). However I'm not getting intended results when I'm using 3.3V power to ATTiny85. I'm getting some nonsense. Using level converters is one alternative but I like to know what I have done wrong.

To clarify, Only change I'm doing is powering ATTiny with 3.3V instead of 5V.

I have prepared the following demo to demonstrate my situation. Thanks in advance :)

I'm using Ardiono 1.8.10

NodeMCU core : 2.7.4

ATTiny85 is running using 8MHz internal oscillator.

NodeMCU code

char rx;
void setup()  
{
  Serial.begin(57600);
}
 
void loop() 
{
  if (Serial.available()){
    rx=Serial.read();
    Serial.print(rx);
    }
}

ATTiny85 code

#include "SoftwareSerial.h"

SoftwareSerial Monitor(5, 4);

uint8_t x=0; //temp
uint8_t y=128; // ECG
void setup() {
  Monitor.begin(57600);
}

void loop() {
  Monitor.print("E"+String(int(y)));
  Monitor.print("T"+String(int(x)));
  x=x+1;
  y=y-1;
  delay(10);
}

Serial monitor od NodeMCU when ATTiny is running at 5V from Arduino UNO

T95E32T96E31T97E30T98E29T99E28T100E27T101E26T102E25T103E24T104 Screen-Shot 1

Serial monitor od NodeMCU when ATTiny is running at 3.3V from Arduino UNO

⸮qxt⸮q99⸮qx5⸮q9x⸮qx6⸮q97⸮qx7⸮q96⸮qxx⸮q95⸮qx9⸮q9t⸮q9`⸮q93⸮q9q⸮q9r⸮q9r⸮q9q⸮q93 Screen-Shot 2

Serial monitor od NodeMCU when ATTiny is running at 3.3V from ESP8266

3x⸮rtv⸮q37⸮rt7⸮qsv⸮rtx⸮qsu⸮rty⸮q3t⸮r5`⸮q3s⸮r5q⸮q3r⸮rur⸮q3q⸮r5s⸮q3`⸮r5t Screen-Shot 3

Upvotes: 1

Views: 1197

Answers (2)

d3rbastl3r
d3rbastl3r

Reputation: 513

You said you run the ATTiny85 at 8MHz ... Did you enabled the divider CKDIV8? If yes, ATTiny would have a hard time to maintain this baud rate.

Your data (shown in the first post) looks like ATTiny send some bits not in time. Keep in mind that the internal oscillator is not that stable (increasing voltage seems to make the internal oscillator work more stable), but stable frequency is mandatory to perform stable asynchronous data transfair. Switching to the external crystal oscillator should stabilize the UART Communication (i know, ATTiny85 has not that much pins and using 2 for a crystal, 2 for the UART communication will leave you only with one additional pin. Probably you can switch to ATTiny84 instead).

Note: If you choose a crystal and you know you will implement UART configuration, choose the frequency of the crystal which can be divided by your preferred baud rate. Especially if you are going to use the USI of the ATTiny85 this will help to avoid error in the transaction (for example you could use crystal with the frequency of 7.3728MHz).

Also keep in mind that you need to consider the voltage before selecting a crystal (means if you need to choose frequency >10MHz you need to work with the voltage between 4.5V and 5.5V)

Upvotes: 1

Akila Uyanwatta
Akila Uyanwatta

Reputation: 603

It looks like ATTiny85 has to run SoftwareSerial at 38400bps when you're powering it using 3.3V.

However it works fine at 57600bps when powering it with 5V.

Upvotes: 2

Related Questions