-
11Don't forget the yield() Function
When using and ESP 8266 you cannot delay() due to watchdog timers for the wifi connections. The yield() function allows for the wifi process to continue while waiting. I made a little helper function to run repeat yield() functions for a set amount of time.
void newDelay(long msec){ totalTime = millis() + msec; while (millis() < totalTime) { yield(); } }
Also note that all individual loops and functions have a timeout due to this watchdog. So setting the LED's must be quick, to not trigger the watchdog.
-
12Buttons on Wix Websites
On Wix, you can send a pre-composed email with a button press!
This is cool because you can both thank someone for interacting with your project as well as send control emails!
I mostly followed this youtube video from the Coding Queen, with modifications.
My code ended up looking like this :
import wixCRM from 'wix-crm'; import wixUsers from 'wix-users'; export function B4_rainbow(event, $w) { //where B4_rainbow is attached to button on my home page wixCRM.createContact({ "emails":['email@email.com'] }) .then((contactId)=>{ wixCRM.emailContact('Premade Email',contactId, { variables: { command: 'Special Character' }}) .catch( (err) => { console.log(err) }); }); }
-
13Python Gmail and Twitch Bot
To fully link my wix website to twitch, I used a Gmail account because of the Google API.
I set up the gmail python api bot by following this tutorial online: https://developers.google.com/gmail/api/quickstart/python
I used Sockets for interacting with twitch -> https://dev.twitch.tv/docs/irc/ and https://www.instructables.com/id/Twitchtv-Moderator-Bot/ (sorry for referencing Instructables)My full code looks something like this:
from apiclient import discovery from apiclient import errors from httplib2 import Http from oauth2client import file, client, tools import base64 import cfg #this is a file with my twitch IRC bot login info import socket import re import time import multiprocessing def chat(sock, msg): """ Send a chat message to the server. Keyword arguments: sock -- the socket over which to send the message msg -- the message to be sent """ sock.send("PRIVMSG {} :{}\r\n".format(cfg.CHAN, msg).encode("utf-8")) s = socket.socket() s.connect((cfg.HOST,cfg.PORT)) s.send("PASS {}\r\n".format(cfg.PASS).encode("utf-8")) s.send("NICK {}\r\n".format(cfg.NICK).encode("utf-8")) s.send("JOIN {}\r\n".format(cfg.CHAN).encode("utf-8")) CHAT_MSG=re.compile(r"^:\w+!\w+@\w+.tmi.twitch.tv PRIVMSG #\w+ :") # Setup the Gmail API SCOPES = 'https://www.googleapis.com/auth/gmail.modify' # we are using modify and not readonly, as we will be marking the messages Read store = file.Storage('storage.json') creds = store.get() if not creds or creds.invalid: flow = client.flow_from_clientsecrets('client_secret.json', SCOPES) #this json is where my google info login is stored. creds = tools.run_flow(flow, store) service = discovery.build('gmail', 'v1', http=creds.authorize(Http())) user_id = 'me' label_id_one = 'INBOX' label_id_two = 'UNREAD' #gets all of the unread messages from the inbox def remail(): t=0 while True: ot=time.time() diff = ot - t unread_msgs = service.users().messages().list(userId='me',labelIds=[label_id_two]).execute() mess = unread_msgs['messages'] final_list=[] #print ("Total messaged retrived: ", str(len(mess))) for msgs in mess: temp_dict = { } m_id = msgs['id'] message = service.users().messages().get(userId=user_id, id=m_id).execute() #get message using api payId=message['payload'] headr =payId['headers'] for one in headr: if one['name'] == 'Subject': msg_subject = one['value'] temp_dict['Subject']= msg_subject else: pass for three in headr: if three['name']=='From': msg_from = three['value'] temp_dict['Sender']= msg_from else: pass #print(temp_dict['Sender']) #should always look like this for me natedamen <nate.damen@pb08.wixshoutout.com> if temp_dict['Subject'] == 'rnbw': chat(s,"!rainbowHeart") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'gltchd': chat(s,"!flicker") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'fxdgltch': chat(s,"!flickerOff") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'hrt': chat(s,"!heartColor") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'bgclr': chat(s,"!backgroundColor") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'rst': chat(s,"!reset") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'ch1': chat(s,"<3") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'ch2': chat(s,"!mirrorMirror") #print(temp_dict['Subject']) service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() elif temp_dict['Subject'] == 'frainbow': chat(s,"!fullRainbow") service.users().messages().modify(userId=user_id, id=m_id, body={ 'removeLabelIds': ['UNREAD']}).execute() time.sleep(1 / cfg.RATE) if diff > 240: t=time.time() diff=0 ot=time.time() chat(s,"Hey Chat! This is TvheadBot just letting you know a few commands: !rainbow !ch1 !heart") #time.sleep(1 / cfg.RATE) def pingPong(): while True: response = s.recv(1024).decode("utf-8") if response == "PING :tmi.twitch.tv\r\n": s.send("PONG :tmi.twitch.tv\r\n".encode("utf-8")) time.sleep(1 / cfg.RATE) print('sent') print(response) if __name__ == '__main__' : p = multiprocessing.Process(target=pingPong) m = multiprocessing.Process(target=remail) m.start() print('Started Email Scanning') p.start() print('ping pong started')
-
14High Five Glove Electrical
The high five glove is rather straightforward with the esp32. I hooked it up to a single cell lipo for power. Gpio 14 is a capacitive touch pin, called T6 when coding. I attached a wire to gpio 14 and soldered it to silver conductive thread!
*Remember to keep your touch pads small so they have good sensitive control. Too large of a pad will result in no touch triggers or constant touch depending on how the sensitivity is set.
-
15High Five Glove Build and Coding
There is a full write up on the code, design of glove, and files found in Log 13 and Log 14. The step and code files are found in the files section!
:) I hope you can understand me sending you to the logs, but I covered the glove in detail there.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.