NodeMCUWiFi old code
This commit is contained in:
parent
3f40eba93a
commit
21b6c3f760
1 changed files with 4 additions and 5 deletions
|
|
@ -2,8 +2,8 @@
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <spi_flash.h>
|
#include <spi_flash.h>
|
||||||
|
|
||||||
#define WIFI_SSID ""
|
#define WIFI_SSID "KAIPPUZHAKKUNNEL"
|
||||||
#define WIFI_PASS ""
|
#define WIFI_PASS "7042754150"
|
||||||
|
|
||||||
#define IP_BROADCAST "192.168.1.255"
|
#define IP_BROADCAST "192.168.1.255"
|
||||||
#define UDP_PORT 8176
|
#define UDP_PORT 8176
|
||||||
|
|
@ -21,7 +21,6 @@ void setup() {
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
||||||
pinMode(echoPin, INPUT);
|
pinMode(echoPin, INPUT);
|
||||||
pinMode(triggerPin, OUTPUT);
|
pinMode(triggerPin, OUTPUT);
|
||||||
|
|
||||||
status = "Connecting";
|
status = "Connecting";
|
||||||
while(WiFi.status() != WL_CONNECTED) {
|
while(WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
@ -29,6 +28,7 @@ void setup() {
|
||||||
status = WiFi.localIP().toString();
|
status = WiFi.localIP().toString();
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("Got IP: " + status);
|
Serial.println("Got IP: " + status);
|
||||||
|
Serial.println("Sending messages to: " + String(IP_BROADCAST));
|
||||||
int err = client.begin(81);
|
int err = client.begin(81);
|
||||||
if(err == 0) {
|
if(err == 0) {
|
||||||
Serial.println("Failed to create UDP Socket");
|
Serial.println("Failed to create UDP Socket");
|
||||||
|
|
@ -41,7 +41,6 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
digitalWrite(triggerPin, LOW);
|
digitalWrite(triggerPin, LOW);
|
||||||
delayMicroseconds(20);
|
delayMicroseconds(20);
|
||||||
digitalWrite(triggerPin, HIGH);
|
digitalWrite(triggerPin, HIGH);
|
||||||
|
|
@ -74,6 +73,6 @@ void loop() {
|
||||||
client.beginPacket(IP_BROADCAST, UDP_PORT);
|
client.beginPacket(IP_BROADCAST, UDP_PORT);
|
||||||
client.write(buff, sizeof(float));
|
client.write(buff, sizeof(float));
|
||||||
client.endPacket();
|
client.endPacket();
|
||||||
delay(3000);
|
|
||||||
delete[] buff;
|
delete[] buff;
|
||||||
|
delay(3000);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue