25 lines
1.3 KiB
Markdown
25 lines
1.3 KiB
Markdown
### Connecting With The websocket.
|
|
#### The reason.
|
|
During our project we needed more esp's to connect to the websocket, so i was given the task to make a connection to wifi, connect to the websocket, and then send information to it.
|
|
|
|
#### Before the setup.
|
|
I used library's for: connecting to multiple wifi's, connecting to the websocket and being able to read infromation form a DHT11.
|
|
These were called uppon in the first few lines.
|
|
|
|
Together with this a few variables are named to be used later in the code.
|
|
|
|
#### The Setup
|
|
Firstoff, start with identifying which serial port will be used and work from there.
|
|
It Then tells the DHT to send a test message and start it up.
|
|
|
|
Then the several wifi connections get told here and it looks for the one that connects.
|
|
(This is made bij giving the wifi name and pasword)
|
|
In this sequence a print is made, showing that there is an atempt to connect to a wifi.
|
|
|
|
*This was used because the node should be able to connect to several wifi's and not be stuck t one in perticulair.
|
|
|
|
After the wifi is connected it sends a print to indicate a connection and pings the ip adress of the used wifi.
|
|
|
|
The websocket connection which was then made is made using the uri, port, and type of connection.
|
|
In case of websocket events it gets sent.
|
|
In case of connection failiure, try this. |