Hola a todos. Si no me hecháis una mano, me veo incapaz de solucionar este problema: Quiero programar un attiny 85 con un Arduino Uno. Pero si intento programar el Attiny para conectarlo a un display SSD1306, me arroja el error que he puesto por titulo del post. He mirado y probado infinidad de cosas y nada, sigue arrojandome el error. Si alguien no me ayuda, lo tendré que dejar por incapacidad de poder hacerlo. El quemado de bootloader se hace correctamente.
Si alguien me puede ayudar…Saludos.
No veo código (usa etiquetas), no se cómo lo has cableado.
Por favor lee las normas del foro y completa toda la información para poder responderte adecuadamente.
Muchas gracias por contestar. Creo que ya he salido ¿? de este atolladero. Por fin he logrado que ya no me salga el maldito error. El error me lo daba cuando intentaba cargar un ejemplo de la libreria SSD1306 o Ug8lib, pero no me dá el error usando la libreria Tiny4kOLED. No sé si será esto normal, pero por lo menos ya tengo una base sobre la que apoyarme para avanzar. Lo dicho, muchas gracias por atenderme.
Hi,
Otra cosa que tienes que tener cuidado es que el atttiny85 para comunicarse con el I2c necesitas usar el #include <TinyWireM.h> y no puedes usar el Wire.
@ TAJO20 Cuando el hilo este resuelto hazmelo saber.
He seguido tu consejo, y nada, sigue igual. Muchas gracias.
Hi,
Adjunto un link que explica como usar el sdd1306 y las librerias que el usa para programarla. https://www.instructables.com/ATTiny85-connects-to-I2C-OLED-display-Great-Things/
Muchas gracias, lo intentaré otra vez, a ver si hay suerte. Ya te contaré.
Hola de nuevo, amigos. Las obligaciones laborales no me han permitido seguir con el problema durante estos dias de ausencia. Este es el mensaje de error que me lanza el IDE:
c:/users/usuario/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: C:\Users\Usuario\AppData\Local\Temp\arduino_build_332857/tiny_temp_dht22.ino.elf section `.text' will not fit in region `text'
c:/users/usuario/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: **region `text' overflowed by 396 bytes**
collect2.exe: error: ld returned 1 exit status
Se encontraron varias bibliotecas para "Wire.h"
Usado: C:\Users\Usuario\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.4.1\libraries\Wire
No usado: C:\Users\Usuario\Documents\Arduino\libraries\Wire-master
exit status 1
Error compilando para la tarjeta ATtiny25/45/85 (No bootloader)
Creo que el error es un desbordamiento que he resaltado en negrita. ¿Es ese el problema?. ¿Como se soluciona?.
Agradecido a quien me ayude.
¿Y si nos muestras el código que quieres cargar? (ya te lo había dicho @Surbyte en el post #2)
Aparentemente hay dos problemas, uno parece relacionado a la memoria pero tambien te está diciendo que estás intentado usar dos librerías distintas para la comunicación I2C. De hecho te está aclarando cuál de las dos el compilador decidió usar, pero debes corregirlo (y veo que tampoco le diste bolilla a @tauro0221 que te dijo cual es la librería correcta que debes usar).
Sube el código y lo vemos (mira en las Normas del foro la forma correcta de hacerlo).
Saludos
Gracias por molestarte en ayudarme.
1º Hice lo que dijo tauro0221, pero seguí igual. (Gracias tauro0221).
2º El codigo simplemente lo he copiado de un proyecto colgado en la red, y presumiblemente debe de funcionar, (a quien le funcione).
3ª Este es el codigo
#include <DHT.h>
#include <Tiny4kOLED.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#define I_PINB PCINT3
#define I_PIN PB3
#define I_VECTOR PCINT0_vect
#define adc_disable() (ADCSRA &= ~(1<<ADEN)) //disable ADC converter
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN,DHTTYPE);
const uint8_t width = 128;
const uint8_t height = 64;
volatile bool turned = false;
/*
*
* Interrupt handler
*
*/
ISR(PCINT_VECTOR){ //interrupt always recovers from sleep
if( digitalRead(I_PIN) == HIGH ) {
turned = true; //set the flag to redraw screen again
}
}
void setup() {
cli(); //turn off interrupts
PCMSK |= (1 << I_PINB);
GIMSK |= (1 << PCIE);
pinMode(I_PIN, INPUT);
sei(); //turn on interrupts
adc_disable(); //save power turning off the converter
set_sleep_mode(SLEEP_MODE_PWR_DOWN); //set the type of sleep to deep sleep
oled.begin(width, height, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br); //start oled object
oled.setFont(FONT8X16); //this font looks better than the other one
drawScreen();
oled.on();
delay(2000);
dht.begin();
turned = true; //flag for drawing screen
}
void sleep(){
sleep_enable();
sleep_cpu();
}
void loop() {
if (turned){
cli(); //turn off interrupts
oled.on();
float h = dht.readHumidity();//false read to reset dht cache
delay(2200);//wait dht to load
h = dht.readHumidity();
float t = dht.readTemperature();
float i = dht.computeHeatIndex(t,h,false);
oled.setCursor(55, 1);
oled.print(t);
oled.print("~C");
oled.setCursor(55, 3);
oled.print(h,0);
oled.print("%");
oled.setCursor(55,5);
oled.print(i);
oled.print("~C"); //the ~ symbol was changed on the library to look like a ° degree symbol
delay(5000); //show for 5 seconds
oled.off();
turned = false;
sei();//attach interrupts again
}
sleep(); //always go to sleep at the end
}
void drawScreen() {
//draws the frame an the main text
for (uint8_t y = 0; y < 8; y++) {
oled.setCursor(0, y);
oled.startData();
for (uint8_t x=0; x<128; x += 2) {
oled.sendData(0b10101010);
oled.sendData(0b01010101);
}
oled.endData();
}
oled.setCursor(0, 0);
oled.startData();
oled.sendData(0b11111111);
oled.repeatData(0b00000101, width - 2);
oled.sendData(0b11111111);
oled.endData();
for (uint8_t y = 1; y < (height - 8) / 8; y++) {
oled.setCursor(0, y);
oled.startData();
oled.sendData(0b11111111);
oled.repeatData(0b00000000, width - 2);
oled.sendData(0b11111111);
oled.endData();
}
oled.setCursor(0, (height - 8) / 8);
oled.startData();
oled.sendData(0b11111111);
oled.repeatData(0b10100000, width - 2);
oled.sendData(0b11111111);
oled.endData();
oled.setCursor(4, 1);
oled.print("Temp:");
oled.setCursor(4, 3);
oled.print("Hum:");
oled.setCursor(4,5);
oled.print("Sens:");
}
Ahora lo he hecho bien, ¿no?.
Y aquí el mensaje de error:
c:/users/usuario/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: C:\Users\Usuario\AppData\Local\Temp\arduino_build_148746/tiny_temp_dht22.ino.elf section `.text' will not fit in region `text'
c:/users/usuario/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: region `text' overflowed by 396 bytes
collect2.exe: error: ld returned 1 exit status
Se encontraron varias bibliotecas para "Wire.h"
Usado: C:\Users\Usuario\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.4.1\libraries\Wire
No usado: C:\Users\Usuario\Documents\Arduino\libraries\Wire-master
exit status 1
Error compilando para la tarjeta ATtiny25/45/85 (No bootloader).
Si sigo haciendo algo mal, dímelo.
Hi,
Adjunto un sketch para que pruebes compilandolo. A mi me compila sin errores pero no puedo probar si trabaja pues no encuentro mi SSD1306. Yo uso el attiny85 para projectos menores pero es bien flexible. En uno de los ejemplos explican que debes de declarar al TinyWireM antes de la declaracion del Tiny4kOLED.Si lo no lo haces entonces la libraria va a instalar al Wire.h y por eso el error. El sketch se supone que haga un scrollng.
ejemplo:
#include <TinyWireM.h>
#include <Tiny4kOLED.h>
/*
* Tiny4kOLED - Drivers for SSD1306 controlled dot matrix OLED/PLED 128x32 displays
*
* Based on ssd1306xled, re-written and extended by Stephen Denne
* from 2017-04-25 at https://github.com/datacute/Tiny4kOLED
*
* This example shows how the scrolling features work.
* When scrolling, the double buffering of screens cannot be used.
*
*/
// Choose your I2C implementation before including Tiny4kOLED.h
// The default is selected is Wire.h
// To use the Wire library:
//#include <Wire.h>
// To use the Adafruit's TinyWireM library:
#include <TinyWireM.h>
// To use the TinyI2C library from https://github.com/technoblogy/tiny-i2c
//#include <TinyI2CMaster.h>
// The blue OLED screen requires a long initialization on power on.
// The code to wait for it to be ready uses 20 bytes of program storage space
// If you are using a white OLED, this can be reclaimed by uncommenting
// the following line (before including Tiny4kOLED.h):
//#define TINY4KOLED_QUICK_BEGIN
#include <Tiny4kOLED.h>
// The F macro is not able to be used outside of methods.
// The following two lines place a string in flash memory,
// and get a reference to it as though it had been created as
// F("This is an example of scrolling text. ")
// while also allowing sizeof(textToScrollData) to return
// the length of the string (including the null terminating character).
const char textToScrollData[] PROGMEM = { "This is an example of scrolling text. " };
DATACUTE_F_MACRO_T * textToScroll = FPSTR(textToScrollData);
uint16_t nextRowOfTextToDraw;
void setup() {
oled.begin();
// Two rotations are supported,
// The begin() method sets the rotation to 1.
//oled.setRotation(0);
// Some newer devices do not contain an external current reference.
// Older devices may also support using the internal curret reference,
// which provides more consistent brightness across devices.
// The internal current reference can be configured as either low current, or high current.
// Using true as the parameter value choses the high current internal current reference,
// resulting in a brighter display, and a more effective contrast setting.
//oled.setInternalIref(true);
// Two fonts are supplied with this library, FONT8X16 and FONT6X8
// Other fonts are available from the TinyOLED-Fonts library
oled.setFont(FONT8X16);
// This example does not use the double buffering ability of 128x32 OLED screens
// so the display should be set up, rather than just cleared, before turing on
setupInitialDisplay();
// If the text to scroll needs to start on-screen, it can be initialized,
// clipped to the scrolling window
oled.setCursor(5, 1);
// Start drawing the text from the beginning pixel, clip at 118 pixels.
oled.clipText(0, 118, textToScroll);
nextRowOfTextToDraw = 118;
oled.on();
}
void loop() {
// Content scrolling is controlled by the microcontroller.
// Each request to scroll content results in the content shifting one pixel left or right
// The parameters are start page, end page, start column, end column
oled.scrollContentLeft(1, 2, 5, 122);
// However the scroll happens after the command is given, and a delay is required before
// the edge of the scrolled content can be safely overwritten.
// The length of the delay is 2 divided by the refresh rate.
// So if the refresh rate is 100 Hz, then the delay required is 20ms.
// Unfortunately the refresh rate is not easy to determine.
// The SSD1306 is capable of refresh rates between 4 and 489 Hz.
// The default refresh rate for a 128x32 screen is 215.5 Hz, requiring a delay of 9.3ms
// The default refresh rate for a 128x64 screen is 107.8 Hz, requiring a delay of 18.6ms
delay(10);
// Draw one column of the text at the right hand end of the scrolling window.
oled.setCursor(122, 1);
oled.clipText(nextRowOfTextToDraw++, 1, textToScroll);
// Wrap the text...
// sizeof(textToScrollData) is 1 byte longer than the text
// (in includes the end of string marker)
// The font width is 8 pixels
if (nextRowOfTextToDraw >= (sizeof(textToScrollData) - 1) * 8) {
nextRowOfTextToDraw = 0;
}
// Fastest scrolling speed is slightly too quick, lets add another delay:
delay(20);
}
void setupInitialDisplay() {
// Draw a border around the screen, to demonstrate scrolling the region within it.
oled.setCursor(0, 0);
oled.startData();
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.sendData(0x7F);
oled.sendData(0x3F);
oled.sendData(0x1F);
oled.sendData(0x0F);
oled.sendData(0x07);
oled.repeatData(0x03, 128-14);
oled.sendData(0x07);
oled.sendData(0x0F);
oled.sendData(0x1F);
oled.sendData(0x3F);
oled.sendData(0x7F);
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.endData();
oled.setCursor(0, 1);
oled.startData();
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.repeatData(0x00, 128-4);
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.endData();
oled.setCursor(0, 2);
oled.startData();
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.repeatData(0x00, 128-4);
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.endData();
oled.setCursor(0, 3);
oled.startData();
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.sendData(0xFE);
oled.sendData(0xFC);
oled.sendData(0xF8);
oled.sendData(0xF0);
oled.sendData(0xE0);
oled.repeatData(0xC0, 128-14);
oled.sendData(0xE0);
oled.sendData(0xF0);
oled.sendData(0xF8);
oled.sendData(0xFC);
oled.sendData(0xFE);
oled.sendData(0xFF);
oled.sendData(0xFF);
oled.endData();
}
Muchas gracias, tauro0221, voy a probarlo. Luego te cuento. Saludos.
¡¡¡¡ Por fiiinnn !!!!! ¡¡¡¡¡ MUCHAS GRACIAS tauro0221 !!!!! No ha habido problema en compilar y cargar el sketch que me has puesto. Funciona bien. Sigo enredando a ver si me desatasco ya de una vez. ¡¡¡¡ MUCHAS GRACIAAS !!!.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.