Forum » Elektrotehnika in elektronika » Arduino in luči
Arduino in luči
FX6300B ::
ok će želiš oba stikala obdržati moraš dodati križno stikalo , če pa želiš le nadomestiti enega vežeš na ta način stem da je eden ismed stikal vbistvu rele :D upam da me zastopiš ;D , , povej najprej kako želiš obdržati oba stikala ali pa nadomestiit rele z enim pa bomo narisal če bo treba :D samo da pomagamo
aja vprašanje koliko si dal za wifi shield mam sam tudi arduino , kitajska jajca :D pa da vidim če se splača kupiti sam wifi modul ali cel shield
aja vprašanje koliko si dal za wifi shield mam sam tudi arduino , kitajska jajca :D pa da vidim če se splača kupiti sam wifi modul ali cel shield
May the force be with you!
SonoR ::
mogoče butasto vprašanje: kaj tisti križec spodaj na prvi sliki prikazuje? :D Da je enkrat luč prižgana, drugič ne?
FX6300B ::
ne to je križno stikalo , če želiš kot si rekel nadomistiti eno stikalo z relejem poveži kot je na 2. sliki
križno stikalo se uporabi pri 3. stikalih
križno stikalo se uporabi pri 3. stikalih
May the force be with you!
::
še mojih 5€: ko sem si jaz naredil prižiganje luči z ardunotom sem namesto stikal (imel sem tri) montiral tipke. Arduno mi tako reagira na pozitivno fronto pri vsaki od tipk (lahko bi jih povezal tudi na en pin ampak ker pinov itak nisem porabil jih imam vsakega na svojem) in v tem primeru invertira stanje releja. V mislih pa imam že nadgradno sistema kjer bom krmilil več luči. Tukaj nameravam narediti tako da bo dolgi pritisk na tipko ugasnil vse luči. Problem pri tem imam ker je hiša stara in moram vse to tlačiti v opstoječe doze. Na koncu bi rad naredil nekaj takega da bi imel "vhodne module" - arduno nano + tipke ter "izhodne module" - arduno nano + rele ali pa kombinacija obojega. Na tipko bi potem "obesil" neko kodo in prav tako na rele. Pritisk tipke bi poslal svojo kodo po omrežju in na to kodo bi potem reagiral eden ali več relejev. Sedaj moram samo še pogruntati kako skupaj spraviti več ardunotov. Eth se mi ni zdel preveč zanesliv zato se sedaj igram s rs485 ampak tukaj sem še precej zelen.
FX6300B ::
SonoR mi pošlješ trenutno kodo mogoče lahko kako pomagam sicer nebom mogel stestirat ker nimam Wifi shielda ampak vseeno lahko preverim :D
May the force be with you!
SonoR ::
/* WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module - This sample application code simply turns on and off an LED remotely via Wifi. - It is suggested to use Atmega644 to avoid further RAM issues. - The IP address given to CC3000 by the Access Point is static. Therefore, it is advisable to make sure that the IP address entered to the browser is correct. Execution: 1. Once uploaded to the microcontroller, open the serial. 2. Wait for successful connection. 3. When DHCP request is successful, Copy the IPaddress given to your device. 4. Enter the IPaddress to your browser. 5. The small Wireless Controller webpage will then be loaded. 6. Click ON button to turn on the LED and OFF button to turn it off. Wiring Connection: 1. Connect +pin of LED(series with current limiting resistor if needed) to pin 8(A0). -pin to GND. This will be the LED to be controlled. 2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9. -pin to GND. This will be the wifi connection indicator. Notes: Reserved pins for CC3000 and SD Card communication are as follows. CC3000 Breakout Board Gizduino SCK <------------------> Digital pin 13 MISO <------------------> Digital pin 12 MOSI <------------------> Digital pin 11 CS <------------------> Digital pin 10 V_EN <------------------> Digital pin 5 uSDCS <------------------> Digital pin 4 IRQ <------------------> Digital pin 3 References: - Adafruit_CC3000 ChatServer.ino - Ethernet WebServer.ino - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software Created On: 28 APR 14 By: e-Gizmo Mechatronix Central */ #include <Adafruit_CC3000.h> #include <SPI.h> #include "utility/debug.h" #include "utility/socket.h" /* --- CC3000 constants --- */ // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed #define WLAN_SSID "arkamadona" // cannot be longer than 32 characters! #define WLAN_PASS "samsung1" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 #define LISTEN_PORT 80 Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT); //(LISTEN_PORT); /* --- Webpage variables --- */ String req; // Will handle the request of the client. String reqsub; // Request substring to for keyword "on" or "of". char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\"> <input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>"; /* --- LED Indicators --- */ #define controlLED 8 int zarnica1 = 8; int stikalo = 9; #define wifiLED 9 void setup(void) { Serial.begin(9600); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println("Initializing..."); if (!cc3000.begin()) { Serial.println("Couldn't begin()! Check your wiring?"); while(1); } Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID); if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println("Failed!"); while(1); } Serial.println("Connected!"); Serial.println("Request DHCP..."); cc3000.checkDHCP(); // Display the IP address DNS, Gateway, etc. while (! displayConnectionDetails()) { delay(1000); } gizduinoServer.begin(); // Start listening for connections Serial.println("Waiting for Client..."); pinMode(wifiLED,OUTPUT); // LED pin for Wifi connection indicator. digitalWrite(wifiLED,HIGH); pinMode(controlLED,OUTPUT); // LED pin to be controlled. pinMode(zarnica1, OUTPUT);//mu pove da je žarnica izhod pinMode(stikalo, INPUT); } void loop(void){ digitalRead(stikalo); if(!cc3000.checkConnected()){ Serial.println("CONNECTION LOST!"); digitalWrite(wifiLED,LOW); while(1); }else{ // Try to get a client which is connected. Adafruit_CC3000_ClientRef client = gizduinoServer.available(); if (client) { Serial.println("New client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); req += c; reqsub = req.substring(6,8); if (reqsub == "of"){ digitalWrite(controlLED, LOW); digitalWrite(zarnica1, LOW); } if (reqsub == "on"){ digitalWrite(controlLED, HIGH); digitalWrite(zarnica1, HIGH); } // Send a reply to the client if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println(); // Give the web page to the client client.println(webpage); client.println(""); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(100); // close the connection client.close(); Serial.println("Client disconnected"); req=""; } } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ bool displayConnectionDetails(void) { uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) { Serial.println(F("Unable to retrieve the IP Address!\r\n")); return false; } else { Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); Serial.println(); return true; } }To je to :) Kakšne tipke so to, mi lahko pošleš kako sliko za lažjo predstavo? :D
Kamikaze5, vidim, da kar podobno razmišljama in si zastavljama cilje :D
Zgodovina sprememb…
- spremenil: SonoR ()
FX6300B ::
kako pa imaš vezano stikalo pin 9 in 5v ? imaš vmes kak upor?
no sedaj sem malo spremenil in boš stestiral če dela ok ali če dela stikalo v napačni smeri :D nisem ziher
aja stikalo pa veži obvezno tako po novem ker sem dal pinMode(stikalo, INPUT_PULLUP); ker drugače rabiš upor med pinom in gnd
veži takole
GND-------Stikalo---------pin9
no sedaj sem malo spremenil in boš stestiral če dela ok ali če dela stikalo v napačni smeri :D nisem ziher
aja stikalo pa veži obvezno tako po novem ker sem dal pinMode(stikalo, INPUT_PULLUP); ker drugače rabiš upor med pinom in gnd
veži takole
GND-------Stikalo---------pin9
/* WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module - This sample application code simply turns on and off an LED remotely via Wifi. - It is suggested to use Atmega644 to avoid further RAM issues. - The IP address given to CC3000 by the Access Point is static. Therefore, it is advisable to make sure that the IP address entered to the browser is correct. Execution: 1. Once uploaded to the microcontroller, open the serial. 2. Wait for successful connection. 3. When DHCP request is successful, Copy the IPaddress given to your device. 4. Enter the IPaddress to your browser. 5. The small Wireless Controller webpage will then be loaded. 6. Click ON button to turn on the LED and OFF button to turn it off. Wiring Connection: 1. Connect +pin of LED(series with current limiting resistor if needed) to pin 8(A0). -pin to GND. This will be the LED to be controlled. 2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9. -pin to GND. This will be the wifi connection indicator. Notes: Reserved pins for CC3000 and SD Card communication are as follows. CC3000 Breakout Board Gizduino SCK <------------------> Digital pin 13 MISO <------------------> Digital pin 12 MOSI <------------------> Digital pin 11 CS <------------------> Digital pin 10 V_EN <------------------> Digital pin 5 uSDCS <------------------> Digital pin 4 IRQ <------------------> Digital pin 3 References: - Adafruit_CC3000 ChatServer.ino - Ethernet WebServer.ino - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software Created On: 28 APR 14 By: e-Gizmo Mechatronix Central */ #include <Adafruit_CC3000.h> #include <SPI.h> #include "utility/debug.h" #include "utility/socket.h" /* --- CC3000 constants --- */ // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed #define WLAN_SSID "arkamadona" // cannot be longer than 32 characters! #define WLAN_PASS "samsung1" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 #define LISTEN_PORT 80 Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT); //(LISTEN_PORT); /* --- Webpage variables --- */ String req; // Will handle the request of the client. String reqsub; // Request substring to for keyword "on" or "of". char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\"> <input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>"; /* --- LED Indicators --- */ #define controlLED 8 int zarnica1 = 8; int stikalo = 9; #define wifiLED 9 void setup(void) { Serial.begin(9600); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println("Initializing..."); if (!cc3000.begin()) { Serial.println("Couldn't begin()! Check your wiring?"); } Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID); if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println("Failed!"); while(1); } Serial.println("Connected!"); Serial.println("Request DHCP..."); cc3000.checkDHCP(); // Display the IP address DNS, Gateway, etc. while (! displayConnectionDetails()) { delay(1000); } gizduinoServer.begin(); // Start listening for connections Serial.println("Waiting for Client..."); pinMode(wifiLED,OUTPUT); // LED pin for Wifi connection indicator. digitalWrite(wifiLED,HIGH); pinMode(controlLED,OUTPUT); // LED pin to be controlled. pinMode(zarnica1, OUTPUT);//mu pove da je žarnica izhod pinMode(stikalo, INPUT_PULLUP); } void loop(void){ if(!cc3000.checkConnected()){ Serial.println("CONNECTION LOST!"); digitalWrite(wifiLED,LOW); while(1); }else{ // Try to get a client which is connected. Adafruit_CC3000_ClientRef client = gizduinoServer.available(); if (client) { Serial.println("New client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); req += c; reqsub = req.substring(6,8); if (reqsub == "of" || digitalRead(stikalo) == HIGH){ digitalWrite(controlLED, LOW); digitalWrite(zarnica1, LOW); } if (reqsub == "on" || digitalRead(stikalo) == LOW){ digitalWrite(controlLED, HIGH); digitalWrite(zarnica1, HIGH); } // Send a reply to the client if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println(); // Give the web page to the client client.println(webpage); client.println(""); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(100); // close the connection client.close(); Serial.println("Client disconnected"); req=""; } } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ bool displayConnectionDetails(void) { uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) { Serial.println(F("Unable to retrieve the IP Address!\r\n")); return false; } else { Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); Serial.println(); return true; } }
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
FX6300B ::
spodnja koda velja za take kombinacije
web je na internetu
stikalo je stikalo
WEB Stikalo LUČ
0 ** 0** 0
0 ** 1 ** 1
1 ** 0 ** 1
1**1 ** 1
web je na internetu
stikalo je stikalo
WEB Stikalo LUČ
0 ** 0** 0
0 ** 1 ** 1
1 ** 0 ** 1
1**1 ** 1
/* WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module - This sample application code simply turns on and off an LED remotely via Wifi. - It is suggested to use Atmega644 to avoid further RAM issues. - The IP address given to CC3000 by the Access Point is static. Therefore, it is advisable to make sure that the IP address entered to the browser is correct. Execution: 1. Once uploaded to the microcontroller, open the serial. 2. Wait for successful connection. 3. When DHCP request is successful, Copy the IPaddress given to your device. 4. Enter the IPaddress to your browser. 5. The small Wireless Controller webpage will then be loaded. 6. Click ON button to turn on the LED and OFF button to turn it off. Wiring Connection: 1. Connect +pin of LED(series with current limiting resistor if needed) to pin 8(A0). -pin to GND. This will be the LED to be controlled. 2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9. -pin to GND. This will be the wifi connection indicator. Notes: Reserved pins for CC3000 and SD Card communication are as follows. CC3000 Breakout Board Gizduino SCK <------------------> Digital pin 13 MISO <------------------> Digital pin 12 MOSI <------------------> Digital pin 11 CS <------------------> Digital pin 10 V_EN <------------------> Digital pin 5 uSDCS <------------------> Digital pin 4 IRQ <------------------> Digital pin 3 References: - Adafruit_CC3000 ChatServer.ino - Ethernet WebServer.ino - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software Created On: 28 APR 14 By: e-Gizmo Mechatronix Central */ #include <Adafruit_CC3000.h> #include <SPI.h> #include "utility/debug.h" #include "utility/socket.h" /* --- CC3000 constants --- */ // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed #define WLAN_SSID "arkamadona" // cannot be longer than 32 characters! #define WLAN_PASS "samsung1" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 #define LISTEN_PORT 80 Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT); //(LISTEN_PORT); /* --- Webpage variables --- */ String req; // Will handle the request of the client. String reqsub; // Request substring to for keyword "on" or "of". char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\"> <input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>"; /* --- LED Indicators --- */ #define controlLED 8 int zarnica1 = 8; int stikalo = 9; #define wifiLED 9 void setup(void) { Serial.begin(9600); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println("Initializing..."); if (!cc3000.begin()) { Serial.println("Couldn't begin()! Check your wiring?"); } Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID); if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println("Failed!"); while(1); } Serial.println("Connected!"); Serial.println("Request DHCP..."); cc3000.checkDHCP(); // Display the IP address DNS, Gateway, etc. while (! displayConnectionDetails()) { delay(1000); } gizduinoServer.begin(); // Start listening for connections Serial.println("Waiting for Client..."); pinMode(wifiLED,OUTPUT); // LED pin for Wifi connection indicator. digitalWrite(wifiLED,HIGH); pinMode(controlLED,OUTPUT); // LED pin to be controlled. pinMode(zarnica1, OUTPUT);//mu pove da je žarnica izhod pinMode(stikalo, INPUT_PULLUP); } void loop(void){ if(!cc3000.checkConnected()){ Serial.println("CONNECTION LOST!"); digitalWrite(wifiLED,LOW); while(1); }else{ // Try to get a client which is connected. Adafruit_CC3000_ClientRef client = gizduinoServer.available(); if (client) { Serial.println("New client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); req += c; reqsub = req.substring(6,8); if (reqsub == "of" && digitalRea(stikalo) == HIGH{ digitalWrite(controlLED, LOW); digitalWrite(zarnica1, LOW); } if ((reqsub == "of" && digitalRead(stikalo) == LOW ) || (reqsub == "on" && digitalRead(stikalo) == HIGH) || (reqsub == "on" && digitalRead(stikalo == LOW)) ){ digitalWrite(controlLED, HIGH); digitalWrite(zarnica1, HIGH); } // Send a reply to the client if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println(); // Give the web page to the client client.println(webpage); client.println(""); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(100); // close the connection client.close(); Serial.println("Client disconnected"); req=""; } } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ bool displayConnectionDetails(void) { uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) { Serial.println(F("Unable to retrieve the IP Address!\r\n")); return false; } else { Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); Serial.println(); return true; } }
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
FX6300B ::
stikalo priklopljeno na arduino?
imaš vezano GND--- stikalo ---- pin9?
pošlješ kako slikco?
kaj pa ti serial monitor kaže?
imaš vezano GND--- stikalo ---- pin9?
pošlješ kako slikco?
kaj pa ti serial monitor kaže?
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
BladE_ ::
Sicer offtopic ampak, če lahko kdo samo na hitro...
Arduino mi na USB na 5V pinu da ven 5V, če pa zadevo priklopim na zunanje napajanje dobim pa ~3.2V in zadeva potem ne dela tako kot bi morala. Sem že googlal pa naj bi bilo napajanje, ker se uporabljajo 9V baterije ampak jaz napajam in napajalnika...
Arduino mi na USB na 5V pinu da ven 5V, če pa zadevo priklopim na zunanje napajanje dobim pa ~3.2V in zadeva potem ne dela tako kot bi morala. Sem že googlal pa naj bi bilo napajanje, ker se uporabljajo 9V baterije ampak jaz napajam in napajalnika...
Akcija - Reakcija
korenje3 ::
mojca, si ti moški ?, ka vidim da si na vseh tehničnih področjih... kot da bi se gledal v ogledalo.
Predvidevam da je rpi isto kot beaglebone in moraš zato konfigurirat gpio preden začneš karkoli delat.
dtc -O dtb -o /lib/firmware/PWM-00A0.dtbo -b 0 -@ PWM.dts
dtc -O dtb -o /lib/firmware/INPUT-00A0.dtbo -b 0 -@ INPUT.dts
dtc -O dtb -o /lib/firmware/OUTPUT-00A0.dtbo -b 0 -@ OUTPUT.dts
OUTPUT.dts
To je nek nov standard ravno zaradi kompatibilnosti kartičnih računalnikov. Edino po novem pri meni bonescript to naredi samodejno pri konfiguriranju vsakega pina.
Predvidevam da je rpi isto kot beaglebone in moraš zato konfigurirat gpio preden začneš karkoli delat.
dtc -O dtb -o /lib/firmware/PWM-00A0.dtbo -b 0 -@ PWM.dts
dtc -O dtb -o /lib/firmware/INPUT-00A0.dtbo -b 0 -@ INPUT.dts
dtc -O dtb -o /lib/firmware/OUTPUT-00A0.dtbo -b 0 -@ OUTPUT.dts
OUTPUT.dts
/* * BBB home automation */ /dts-v1/; /plugin/; / { compatible = "ti,beaglebone", "ti,beaglebone-black"; part-number = "OUTPUT-BBB-home"; version = "00A0"; fragment@0 { target = <&am33xx_pinmux>; __overlay__ { gpio_output: pinmux_gpio_output_pins { pinctrl-single,pins = < 0x078 0x07 /* P9.12 GPIO1[28] */ 0x074 0x07 /* P9.13 GPIO0[31] */ 0x070 0x07 /* P9.11 GPIO0[30] */ 0x040 0x07 /* P9.15 GPIO1[16] */ 0x15c 0x07 /* P9.17 GPIO0[5] */ 0x158 0x07 /* P9.18 GPIO0[4] */ 0x044 0x07 /* P9.23 GPIO1[17] */ 0x184 0x07 /* P9.24 GPIO0[15] */ 0x1AC 0x07 /* P9.25 GPIO3[21] */ 0x1B4 0x07 /* P9.41 GPIO0[20] */ 0x190 0x07 /* P9.31 GPIO3[14] */ 0x194 0x07 /* P9.29 GPIO3[15] */ 0x198 0x07 /* P9.30 GPIO3[16] */ 0x1A4 0x07 /* P9.27 GPIO3[19] */ 0x180 0x07 /* P9.26 GPIO0[14] */ >; }; }; }; fragment@2 { target = <&ocp>; __overlay__ { gpio_output { compatible = "bone-pinmux-helper"; pinctrl-names = "default"; pinctrl-0 = <&gpio_output>; status = "okay"; }; }; }; };
To je nek nov standard ravno zaradi kompatibilnosti kartičnih računalnikov. Edino po novem pri meni bonescript to naredi samodejno pri konfiguriranju vsakega pina.
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
Zgodovina sprememb…
- spremenil: korenje3 ()
korenje3 ::
Lahko pa dodam še en segment kako konfiguriram pine v svoji skripti.
for(var pin in pinname){ //console.log(getTimeDate()+"pin: "+pin+" enabled: "+pinname[pin].options.enabled); if(pinname[pin].options.enabled != true){ continue; } if(pinname[pin].chg || ! socket) { pinname[pin].chg = false; if(pinname[pin].type == "TEMP"){ pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; continue; } if(pinname[pin].pin){ if(! b.bone.pins[pinname[pin].pin]){ continue; } if(pinname[pin].type == "PWM" && b.bone.pins[pinname[pin].pin].pwm){ try { if(b.pinMode(pinname[pin].pin, b.ANALOG_OUTPUT, b.bone.pins[pinname[pin].pin].pwm.muxmode, 'pulldown', 'fast')){ if(b.analogWrite(pinname[pin].pin,pinname[pin].options.min,pinname[pin].options.frequency)){ nconf.set("pinname:"+pin+":options:s",0); console.log(getTimeDate()+"Configured PWM pin: "+pinname[pin].pin+" type: "+pinname[pin].type); pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; } } } catch(e) { console.log(getTimeDate()+"PIN Error #PWM: "+e); if(socket){ socket.emit("error","PIN Error #PWM: "+e); } nconf.set("pinname:"+pin+":options:enabled",false); } } else if(pinname[pin].type == "ANALOG"){ if(typeof b.bone.pins[pinname[pin].pin].ain !== 'undefined'){ nconf.set("pinname:"+pin+":options:s",0); console.log(getTimeDate()+"Configured ANALOG pin: "+pinname[pin].pin+" type: "+pinname[pin].type); pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; } else { console.log(getTimeDate()+"PIN not analog #ANALOG: "+e); if(socket){ socket.emit("error","PIN not analog #ANALOG: "+e); } nconf.set("pinname:"+pin+":options:enabled",false); } } else if(pinname[pin].type == "INPUT"){ configurepins_input(pin); } else if(pinname[pin].type == "OUTPUT"){ try { if(b.pinMode(pinname[pin].pin, b.OUTPUT, 7, 'pulldown', 'fast')){ console.log(getTimeDate()+"Configured OUTPUT pin: "+pinname[pin].pin+" type: "+pinname[pin].type); pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; }; b.digitalWrite(pinname[pin].pin,0); nconf.set("pinname:"+pin+":options:s",false); } catch(e) { console.log(getTimeDate()+"PIN Error #OUTPUT: "+e); if(socket){ socket.emit("error","PIN Error #OUTPUT: "+e); } nconf.set("pinname:"+pin+":options:enabled",false); } } else if(pinname[pin].type == "OUTPCT" && pinname[pin].pinoff){ try { if(b.pinMode(pinname[pin].pin, b.OUTPUT, 7, 'pulldown', 'fast')){ console.log(getTimeDate()+"Configured OUTPCT1 pin: "+pinname[pin].pin+" type: "+pinname[pin].type); }; b.digitalWrite(pinname[pin].pin,0); if(b.pinMode(pinname[pin].pinoff, b.OUTPUT, 7, 'pulldown', 'fast')){ console.log(getTimeDate()+"Configured OUTPCT2 pin: "+pinname[pin].pin+" type: "+pinname[pin].type); }; pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; b.digitalWrite(pinname[pin].pinoff,0); nconf.set("pinname:"+pin+":options:s",pinname[pin].options.s); } catch(e) { console.log(getTimeDate()+"PIN Error #OUTPCT: "+e); if(socket){ socket.emit("error","PIN Error #OUTPCT: "+e); } nconf.set("pinname:"+pin+":options:enabled",false); } } } } } function configurepins_input(pin){ try { if(b.pinMode(pinname[pin].pin, b.INPUT, 7, 'pulldown', 'fast')){ if(! pininterrupt[pin]){ pininterrupt[pin] = { count:{rising:0, falling:0, change:0}, rising:{}, falling:{}, change:{}}; } pininterrupt[pin].attaching = true; if(b.attachInterrupt(pinname[pin].pin, true, b.CHANGE, function(x){ if(typeof pininterrupt[pin] !== "undefined"){ if(pininterrupt[pin].attaching){ pininterrupt[pin].attaching = false; return; } if(pininterrupt[pin].debounce){ return; } pininterrupt[pin].debounce = setTimeout(function(){ if(b.digitalRead(x.pin.key)){ // console.log(getTimeDate()+"activated HIGH"); for(var vhod in pininterrupt[pin].rising){ pininterrupt[pin].count.rising += 1; pininterrupt[pin].rising[vhod](); } } else { // console.log(getTimeDate()+"activated LOW"); for(var vhod in pininterrupt[pin].falling){ pininterrupt[pin].count.falling += 1; pininterrupt[pin].falling[vhod](); } } for(var vhod in pininterrupt[pin].change){ pininterrupt[pin].count.change += 1; pininterrupt[pin].change[vhod](); } delete pininterrupt[pin].debounce; }, 50); // debounce time } })){ console.log(getTimeDate()+"Configured INPUT pin: "+pinname[pin].pin+" type: "+pinname[pin].type); pincontrol[pin] = { control:"", count:{rising:0, falling:0, change:0}}; }; }; } catch(e) { console.log(getTimeDate()+"PIN Error #INPUT: "+e); if(socket){ socket.emit("error","PIN Error #INPUT: "+e); } nconf.set("pinname:"+pin+":options:enabled",false); } } confsave("configure pins");
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
korenje3 ::
i9-12900k; 32GB DDR5-6000 CL36; Nvidia RTX 3080 ti;
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
Gigabyte Aorus z690 master; Be Quiet Dark Power 12 1000W
int47 ::
Mogoče malo pozno:
Poglej ESP8266. Na ebay-u obstaja v različnih okusih z manj, ali več GPIO, z interno, ali zunanjo anteno.
Obstaja več različnih FW.
Možna je uporaba samostojno, ali v povezavi z uC - preko serijske komunikacije (AT stil ukazov).
Za začetnika ena bolj enostavna varianta je tudi ESP8266 BASIC
Glede na to, da ima ESP-01 samo dva GPIO, katerih stanje mora biti ob resetu '1', je boljša izbira ESP-12E.
Na mojih primerkih ob dobavi ni bil uporaben FW. Za zamenjavo FW je potreben USB -> RS232 pretvornik z 3.3V nivoji.
Poglej ESP8266. Na ebay-u obstaja v različnih okusih z manj, ali več GPIO, z interno, ali zunanjo anteno.
Obstaja več različnih FW.
Možna je uporaba samostojno, ali v povezavi z uC - preko serijske komunikacije (AT stil ukazov).
Za začetnika ena bolj enostavna varianta je tudi ESP8266 BASIC
Glede na to, da ima ESP-01 samo dva GPIO, katerih stanje mora biti ob resetu '1', je boljša izbira ESP-12E.
Na mojih primerkih ob dobavi ni bil uporaben FW. Za zamenjavo FW je potreben USB -> RS232 pretvornik z 3.3V nivoji.
SonoR ::
stikalo priklopljeno na arduino?
imaš vezano GND--- stikalo ---- pin9?
pošlješ kako slikco?
kaj pa ti serial monitor kaže?
imam tako priklopleno stikalo ja.
Ko imam fizično stikalo na on, lahko preko weba prižgem in ugasnem luč, ko pa imam stikalo na off, pa gre samo prižgat, izklopi pa ne. Samo fizično stikalo pa ne vklopi ali izklopi.
Serial monitor pa kaže:
Client disconnected
New client
GET /favicon.ico HTTP/1.1
Host: 192.168.1.4
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
Accept: */*
Referer: http://192.168.1.4/?of
Accept-Encoding: gzip, deflate, sdch
Accept-Language: sl-SI,sl;q=0.8,en-GB;q=0.6,en;q=0.4,de;q=0.2,hr;q=0.2
Client disconnected
SaXsIm ::
Sicer offtopic ampak, če lahko kdo samo na hitro...
Arduino mi na USB na 5V pinu da ven 5V, če pa zadevo priklopim na zunanje napajanje dobim pa ~3.2V in zadeva potem ne dela tako kot bi morala. Sem že googlal pa naj bi bilo napajanje, ker se uporabljajo 9V baterije ampak jaz napajam in napajalnika...
Na 9V napajanju bi zadeva morala funkcionirati brez problema. Možno da imaš kakšen VREF čudno zvezan, ali pa je odletel regulator.
SaXsIm
FX6300B ::
stikalo priklopljeno na arduino?
imaš vezano GND--- stikalo ---- pin9?
pošlješ kako slikco?
kaj pa ti serial monitor kaže?
imam tako priklopleno stikalo ja.
Ko imam fizično stikalo na on, lahko preko weba prižgem in ugasnem luč, ko pa imam stikalo na off, pa gre samo prižgat, izklopi pa ne. Samo fizično stikalo pa ne vklopi ali izklopi.
Serial monitor pa kaže:
Client disconnected
New client
GET /favicon.ico HTTP/1.1
Host: 192.168.1.4
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
Accept: */*
Referer: http://192.168.1.4/?of
Accept-Encoding: gzip, deflate, sdch
Accept-Language: sl-SI,sl;q=0.8,en-GB;q=0.6,en;q=0.4,de;q=0.2,hr;q=0.2
Client disconnected
poizkusi sedaj sem malo spremenil prej sem opazil sem očitno zgrešil par zaklepajev itd here you go
/* WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module - This sample application code simply turns on and off an LED remotely via Wifi. - It is suggested to use Atmega644 to avoid further RAM issues. - The IP address given to CC3000 by the Access Point is static. Therefore, it is advisable to make sure that the IP address entered to the browser is correct. Execution: 1. Once uploaded to the microcontroller, open the serial. 2. Wait for successful connection. 3. When DHCP request is successful, Copy the IPaddress given to your device. 4. Enter the IPaddress to your browser. 5. The small Wireless Controller webpage will then be loaded. 6. Click ON button to turn on the LED and OFF button to turn it off. Wiring Connection: 1. Connect +pin of LED(series with current limiting resistor if needed) to pin 8(A0). -pin to GND. This will be the LED to be controlled. 2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9. -pin to GND. This will be the wifi connection indicator. Notes: Reserved pins for CC3000 and SD Card communication are as follows. CC3000 Breakout Board Gizduino SCK <------------------> Digital pin 13 MISO <------------------> Digital pin 12 MOSI <------------------> Digital pin 11 CS <------------------> Digital pin 10 V_EN <------------------> Digital pin 5 uSDCS <------------------> Digital pin 4 IRQ <------------------> Digital pin 3 References: - Adafruit_CC3000 ChatServer.ino - Ethernet WebServer.ino - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software Created On: 28 APR 14 By: e-Gizmo Mechatronix Central */ #include <Adafruit_CC3000.h> #include <SPI.h> #include "utility/debug.h" #include "utility/socket.h" /* --- CC3000 constants --- */ // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed #define WLAN_SSID "arkamadona" // cannot be longer than 32 characters! #define WLAN_PASS "samsung1" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 #define LISTEN_PORT 80 Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT); //(LISTEN_PORT); /* --- Webpage variables --- */ String req; // Will handle the request of the client. String reqsub; // Request substring to for keyword "on" or "of". char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\"> <input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>"; /* --- LED Indicators --- */ #define controlLED 8 int zarnica1 = 8; int stikalo = 9; #define wifiLED 9 void setup(void) { Serial.begin(9600); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println("Initializing..."); if (!cc3000.begin()) { Serial.println("Couldn't begin()! Check your wiring?"); } Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID); if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println("Failed!"); while(1); } Serial.println("Connected!"); Serial.println("Request DHCP..."); cc3000.checkDHCP(); // Display the IP address DNS, Gateway, etc. while (! displayConnectionDetails()) { delay(1000); } gizduinoServer.begin(); // Start listening for connections Serial.println("Waiting for Client..."); pinMode(wifiLED,OUTPUT); // LED pin for Wifi connection indicator. digitalWrite(wifiLED,HIGH); pinMode(controlLED,OUTPUT); // LED pin to be controlled. pinMode(zarnica1, OUTPUT);//mu pove da je žarnica izhod pinMode(stikalo, INPUT_PULLUP); } void loop(void){ if(!cc3000.checkConnected()){ Serial.println("CONNECTION LOST!"); digitalWrite(wifiLED,LOW); while(1); }else{ // Try to get a client which is connected. Adafruit_CC3000_ClientRef client = gizduinoServer.available(); if (client) { Serial.println("New client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); req += c; reqsub = req.substring(6,8); if ((reqsub == "of" && digitalRead(stikalo) == HIGH) || (reqsub == "on" && digitalRead(stikalo) == LOW)){ digitalWrite(controlLED, LOW); digitalWrite(zarnica1, LOW); } if ((reqsub == "of" && digitalRead(stikalo) == LOW ) || (reqsub == "on" && digitalRead(stikalo == LOW)) ){ digitalWrite(controlLED, HIGH); digitalWrite(zarnica1, HIGH); } // Send a reply to the client if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println(); // Give the web page to the client client.println(webpage); client.println(""); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(100); // close the connection client.close(); Serial.println("Client disconnected"); req=""; } } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ bool displayConnectionDetails(void) { uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) { Serial.println(F("Unable to retrieve the IP Address!\r\n")); return false; } else { Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); Serial.println(); return true; } }
May the force be with you!
SonoR ::
res ne vem kaj povzroča težavo, ampak še vedno ne deluje. Stikalo ni pokvarjeno, ker sem ga že večkrat sprobal, če bi slučajno bilo. :/ ko sem nekaj preklapljal stikalo je serial monitor začel izpisoati FrFrFr... v nedogled.
Zgodovina sprememb…
- spremenil: SonoR ()
FX6300B ::
poizkusi sedaj imeti rele v pinu 3
/* WirelessControllerWifi is one of the applicatioin of CC3000 Wifi Module - This sample application code simply turns on and off an LED remotely via Wifi. - It is suggested to use Atmega644 to avoid further RAM issues. - The IP address given to CC3000 by the Access Point is static. Therefore, it is advisable to make sure that the IP address entered to the browser is correct. Execution: 1. Once uploaded to the microcontroller, open the serial. 2. Wait for successful connection. 3. When DHCP request is successful, Copy the IPaddress given to your device. 4. Enter the IPaddress to your browser. 5. The small Wireless Controller webpage will then be loaded. 6. Click ON button to turn on the LED and OFF button to turn it off. Wiring Connection: 1. Connect +pin of LED(series with current limiting resistor if needed) to pin 13(A0). -pin to GND. This will be the LED to be controlled. 2. Connect +pin of LED(series with current limiting resistor if needed) to pin 9. -pin to GND. This will be the wifi connection indicator. Notes: Reserved pins for CC3000 and SD Card communication are as follows. CC3000 Breakout Board Gizduino SCK <------------------> Digital pin 13 MISO <------------------> Digital pin 12 MOSI <------------------> Digital pin 11 CS <------------------> Digital pin 10 V_EN <------------------> Digital pin 5 uSDCS <------------------> Digital pin 4 IRQ <------------------> Digital pin 3 References: - Adafruit_CC3000 ChatServer.ino - Ethernet WebServer.ino - Important Libraries from Adafruit: https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-library-software Created On: 28 APR 14 By: e-Gizmo Mechatronix Central */ #include <Adafruit_CC3000.h> #include <SPI.h> #include "utility/debug.h" #include "utility/socket.h" /* --- CC3000 constants --- */ // These are the interrupt and control pins #define ADAFRUIT_CC3000_IRQ 3 // MUST be an interrupt pin! // These can be any two pins #define ADAFRUIT_CC3000_VBAT 5 #define ADAFRUIT_CC3000_CS 10 // Use hardware SPI for the remaining pins // On an UNO, SCK = 13, MISO = 12, and MOSI = 11 Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); // you can change this clock speed #define WLAN_SSID "arkamadona" // cannot be longer than 32 characters! #define WLAN_PASS "samsung1" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 #define WLAN_SECURITY WLAN_SEC_WPA2 #define LISTEN_PORT 80 Adafruit_CC3000_Server gizduinoServer(LISTEN_PORT); //(LISTEN_PORT); /* --- Webpage variables --- */ String req; // Will handle the request of the client. String reqsub; // Request substring to for keyword "on" or "of". char webpage[404] = "<!DOCTYPE HTML><html><body><center><h1>Wireless Controller via Wi-Fi</h1><p>by e-Gizmo</p><br><form method=\"get\"><input type=\"button\"style=\"height:100px;width:100px\" value=\"ON\"onclick=\"window.location='/?on'\"> <input type=\"button\"style=\"height:100px;width:100px\"value=\"OFF\"onclick=\"window.location='/?of'\"></form></center></body></html>"; /* --- LED Indicators --- */ #define controlLED 13 #define wifiLED 12 #define Stikalo 9 #define zarnica 3 int st_zarnica = 0; void setup(void) { Serial.begin(9600); Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC); /* Initialise the module */ Serial.println("Initializing..."); if (!cc3000.begin()) { Serial.println("Couldn't begin()! Check your wiring?"); while(1); } Serial.print("Attempting to connect to "); Serial.println(WLAN_SSID); if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) { Serial.println("Failed!"); while(1); } Serial.println("Connected!"); Serial.println("Request DHCP..."); cc3000.checkDHCP(); // Display the IP address DNS, Gateway, etc. while (! displayConnectionDetails()) { delay(1000); } gizduinoServer.begin(); // Start listening for connections Serial.println("Waiting for Client..."); pinMode(wifiLED,OUTPUT); // LED pin for Wifi connection indicator. digitalWrite(wifiLED,HIGH); pinMode(controlLED,OUTPUT); // LED pin to be controlled. pinMode(Stikalo, INPUT_PULLUP); pinMode(zarnica, OUTPUT); } void loop(void){ if(!cc3000.checkConnected()){ Serial.println("CONNECTION LOST!"); digitalWrite(wifiLED,LOW); while(1); }else{ // Try to get a client which is connected. Adafruit_CC3000_ClientRef client = gizduinoServer.available(); if (client) { Serial.println("New client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); req += c; reqsub = req.substring(6,8); if (digitalRead(zarnica) == LOW) st_zarnica = 1; if (digitalRead(zarnica) == HIGH) st_zarnica = 0; if (reqsub == "of" && st_zarnica == 0 || reqsub == "on" && st_zarnica == 1){ digitalWrite(controlLED, LOW); digitalWrite(zarnica, LOW); } if (reqsub == "on" && st_zarnica == 0 || reqsub == "of" && st_zarnica == 1){ digitalWrite(controlLED, HIGH); digitalWrite(zarnica, HIGH); } // Send a reply to the client if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println(); // Give the web page to the client client.println(webpage); client.println(""); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(100); // close the connection client.close(); Serial.println("Client disconnected"); req=""; } } } /**************************************************************************/ /*! @brief Tries to read the IP address and other connection details */ /**************************************************************************/ bool displayConnectionDetails(void) { uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv; if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv)) { Serial.println(F("Unable to retrieve the IP Address!\r\n")); return false; } else { Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress); Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask); Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway); Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv); Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv); Serial.println(); return true; } }
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
FX6300B ::
imaš vštekano v usb ne? probej na napajalnik ja čisto možno meni se je dogajalo ko sem naredil avtoček ki se sam vozi s pomočjo 2 hc-sr04 senzorjev pa je bla baterija ki napaja arduino prazna, vse je svetilo samo delovalo ni nič :D
May the force be with you!
FX6300B ::
maš kak 9V napajalnik?
ali 5v
aja bi mi mogoče slikal rele nekaj me zanima :D
ali 5v
aja bi mi mogoče slikal rele nekaj me zanima :D
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
FX6300B ::
ko si omenil 9V imaš to na 9V priključeno? pač preko arduina ki ima regulator na 5v? drugače če nimaš lahko probaš kakršenkoli napajalnik ki daje okrog 9V in 1 A bi mogl bit 100% dost pa prklopš na Vin pa GND
Vin --- +9V
GND --- 0V (minus)
Vin --- +9V
GND --- 0V (minus)
May the force be with you!
SonoR ::
ja ne nimam, imam na arduinota tam ko piše 5v, torej rabim še en napajalnik :D Me zanima, če bo stvar čudežno delovala :D
15v je preveč?
15v je preveč?
Zgodovina sprememb…
- spremenil: SonoR ()
FX6300B ::
ja tam do 12V max pa še to se regulator vrjetno greje potem
tam 5-9V je priporočeno
drugače pa če maš polnilc za telefon pa en str usb kabl od kkšne crknene podgane(pc miška ) pa gor prklopš
tam 5-9V je priporočeno
drugače pa če maš polnilc za telefon pa en str usb kabl od kkšne crknene podgane(pc miška ) pa gor prklopš
May the force be with you!
FX6300B ::
lahko bi pa tudi probal ta kabel od arduino -- PC dat v en polnilc za telefon, bi dobil več štroma
May the force be with you!
SonoR ::
dva mam ko spustita 5v in 1,2 ampera oz. drugi 800mA
Zgodovina sprememb…
- spremenil: SonoR ()
::
ja ne nimam, imam na arduinota tam ko piše 5v, torej rabim še en napajalnik :D Me zanima, če bo stvar čudežno delovala :D
15v je preveč?
Pozor! če si priklopil napajanje na Arduinotov pin, ki je označen s 5V, potem si lahko tudi kaj prekuril. Ta pin je priključen na napajanje za regulatorjem napetosti! Napajanje priključi na pin, ki je označen z VIN, oz. na za to namenjen konektor ali pa ga napajaj preko USBja.
SonoR ::
15v je očitno preveč za rele, trenutno pa nimam česa takšnega, ki bi lahko kako zvezal na rele :/
FX6300B ::
aha ok ja 15v je 3x preveč lol pa ko dobiš kaj takega da bi zvezal daj kar na komplet pač na arduino da vse skupaj napaja
May the force be with you!
FX6300B ::
mene nekaj zanima glede HC-SR501 (senzor gibanja) so vredu za alarmni sistem?
May the force be with you!
TilenS ::
Če misliš narediti kolikor toliko zanesljiv alarmni sistem potem raje vzemi namenske PIR senzorje, recimo Bosch in podobni. Poglej tudi za PIR+MW (micowave), če imaš kje probleme z lažno detekcijo ampak to lahko tudi rešiš programsko.
FX6300B ::
najlepša hvala :D bom moral nekaj naresti zaden čas se je zgodilo pri nas na vasi kar nekaj vlomov
pa kaj veš če obstajajo taki da so za arduino pač delujejo na 5V
pa kaj veš če obstajajo taki da so za arduino pač delujejo na 5V
May the force be with you!
Zgodovina sprememb…
- spremenil: FX6300B ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Kdo se spozna na ESP8266 in Arduino?Oddelek: Pomoč in nasveti | 2383 (1961) | chiiiii |
» | Arduino(slave) + ESP8266(master) preko I2CjaOddelek: Elektrotehnika in elektronika | 1014 (867) | teoo |
» | Pomoč C++Oddelek: Pomoč in nasveti | 1350 (1069) | samo111 |
» | Arduino "leteče luči"Oddelek: Elektrotehnika in elektronika | 2994 (1871) | zrataj4201 |
» | Arduino - krmiljenje stepper motorjevOddelek: Elektrotehnika in elektronika | 3713 (2892) | steling |