Ah I see. There are indeed a few differences with ATTiny85s, the one in my Digispark / Digistump is running at 16.5 MHz whereas the standard board file dictates 8 MHz.
But the fuses can only be set for one variant ofc.
What board = .. value did you select in the platformio.ini?
Suddenly today when trying to upload I get an upload error again. Is there a way to get more information on the error? Can I set verbose on the upload? How and where do I do it?
> Executing task in folder I2C_scanner: C:\Users\hans\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny85.html
PLATFORM: Atmel AVR (3.2.0) > Generic ATtiny85
HARDWARE: ATTINY85 8MHz, 512B RAM, 8KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr-attiny 1.3.2
- tool-avrdude 1.60300.200527 (6.3.0)
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 13 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SoftI2CMaster> 2.1.3
|-- <SoftwareSerial> 1.0
Building in release mode
Checking size .pio\build\attiny85\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [===== ] 54.7% (used 280 bytes from 512 bytes)
Flash: [===== ] 45.8% (used 3756 bytes from 8192 bytes)
Configuring upload protocol...
AVAILABLE: usbtiny
CURRENT: upload_protocol = usbtiny
Looking for upload port...
Uploading .pio\build\attiny85\firmware.hex
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
*** [upload] Error 1
================================== [FAILED] Took 4.03 seconds ==================================
The terminal process "C:\Users\hans\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" terminated with exit code: 1.
Disconnected everything from the circuit and still failed. Tried a second Tiny - failed. Tried a third Tiny - success. It looks like I’ve bricked two Tinys. I found AVRdudeSS and wanted to read the fuses in the Tinys to compare. I was warned not write anything and I didn’t. I only tried to read the fuses and not being sure about the parameters I emailed Zak Kemble and got some help but I never got it working. I don’t think I could have ruined the Tiny but who am I to know.
BTW, the upload flags you gave me
upload_flags =
-U
lfuse:w:0xE2:m
-U
hfuse:w:0x5F:m
-U
efuse:w:0xFF:m
-U
lock:w:0xFF:m
are they to be used just once and then taken out? Do the fuse values stick until you set them to something else?
This is not good o_o. But I also don’t know what it could be. I’ve had zero issues with the ATTiny85 on my Digispark Mini (that’s what they seem to call it nowadays) regarding that yet.
OK, i made a High Voltage Programmer PCB and tested three suspected TTiny85s and they were all good. I resumed my test with the I2C_Scanner sketch with one OLED display wired up and I get a lot of garbled output on serial monitor. I’ve set monitor speed to 9600 in the source and in platformio.ini.
I measured the voltages and GND-SCL = 3.8V, GND-SDA = 2.1V. If I remove the display I get GND-SCL = 5V, GND-SDA = 2V. I use 4.7kΩ pullups.
I removed the SCL and SDA wires from the Sparkfun programmer and measured voltages and SCL-GND = 1.4V and SDA-GND = 4.8V. Is that a clue?
While still trying to get the I2C_Scanner sketch to work I changed pullup resistors to 2.7kΩ and voltages change a bit: SCL-GND 4.1V and GND-SDA 2.3V but there was no improvement. What recommended voltages are looking for on the SCL and SDA pins? This is the output on the serial monitor.
OK, I replaced the OLED with a 16x2 display and now the SCL-GND=5V and SDA-GND=2V. The display lights up during upload and it looks promising but another error came up. I have now added a 10kΩ resistor Vcc - Reset.
avrdude: 3670 bytes of flash written
avrdude: verifying flash memory against .pio\build\attiny85\firmware.hex:
avrdude: load data flash data from input file .pio\build\attiny85\firmware.hex:
avrdude: input file .pio\build\attiny85\firmware.hex contains 3670 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 7.43s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x4a
avrdude: verification error; content mismatch
avrdude: safemode: lfuse changed! Was 62, and is now 0