This should be a fairly straightforward project that can be done in very little time. The code is written so that you don't have to input your wifi information or your twitch channel info. When the device first starts up it starts in AP mode and you can connect to it as a wireless hotspot. You can then fill in your wifi information and your twitch channel information. It will store this info in flash so it will remember everything if it is powered off and on again. I also added a hard reset that makes it forget everything. If you short pin D8 to ground while it is powered on it will forget the wifi info and the channel info. This is great if you want to give it away with it in a factory default setting.
Detailed instruction on setting it up after you upload the code is included in the setup manual in the files section.
This is the bit of code that resets everything.
int resetpin = digitalRead(reset_pin);
if(resetpin == LOW){
Serial.println("RESETTING TO FACTORY SETTINGS IN 3...");
digitalWrite(led,HIGH);
delay(1000);
Serial.println("2...");
delay(1000);
Serial.println("1...");
delay(1000);
Serial.println("wait 10 seconds and manually reset");
delay(100);
WiFi.disconnect(true); //erase ssid info
SPIFFS.format();
delay(500);
//SPIFFS.format();//erase custom parameters login, oauth, channel name
}
Also, the device will display information on the serial monitor. It will display all of twitch chat as well.
You can easily add features to the code to make your own custom bot. It can post messages to chat so if you want it to post links to your social media or respond to commands the process is quite easy.
The command
client.sendMessage("YOUR MESSAGE");
will allow you to send your own messages to chat.
Any commands you give should go in the void callback(IRCMessage ircMessage) loop
void callback(IRCMessage ircMessage) {
//Serial.println("In CallBack");
// PRIVMSG ignoring CTCP messages
if (ircMessage.command == "PRIVMSG" && ircMessage.text[0] != '\001') {
//Serial.println("Passed private message.");
ircMessage.nick.toUpperCase();
String message("<" + ircMessage.nick + "> " + ircMessage.text);
//prints chat to serial
Serial.println(message);
//flashes the LED with a new message
for(int i=0; i<6; i++){
digitalWrite(led,HIGH);
delay(50);
digitalWrite(led,LOW);
delay(25);
}
/*
put your custom commands here
listen for a command example and post social media stuff
if(ircMessage.text == "!twitter") {
client.sendMessage(IRC_CHAN,"Follow me on twitter https://twitter.com/otherlonestar");
}
*/
return;
}
}
You do need to give some credentials to the device during setup. It needs to know what channel to connect to and what user to connect as. You can use your own twitch account or make a bot account. You will need to obtain an OAUTH key to do so. The info on OAUTH keys is included in the manual.
You'll need some libraries to make it work. The IRCClient Library is the really important one. https://github.com/fredimachado/ArduinoIRC
Could something like this be applied to a I2C 16x2 LCD? I've been webcrawing for a while trying to figure something out. I already have a setup to be able to read the chat, but having this little LCD display the last posted chat is my goal.