FYI, for those interested in using a HC-05 Bluetooth module for uploading sketches to any board that has a reset button and pin to put the board into flash mode, I made a small design and sketch for a ATTiny85 (or any other compatible device) to do this as I couldn't find any info on google how to do this.
The drawing attached is for a Lolin D1 mini as a controller for an led strip, but If you look at how the HC-05 is connected it does this. When the switch at the Attiny 85 is open you can use the blueooth serial as normal for debugging or sending commands etc, when the switch is closed and the HC-05 state pin goes high, a voltage is sent to the transitor to turn the Attiny85 on and the attached sketch does this:
1: Sets the flash pin to gnd, resets the lolin and puts it into flash mode, so you can upload a sketch. Once the sketch is uploaded the state pin goes low and the Attiny85 removes ground from the flash pin and resets the board.
Here's the Attiny85 sketch:
// ATtiny85 reset sketch for programing a Lolin/Wemos D1 MINI via Bluetooth (HC-05)
// By MrDude
const byte Pins[5] PROGMEM = {0, 1, 2, 3, 4};
/*
You can't use pin 1 (D5) as an input or output pin as this is used as a reset pin, if you mess with the fuse bits to allow this to operate as an input or output
you need a special high voltage serial programmer to reset the fuse bits:
http://projectsfromtech.blogspot.com/2013/04/using-reset-pin-as-io-on-attiny8545.html
For using this pin, you can make a programmer - http://www.gammon.com.au/forum/?id=12898
Pin 4 is Gnd, Pin 8 is VCC - so these are only for powering the board, essentially this means you can only have 5 I/O pins.
NOTE: When first powering up the ATtiny. It sends a reset signal to the Lolin D1, so the Lolin will reset without going into flash mode and reset any current pin states.
*/
#define DFlash Pins[0] //5
#define Board_LED Pins[1] //6
#define BTState Pins[2] //7
#define DReset Pins[4] //3
int x, y = 0;
void setup()
{
//Set the up Attiny85 PINS
pinMode(BTState, OUTPUT);
digitalWrite(BTState, LOW); //pin 7 on at attiny85 (D2)
pinMode(DFlash, OUTPUT);
digitalWrite(DFlash, HIGH); //pin 5 on attiny85 (D0)
pinMode(DReset, OUTPUT);
digitalWrite(DReset, HIGH); //pin 3 on attiny85 (D4)
pinMode(Board_LED, OUTPUT);
//blink the led once when power is applied so we know the Attiny is working.
digitalWrite(Board_LED, HIGH); //pin 6 on attiny85 (D1)
delay(1000);
digitalWrite(Board_LED, LOW); //pin 6 on attiny85 (D1)
}
void loop()
{
if (digitalRead(BTState) == LOW)
{
y = 0;
}
if (digitalRead(BTState) == HIGH)
{
y = 1;
}
if (y == 1 && x == 0){
//if the state pin detects voltage turn the board led on
digitalWrite (Board_LED, HIGH);
//Enable the d1 mini flash mode pin.
digitalWrite (DFlash, LOW);
delay(100);
//reset the lolin d1 mini
digitalWrite (DReset, LOW); //connect this to a transistor to temp ground the reset pin
delay(200);
digitalWrite (DReset, HIGH);
x = 1; //set this so we don't end up looping the reset....
}
if (y == 0){
digitalWrite (Board_LED, LOW);
digitalWrite(DFlash, HIGH);
}
//reset the board once flashing is completed
if (y == 0 && x == 1){
x = 0;
digitalWrite (DReset, LOW);
delay(100);
digitalWrite (DReset, HIGH);
}
}
I know the ESP8266 has wifi and you can upload firmware via this, however if that fails and you have your board where it's not easy to plug into a laptop usb, flashing via bluetooth is a good option to have as a backup.
Hopefully this can help someone, I wish I had found a post like this last week as this was a bit of work for me as I am not an electronics guy.
