0

I have a very small test project running on an Attiny85 (set to internal 8MHz).

Everything works when powering the circuit from an Arduino (3.3 or 5.0 volt). But when changing the power to a 18650 battery with a voltage of around 4.0v the Attiny85 still works, because the LED blinks, but nothing is coming through via the UART. What could be the reason for this?

#include <SendOnlySoftwareSerial.h>
#define PHOTO_RESISTOR_PIN A1
#define UART_TX_PIN 0
#define LED_PIN 1

SendOnlySoftwareSerial esp(UART_TX_PIN);

void setup() {
  esp.begin(9600);
  pinMode(PHOTO_RESISTOR_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  pinMode(UART_TX_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  int light = analogRead(PHOTO_RESISTOR_PIN);
  esp.println(light);
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  delay(1000);
}

circuit

4
  • 1
    Do yoou not have the ground of the ATTiny circuit connected to the ground of the UART board??? – Majenko May 1 '20 at 15:13
  • That was it! So the reason why that works when running off the Arduino power is that they share the same ground in the computer (that powers them both)? – miccet May 1 '20 at 15:16
  • Yep. You might like to read this:majenko.co.uk/blog/importance-sharing-grounds – Majenko May 1 '20 at 15:21
  • Absolutely, thank you! – miccet May 1 '20 at 15:40
3

Unless you connect the ground of your ATTiny to the ground of your USB UART interface there is no circuit for the electrons to flow around.

It works when powered from the computer because everything shared the same ground connection.

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.