Enviado por: nbaglietto - 24-11-2017, 02:05 AM - Foro: Arduino
- Sin respuestas
luego de utilizar el codigo E-RFIDDoorUnlocker-master con un arduino uno y un shield ethernet 5100 se colgaba la coneccion tcp y no me resultaba confiable para un proyecto de cerradura.
Despues descubri el Wemos D1 y me parecio muy bueno y apto para este proyecto, el problema fue que al querer convertir el codigo este compila bien pero al pasar al wemos este se reinicia de forma permanente.
Aca les paso el codigo que fu compilado con el ide arduino 1.6. El wemos es alimentado por su puerto usb con la pc, probe con uno d1 mini y un d1 y tuve el mismo problema con los 2.
-----------------------------------------------------------------------------------------------
Código:
//#include <SPI.h> // RC522 Module uses SPI protocol
#include <MFRC522.h> // Library for Mifare RC522 Devices
#include <aJSON.h>
///////////////////////////////////////////////////////
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
//#include <WiFiClientSecure.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
/////////////////////////////////////////////////////77
// #define COMMON_ANODE
#ifdef COMMON_ANODE
#define LED_ON LOW
#define LED_OFF HIGH
#else
#define LED_ON HIGH
#define LED_OFF LOW
#endif
#define redLed 7
#define greenLed 6
#define blueLed 5
#define relay 16
#define buzzer 2 // Button pin for WipeMode
#define CHECK_ALL 0
#define CREATE_ONE 1
#define CHECK_ONE 2
#define CHECK_MASTER 3
#define CHECK_ONE_ASSOC 4
#define CREATE_MASTER 5
boolean programMode = false; // initialize programming mode to false
int successRead; // Variable integer to keep if we have Successful Read from Reader
WiFiClient wclient;
byte readCard[4];// Stores scanned ID read from RFID Module
char cardUID[10];// Stores scanned ID read from RFID Module in text mode
/* We need to define MFRC522's pins and create instance
Pin layout should be as follows (on Arduino Uno):
MOSI : Pin 11 / ICSP-4
MISO : Pin 12 / ICSP-1
SCK : Pin 13 / ICSP-3
SDA/SS : Pin 10 (Configurable)
RST : Pin 9 (Configurable)
look MFRC522 Library for
pin configuration for other Arduinos.
*/
#define SS_PIN 15
#define RST_PIN 2
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
boolean startRead = false;
String jsonString = "";
String jsonStringCurr = "";
void softAP(const char* ssid, const char* passphrase, int channel = 1, int ssid_hidden = 0, int enableAP = 0);
const char* ssid = "Macri_Gato";
const char* password = "rioiguazu5416";
const char* host = "192.168.1.250";
const int port = 80;
//const int watchdog = 60000; // Fréquence d'envoi des données à Domoticz - Frequency of sending data to Domoticz
//unsigned long previousMillis = millis();
//////////////////////////////////////////////////////////////////
ESP8266WebServer server ( 8085 );
HTTPClient http;
IPAddress ip(192, 168, 1, 254);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress dns(8, 8, 8, 8);
///////////////////////////////////////// Setup ///////////////////////////////////
void setup() {
//Arduino Pin Configuration
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(relay, OUTPUT);
pinMode(buzzer, OUTPUT);
digitalWrite(relay, LOW); // Make sure door is locked
digitalWrite(redLed, LED_OFF); // Make sure led is off
digitalWrite(greenLed, LED_OFF); // Make sure led is off
digitalWrite(blueLed, LED_OFF); // Make sure led is off
//Protocol Configuration
Serial.begin(9600); // Initialize serial communications with PC
SPI.begin(); // MFRC522 Hardware uses SPI protocol
mfrc522.PCD_Init(); // Initialize MFRC522 Hardware
mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max); //Set Antenna Gain to Max- this will increase reading distance
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
///////////////////////////////////////////////////
responseInit();
if (query(CHECK_ALL, "")) { // Look DB if Master Card defined
Serial.println("No Master Card Defined");
Serial.println("Scan A PICC to Define as Master Card");
do {
successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
digitalWrite(blueLed, LED_ON); // Visualize Master Card need to be defined
delay(200);
digitalWrite(blueLed, LED_OFF);
delay(200);
}
while (!successRead); //the program will not go further while you not get a successful read
responseSuccess();
//Next line convert byte tag ID to char tag ID
sprintf(cardUID, "%02X%02X%02X%02X", readCard[0], readCard[1], readCard[2], readCard[3]);
query(CREATE_ONE, cardUID); // Create tag in database
query(CREATE_MASTER, cardUID); // Set first user and first tag as master
Serial.println("Master Card Defined");
}
Serial.println("##### RFID Door Acces Control v2.0.8 #####"); //For debug purposes
Serial.println("");
Serial.println("Waiting PICCs to bo scanned :)");
}
///////////////////////////////////////// Main Loop ///////////////////////////////////
void loop (){
do {
successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
if (programMode) {
cycleLeds(); // Program Mode cycles through RGB waiting to read a new card
}
else {
normalModeOn(); // Normal mode, blue Power LED is on, all others are off
}
}
while (!successRead); //the program will not go further while you not get a successful read
if (programMode) {
cardReaded();
if ( isMaster(readCard) ) { //If master card scanned again exit program mode
Serial.println("This is Master Card");
Serial.println("Exiting Program Mode");
Serial.println("-----------------------------");
responseSuccess();
programMode = false;
return;
}
else {
if ( findID(readCard, CHECK_ONE) ) { //If scanned card is known, do nothing
responseFail();
Serial.println("I know this PICC, so do nothing");
Serial.println("-----------------------------");
}
else { // If scanned card is not known add it
Serial.println("I do not know this PICC, adding...");
writeID(readCard);
responseSuccess();
Serial.println("-----------------------------");
}
}
}
else {
cardReaded();
if ( isMaster(readCard) ) { // If scanned card's ID matches Master Card's ID enter program mode
programMode = true;
responseSuccess();
Serial.println("Hello");
Serial.println("Scan a PICC to ADD");
Serial.println("-----------------------------");
}
else {
if ( findID(readCard, CHECK_ONE_ASSOC) ) { // If not, see if the card is in the database
Serial.println("Welcome, You shall pass");
responseSuccess();
openDoor(500);// Open the door lock for 300 ms
}
else {// If not, show that the ID was not valid
Serial.println("You shall not pass");
responseFail();
}
}
}
}
///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
int getID() {
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return 0;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return 0;
}
// There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
// I think we should assume every PICC as they have 4 byte UID
// Until we support 7 byte PICCs
Serial.println("Scanned PICC's UID:");
for (int i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
}
Serial.println("");
mfrc522.PICC_HaltA(); // Stop reading
return 1;
}
//////////////////////////////////////// Normal Mode Led ///////////////////////////////////
void normalModeOn () {
digitalWrite(blueLed, LED_ON); // Blue LED ON and ready to read card
digitalWrite(redLed, LED_OFF); // Make sure Red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure Green LED is off
digitalWrite(relay, LOW); // Make sure Door is Locked
}
///////////////////////////////////////// Add ID to database ///////////////////////////////////
boolean writeID( byte a[] ) {
sprintf(cardUID, "%02X%02X%02X%02X", a[0], a[1], a[2], a[3]);
if (query(CREATE_ONE, cardUID)) {
return true;
}
return false;
}
///////////////////////////////////////// Find ID on database ///////////////////////////////////
boolean findID(byte find[], int op) {
sprintf(cardUID, "%02X%02X%02X%02X", find[0], find[1], find[2], find[3]);
switch (op) {
case 2:
if (query(CHECK_ONE, cardUID)) {
return true;
}
break;
case 4:
if (query(CHECK_ONE_ASSOC, cardUID)) {
return true;
}
break;
}
return false;
}
////////////////////// Check readCard IF is masterCard ///////////////////////////////////
// Check to see if the ID passed is the master programing card
boolean isMaster( byte test[] ) {
sprintf(cardUID, "%02X%02X%02X%02X", test[0], test[1], test[2], test[3]);
if (query(CHECK_MASTER, cardUID)) {
return true;
} else {
return false;
}
}
///////////////////////////////////////// Unlock Door ///////////////////////////////////
void openDoor( int setDelay ) {
digitalWrite(blueLed, LED_OFF); // Turn off blue LED
digitalWrite(redLed, LED_OFF); // Turn off red LED
digitalWrite(greenLed, LED_ON); // Turn on green LED
digitalWrite(relay, HIGH); // Unlock door!
delay(setDelay); // Hold door lock open for given seconds
digitalWrite(relay, LOW); // Relock door
delay(2000); // Hold green LED on for 2 more seconds
digitalWrite(greenLed, LED_OFF);
digitalWrite(blueLed, LED_ON);
}
String requestServer(int code, char uid[]) {
Serial.println("conectando...");
delay(1000);
// Iniciando conexao com o servidor
//if (client.connect(server, 80)) {
if (wclient.connect(host, 80)) {
//Serial.println("connection failed");
// return;
Serial.println("connected");
// Make a HTTP request:
wclient.print("GET /nfc/operations.php?cod=");
wclient.print(code);
wclient.print("&tag=");
wclient.print(uid);
wclient.println(" HTTP/1.0");
wclient.println();
//Aguardando conexao
while (!wclient.available()) {
delay(1);
}
//Percorre os caracteres do envelope HTTP do servidor e armazena na String apenas o conteudo JSON
while (wclient.available()) {
char c = wclient.read();
Serial.print(c);
if ( c == '{' ) {
startRead = true;
}
if ( startRead ) {
jsonString += c;
}
if (c == '}') {
startRead = false;
}
}
//Reseta a flag de leitura de conteudo JSON
startRead = false;
}
else {
// Caso nao ocorra conexao
Serial.println("conexao falhou");
}
wclient.stop();
http.end();
return jsonString;
}
boolean parseJson(char *jsonString) {
//Inicializa o objeto Pai
aJsonObject* root = aJson.parse(jsonString);
if (root != NULL) {
//Caputura o objeto adesaoDia
aJsonObject* status = aJson.getObjectItem(root, "stat");
int stat = status->valueint;
Serial.print("Status: ");
Serial.println(stat);
if (stat) {
aJson.deleteItem(root);
return true;
}
}
//Deleta o objeto apos a utilizacao para liberacao de memoria
aJson.deleteItem(root);
return false;
}
boolean query(int code, char uid[]) {
bool status = false;
jsonString = requestServer(code, uid);
if (!jsonString.equals("")) {
char jsonChar[jsonString.length()];
jsonString.toCharArray(jsonChar, jsonString.length() + 1);
status = parseJson(jsonChar);
jsonString = "";
}
return status;
}
///////////////////////////////////////// Cycle Leds (Program Mode) ///////////////////////////////////
void cycleLeds() {
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(redLed, LED_OFF);
}
void cardReaded() {
digitalWrite(blueLed, LED_ON);
delay(200);
digitalWrite(blueLed, LED_OFF);
tone(buzzer, 500);
delay(200);
digitalWrite(blueLed, LED_ON);
tone(buzzer, 1500);
delay(200);
noTone(buzzer);
}
void responseInit() {
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
tone(buzzer, 500);
delay(200);
noTone(buzzer);
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
tone(buzzer, 1000);
delay(200);
noTone(buzzer);
delay(200);
tone(buzzer, 1500);
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
tone(buzzer, 2000);
delay(200);
tone(buzzer, 500);
delay(200);
noTone(buzzer);
digitalWrite(redLed, LED_OFF);
}
void responseFail() {
digitalWrite(redLed, LED_ON); // Make sure red LED is on
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
tone(buzzer, 500);
delay(1500);
noTone(buzzer);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
}
void responseSuccess() {
digitalWrite(redLed, LED_OFF);
digitalWrite(greenLed, LED_ON);
digitalWrite(blueLed, LED_OFF);
tone(buzzer, 1500);
delay(200);
noTone(buzzer);
delay(200);
tone(buzzer, 1500);
delay(200);
noTone(buzzer);
digitalWrite(greenLed, LED_OFF);
}
Lo primero agradecer la existencia de esta comunidad y a todos los que participáis en ella, es una gran suerte contar con vosotros para resolver las dudas de los que estamos empezando en este apasionante mundo.
Tengo una ANET A8 desde hace un mes y me esta dando problemas con versiones de CURA actuales y con SLICER, a la hora de cargar el gcode en la impresora con la tarjeta SD se queda en estado imprimiendo pero no marca la temperatura que le paso de la cama ni del extrusor, así que no sube de temperatura y no imprime. Con la versión de CURA que traía en la tarjeta microSD no me pasa (Cura 14.7), funciona perfectamente. Seguro que es una tontería, pero no doy con el asunto.
Buenas, estoy intentando imprimir con el Chimera y con Simplify 3D, pero ya me estoy volviendo loco con la configuración porque en principio está bien configurado todo, pero al imprimir me hace cosas raras.
Como podéis ver hace pegotes o falta plástico o me deja huecos entre los dos colores que, por cierto, es el PLA de BQ.
Os adjunto toda la configuración del Simplify que se me ha ocurrido que os pueda servir de ayuda para ver si encontráis el problema. Si necesitáis algo más, tan solo decidlo
La configuración de la refrigeración no la adjunto porque tengo conectado el ventilador directamente a los 5V de la fuente de alimentación, y los scripts que tengo son los siguientes:
Código:
Starting script
M190 S40;
M109 T0 S205;
M109 T1 S205;
G28;
Ending script
M104 S0 T0;
M104 S0 T1;
M140 S0 ; turn off bed
G28 X ;
M84 ; disable motors
Y he creado el menú de navegación de la web para ir a las diferentes pantallas y al blog para poder leer los artículos.
El caso es que cuando voy al blog, se abre la página del blog, pero no se muestran los artículos (ya tengo artículos publicados, pero no se visualizan)
En cambio, en la pantalla principal, tengo un carrousel con los últimos posts publicados, y se muestran correctamente.
A parte, el tema de wordpress me deja dos opciones para visualizar la web:
OPCIÓN 1
Tener una pantalla principal super bonita, con imágenes ya prestablecidas, carrousels donde aparecen las entradas del blog correctamente, etc. Sin embargo, cuando voy al blog se presenta el problema
OPCIÓN 2
Tener la portada estática. Es sencillo y cualquier cosa que quieras tienes que hacertelo tú. Sin embargo, el link hacia el blog funciona correctament.
Por lo tanto, solo cambiando el tipo de portada, funciona o deja de funcionar. Sin tocar nada del link. Lo he estado mirando con otra persona. Y los dos nos hemos quedado sin saber que decir.
Hemos intentado cambiar de plantilla, porque creíamos que era problema de la plantilla. Pero el problema se presenta con el resto de plantillas. Por lo tanto debe ser algo del link.
soy Josecho de FFF world y con motivo del Black Friday 2017 hemos preparado una triple oferta especial de la que queremos informaros.
La oferta se aplicará a todos los pedidos realizados durante la semana del Black Friday hasta el Ciber Monday, es decir del lunes 20 al lunes 27 de noviembre incluidos.
La oferta consiste en lo siguiente. Todos los pedidos realizados en nuestra tienda online tendrán:
1º - Gastos de envío gratuitos
2º - Incluirán un paquete de 150 gramos de muestras variadas de FlexiSMART (filamento flexible) y Baobab (filamento de madera)
3º - Incluirán una práctica aguja limpia-nozzle flexible.
Para acogerse a la promoción es necesario introducir el código “BLACKFRIDAY2017” durante el proceso de compra.
Una gran oportunidad para probar alguno de nuestros nuevos filamentos –Baobab y Carbon PLA- o los ya conocidos –FlexiSMART, PETG Tech, etc...- sin pagar los gastos de envío y recibiendo dos regalos.
Y como siempre con la garantía de calidad y servicio de FFFworld.