Last active
December 30, 2017 07:00
-
-
Save IOT-123/993f933a3148ce4965314df3bff586e7 to your computer and use it in GitHub Desktop.
A test harness, using an UNO/ESP8266, for the ATtiny85 hardware watchdog, targeting D1M Blocks (custom shields for Wermos D1 Mini)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
byte _interval = 0; | |
void setup() { | |
Serial.begin(9600); | |
Wire.begin(); // join i2c bus (address optional for master) | |
delay(3000); | |
Serial.println("Sending started"); | |
SendCmd('G', 1); // get the expected pat interval | |
Serial.print("The Interval on the ATTINY85 is "); | |
Serial.print(_interval); | |
Serial.println( " seconds"); | |
} | |
byte x = 1; | |
void loop() { | |
if (x < 5){ | |
Serial.print("Patting the dog #"); | |
Serial.println(x); | |
SendCmd('P', 0); | |
}else{ | |
Serial.println("Stopped patting the dog, expect a reset"); | |
} | |
x++; | |
delay(10000); | |
} | |
void SendCmd(char cmd, byte par) { | |
Wire.beginTransmission(8); // transmit to device #8 | |
Wire.write(cmd); // sends a char | |
Wire.write(par); // sends one byte | |
Wire.endTransmission(); | |
if (cmd == 'G'){// we are only getting Interval | |
Wire.requestFrom(8,1); // request a single byte from slave device #25 | |
while(Wire.available()) // slave may send less than requested | |
{ | |
_interval = Wire.read(); // receive a byte as character | |
} | |
} | |
Serial.print(String(cmd) + " : "); | |
Serial.println(par); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment