[Solved] Attiny85 and 24lc256 on i2c taking temperature. how to read it?

Hello all,
in experimenting, ive got an attiny85, 24lc256, lm34 and max1555 with a 110mah lipo taking temperature every minute for about 20 minutes. this experiment is all part of my learning, my question is, where do i go from here? specifically, instead of me pulling my eeprom every time i want to read it, whats a solid way to read the eeprom in place after my sampling is done. the sketch isnt 100% meaning its just in testing phase to get me 20 samples, and alert me when done. id like to be able to plug it up to usb and retrieve the data somehow. im not opposed to purchasing breakout boards, but would like to build it myself. thanks for the input. please feel free to streamline the sketch or advise if anything is being done wrong, or a better way to do it. thanks again. :smiley: edit** and charge pump (max619) 50ma model.

#include <TinyWireM.h>
#define IO_ADDR 0x50
#define ledpin 1
float tempF;
float a;
byte x; //for testing
unsigned int pointer=0;//x5a2;
void setup() {
  pinMode(ledpin,OUTPUT);
  pinMode(3,INPUT);
  //  for (int i=0;i<20;i++){   for testing
  TinyWireM.begin();        // initialize the I2C interface
  beginsequence();
  //  }
}
void loop() {
  if (pointer==0x13){   //e2 addr 20. bust out of loop when 20 samples done. 
    endrun();
  }
  a=analogRead(3);
  tempF=(5.0*a*100.0)/1023.0;
  byte c=tempF+0.5;
  TinyWireM.beginTransmission(IO_ADDR);
  TinyWireM.send(pointer>>8);
  TinyWireM.send(pointer & 0xFF);
  TinyWireM.send(c);
  TinyWireM.endTransmission(); 

  pointer=pointer+1;
  
  
delay(60000);
}

void endrun(){
  tone(4, 2000, 80);
  digitalWrite(ledpin,HIGH);
  while (1){       //just hang here with led on till i get up of lazy butt to retrieve. basically crash sketch here, best way for this?
  }
}

void beginsequence(){    //some kind of visual indicator that its gonna start, battery not dead
  tone(4, 2000, 80);
  digitalWrite(ledpin,HIGH);
  delay(500);
  digitalWrite(ledpin,LOW);
  delay(200);
  tone(4, 2000, 80);
  digitalWrite(ledpin,HIGH);
  delay(200);
  digitalWrite(ledpin,LOW);
delay(200);
}

Hello,

grendle:
in experimenting, ive got an attiny85...

Are there any free pins left (other than RESET)?

if i dump the tone(), gives me one pin. i could dump the led too, gives me 2 pins then.

How precious is the data? If a transfer fails, should the data be preserved for another attempt?

not important at this point at all, just learning stages still.

What I would do...

• Use the LED pin for serial communications (leave the LED in place).

• On powerup / reset, dump all data to Serial.

• Leave everything else in your program the way it is.

i am going to give that a go, sounds good. thank you C.B. right now watching battlestar galactica when zarek and gaeta try to take over the galactica, i think blood on your hands episode. as soon as done im gonna get to work on this.

here is the code, the "test" comes through fine, everything else just blank lines. am i reading the 24lc256 correctly with tinywirem? core is attiny85 @8 internal, bod disabled.

#include <TinyWireM.h>
#define IO_ADDR 0x50
byte data;
unsigned int pointer=0;

void setup(){
  Serial.begin(9600);
  Serial.println("test");
 
  
//  for (int i=0;i<20;i++){

    TinyWireM.beginTransmission(IO_ADDR);
    TinyWireM.send(pointer>>8);
    TinyWireM.send(pointer & 0xFF);
    TinyWireM.endTransmission();
    TinyWireM.requestFrom(IO_ADDR,1);
    data=TinyWireM.receive();
//    pointer++;
    Serial.println(data);
    
//  }
}

void loop(){
  
}

wait i see, i forgot tinywire.begin, let me revise and retry.

SUCCESS!

thank you C.B.
i just got to put it all together now. revised read/reset/send sketch that works. i use putty, can save it to putty log and import to excel, as long as i know when readings started, i can add the times to excel afterwards, eliminating an rtc for this project. (which i may add anyway later on) thanks again.

#include <TinyWireM.h>
#define IO_ADDR 0x50
byte data;
unsigned int pointer=0;

void setup(){
  TinyWireM.begin();
  Serial.begin(9600);
  Serial.println("test");
 
  
  for (int i=0;i<20;i++){

    TinyWireM.beginTransmission(IO_ADDR);
    TinyWireM.send(pointer>>8);
    TinyWireM.send(pointer & 0xFF);
    TinyWireM.endTransmission();
    TinyWireM.requestFrom(IO_ADDR,1);
    data=TinyWireM.receive();
    pointer++;
    Serial.println(data,DEC);
    
  }
}

void loop(){
  
}