Skip to content

Writing discord messages / W5100S + Pico

Use the W5100S and the Pico board to write messages to Discord.

Alan

Published August 07, 2023

Writing discord messages / W5100S + Pico

Components

Hardware components

Project description

 

Hello! Are you having a good day!
Today, I made a project with an interesting theme. It's a very simple and fun project.

I have five friends. They love playing games. I enjoy playing games after work with these friends every day.

Writing discord messages / W5100S + Pico

Do you happen to know a game called LOL? This game, called League of Legends, is difficult to play unless five people gather. So I have to let you know if I can play tonight or not. If I don't tell them, my crazy friends won't stay still.

However, I am very lazy to chat. It's especially annoying to do it during work hours. It's not a big deal, but I'm sure there are people who sympathize.

So I decided to make a device that can simply tell you my status with a button. I'm sure I'll press the button at least once..

Writing discord messages / W5100S + Pico

I made a simple button. Pull-up 3.3V.

Writing discord messages / W5100S + Pico

It connects to the Pico board. I finished it with silicon to secure it.And the Pico board is connected to the W5100S board. This is the best way to use Ethernet.

IFTTT

I must now create an action progression through IFTTT.

https://ifttt.com/explore

Writing discord messages / W5100S + Pico

IFTTT connects applications that we commonly use.

After signing up, you can create an applets.

Writing discord messages / W5100S + Pico

Click "IF Then" first.

Writing discord messages / W5100S + Pico

Select "Webhooks".

Writing discord messages / W5100S + Pico

Select "Receive a web request" because it is not sent to Json.

Writing discord messages / W5100S + Pico

Enter the applets name you want.

Writing discord messages / W5100S + Pico

When you're done, then it's "Then That". Select an action.

Writing discord messages / W5100S + Pico
Writing discord messages / W5100S + Pico

I can select Discord to select the activities.

Writing discord messages / W5100S + Pico

After connecting to the discord, enter the desired channel. You can also format messages.

IFTTT is complete.

 

Firmware

First, you need to update the Pico to the WIZnet 5K version. This exclusive FW was carried out by referring to Virtor's project.

https://maker.wiznet.io/viktor/projects/how-to-connect-raspberry-pi-pico-to-twitter-using-ethernet-hat-and-ifttt/

Writing discord messages / W5100S + Pico

Now, next.

I proceeded with micro python. H, Similarly, the dedicated FW provided by Victor is also a micro-Python version.

from usocket import socket
from machine import Pin,SPI
import network
import time
import urequests

button_pin1 = machine.Pin(27, machine.Pin.IN, machine.Pin.PULL_UP)
button_pin2 = machine.Pin(26, machine.Pin.IN, machine.Pin.PULL_UP)
button_pin3 = machine.Pin(22, machine.Pin.IN, machine.Pin.PULL_UP)
button_pin4 = machine.Pin(21, machine.Pin.IN, machine.Pin.PULL_UP)
button_pin5 = machine.Pin(20, machine.Pin.IN, machine.Pin.PULL_UP)

I imported the libraries to use.. In addition, set the 5 connected buttons to pull-up.

#W5x00 chip init
def w5x00_init():
    spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
    nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
    nic.active(True)
    nic.ifconfig(('192.168.0.20','255.255.255.0','192.168.0.1','8.8.8.8'))
    while not nic.isconnected():
        time.sleep(1)

And it starts the W5x00 chip.

 if button_pin1.value() == 0:
            print("Button1 is pressed!")
            message 
            ="Looks%20like%20it's%20gonna%20be%20an%20overtime%20night...%20Sorry,%20no%20gaming%20for%20me%20today."
            
            x = 1

Creates a message to send when the button is pressed.

Writing discord messages / W5100S + Pico

The message that will be sent according to the button is set like this.

send_data =
"https://maker.ifttt.com/trigger/fire/with/key/your_key?value1={}".format(message)

urequests.post(send_data)

And if you pass the message to that code, you're done. For "your_key", enter the key of apps issued by IFTTT!

Operating

Writing discord messages / W5100S + Pico

It works very well! Now I can communicate my situation well without having to chat directly!

https://youtube.com/shorts/q9OgWt0Xajg?feature=share

Documents

  • W5100S_Pico_IFTTT_Discord

Comments

Similar projects you might like

Comments