Aller au contenu


buildrobot

Inscrit(e) (le) 30 oct. 2011
Déconnecté Dernière activité janv. 01 2019 07:51
-----

Sujets que j'ai initiés

Esp-wroom-32

19 juillet 2018 - 11:05

Bonjour tout le monde,

 

J'ai récemment acheté une carte Esp-wroom-32 (https://www.espressi...atasheet_en.pdf ) et je souhaiterai l'alimenter avec une alimentation externe.

Il y a 2 pin d'alimentation (3.3v et 5v). Je sais que le pin du 5v peut être utilisé en entrée (de 7v à 12v) mais dans ce cas, je ne peux plus l'utilisé pour alimenter mon circuit.

 

Est-ce que je peux utiliser le pin du 3.3v en tant qu'entrée pour mon alim externe (de 7v à 12v) ? Je n'arrive pas à trouver l'information...

 

Je vous remercie d'avance pour votre réponse ! :)


Taille PROGMEM

13 juillet 2018 - 11:14

Bonjour, voulant créer un interface web pour contrôler mon arduino avec un Shield Ethernet ENC28J60.

Pour la créer, j'utiliser la librairies EtherCard.h.

 

Je créer ma page comme suis :

const char http_OK[] PROGMEM =
  "HTTP/1.0 200 OK\r\n"
  "Content-Type: text/html\r\n"
  "Pragma: no-cache\r\n\r\n";

const char http_Found[] PROGMEM =
  "HTTP/1.0 302 Found\r\n"
  "Location: /\r\n\r\n";

const char http_Unauthorized[] PROGMEM =
  "HTTP/1.0 401 Unauthorized\r\n"
  "Content-Type: text/html\r\n\r\n"
  "<h1>401 Unauthorized</h1>";

const char title[] PROGMEM =
  "<html>"
  "<head>"
  "<title>Escape Dimension</title>"
  "</head>";

const char colorLed[] PROGMEM =

  "Couleur led :"
  "<input type='checkbox' name='ledr' value='on'> Rouge"
  "<input type='checkbox' name='ledb' value='on'> Bleu"
  "<input type='checkbox' name='ledg' value='on'> Vert<br>"
  ;

const char difficulte[] PROGMEM =
  "Difficulte :"
  "<input type='checkbox' name='diff1' value='1'> 1"
  "<input type='checkbox' name='diff2' value='2'> 2"
  "<input type='checkbox' name='diff3' value='3'> 3<br>"
  ;

const char niveau1[] PROGMEM =
  "Nombre de sons par sequence :"
  "<li>Niveau 1</li>"
  "Sequence 1 : <input type='number' min='0' max='20' step='1' name='n1s1' value='5' size='5' required> sons<br>"
//  "Sequence 1 : <input type='number' min='0' max='20' step='1' name='n1s2' value='5' size='10' required> sons<br>"
//  "Sequence 1 : <input type='number' min='0' max='20' step='1' name='n1s3' value='5' size='15' required> sons<br>"
  ;

void homePage()
{
  bfill.emit_p(PSTR(
                 "$F"
                 "$F"
                 "<h1 style='text-align:center'> Game master </h1>"
                 "<div style='border-style: solid; padding: 5px;'>"
                 "<h2 style='text-align: center; margin: none'>Configuration</h2>"

                 "<form method='get'>"
                 "$F"
                 "$F"
                 "$F"
                 "<input type='submit' value='Submit'>"
                 "</form>"
               ),
               http_OK,
               title,
               colorLed,
               difficulte,
               niveau1
              );
}

 

 

Lorsque je veut rajouter 2 lignes supplémentaire (dans mon niveau1[] PROGMEM), plus rien ne fonctionne.

J'ai du mal à comprendre l'utilisation de PROGMEM. Il me semble que l'on ne peut pas dépasser un certain nombre de caractère dans la mémoire de l'Arduino ?

 

Je vous remercie d'avance de votre bonne foi pour toutes vos réponses ! :)

 

PS : n'hésitez pas à me demander plus de code pour plus de clarté ;)


Interface avec un ENC28J60

04 juillet 2018 - 11:01

Bonjour,

 

J'ai acheté un Shield Ethernet ENC28J60 (datasheet : https://www.mouser.c...9662b-62019.pdf )modulo-ethernet-enc28j60-arduino-D_NQ_NP .

 

Je souhaiterai créer une interface web me permettant de contrôler différents éléments de mon Arduino Uno (comme des LEDs, changer la valeurs de variable, jouer des sons...)

 

Pour cela, j'utilise la bibliothèque EtherCard.h.

 

Pour l'instant, j'ai une simple interface permettant de change la couleur du led RGB de chez Adafruit, avec 3 boutons. 

 

Mon problème vient ensuite.

 

Lorsque je veux rajouter d'autres boutons (par exemple pour gérer la difficulté d'un jeu ou jouer des sons), ma page web ne fonctionne plus...

 

Voici mon code fonctionnel :

#include <EtherCard.h>
#include <PololuLedStrip.h>

#define LED_COUNT 1   //Number of led connected
#define LED1 4  // define LED pin
PololuLedStrip<4> ledStrip;
rgb_color colors[LED_COUNT];


static byte myip[] = { 192, 168, 2, 177 };                      // ethernet interface ip address
static byte gwip[] = { 192, 168, 1, 254 };                      // gateway ip address
static byte mymac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 };   // ethernet mac address - must be unique on your network

bool boolLedR = false;
bool boolLedG = false;
bool boolLedB = false;
byte Red = 0, Green = 0, Blue = 0;

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer
BufferFiller bfill;

void setup() {
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip, gwip);


  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
}

//En tête HTML
const char http_OK[] PROGMEM =
  "HTTP/1.0 200 OK\r\n"
  "Content-Type: text/html\r\n"
  "Pragma: no-cache\r\n\r\n";

const char http_Found[] PROGMEM =
  "HTTP/1.0 302 Found\r\n"
  "Location: /\r\n\r\n";

const char http_Unauthorized[] PROGMEM =
  "HTTP/1.0 401 Unauthorized\r\n"
  "Content-Type: text/html\r\n\r\n"
  "<h1>401 Unauthorized</h1>";

//Principal page of my interface
void homePage()
{
  bfill.emit_p(PSTR("$F"
                    "<html>"
                    "<head>"
                    "<title>Escape Dimension</title>"
                    "<meta http-equiv='refresh' content='5'/>"
                    "</head>"

                    "<body>"
                    "<h1 style='text-align:center'> Game master </h1>"
                    "<div style='border-style: solid'>"
                    "Color led :"
                    "<button><a href=\"?ledr=$F\">$F</a></button>"
//L'ajout de ces trois boutons (ou même d'un seul) arrête de faire fonctionne mon programme...
//                    "<button>Difficulte 1</button>"
//                    "<button>Difficulte 2</button>"
//                    "<button>Difficulte 3</button>"

                    "</div>"
                    "</body>"
                    "</html>"
                   ),
               http_OK,
               boolLedR ? PSTR("off") : PSTR("on"),
               boolLedR ? PSTR("RED allume") : PSTR("RED eteint"),
               boolLedG ? PSTR("off") : PSTR("on"),
               boolLedG ? PSTR("GREEN allume") : PSTR("GREEN eteint"),
               boolLedB ? PSTR("off") : PSTR("on"),
               boolLedB ? PSTR("BLUE allume") : PSTR("BLUE eteint")
              );
}

void loop() {
  colors[0] = rgb_color(Green, Red, Blue);
  ledStrip.write(colors, LED_COUNT);


  // wait for an incoming TCP packet, but ignore its contents
  word len = ether.packetReceive();
  word pos = ether.packetLoop(len);

  if (pos) {
    delay(1);   // necessary for my system
    bfill = ether.tcpOffset();
    char *data = (char *) Ethernet::buffer + pos;

    if (strncmp("GET /", data, 5) != 0) {
      // Unsupported HTTP request
      // 304 or 501 response would be more appropriate
      bfill.emit_p(http_Unauthorized);
    }
    else {
      data += 5;

      if (data[0] == ' ') {
        // Return home page
        homePage();
      }
      else if (strncmp("?ledr=on", data, 8) == 0) {
        // Set boolLedR true and redirect to home page
        boolLedR = true;
        Red = 255;
        bfill.emit_p(http_Found);
      }
      else if (strncmp("?ledr=off", data, 9) == 0) {
        // Set boolLedR false and redirect to home page
        boolLedR = false;
        Red = 0;
        bfill.emit_p(http_Found);
      }
      else if (strncmp("?ledg=on", data, 8) == 0) {
        // Set boolLedR true and redirect to home page
        boolLedG = true;
        Green = 255;
        bfill.emit_p(http_Found);
      }
      else if (strncmp("?ledg=off", data, 9) == 0) {
        // Set boolLedR false and redirect to home page
        boolLedG = false;
        Green = 0;
        bfill.emit_p(http_Found);
      }
      else if (strncmp("?ledb=on", data, 8) == 0) {
        // Set boolLedR true and redirect to home page
        boolLedB = true;
        Blue = 255;
        bfill.emit_p(http_Found);
      }
      else if (strncmp("?ledb=off", data, 9) == 0) {
        // Set boolLedR false and redirect to home page
        boolLedB = false;
        Blue = 0;
        bfill.emit_p(http_Found);
      }
      else {
        // Page not found
        bfill.emit_p(http_Unauthorized);
      }
    }

    ether.httpServerReply(bfill.position());    // send http response
  }

}

Je vous ai mis en commentaire de ma fonction homePage les boutons qui ne veulent pas fonctionner...

 

J'en viens donc à vous pour savoir si quelqu'un sait d'où pourrait venir le problème


Sield ethernet Arduino

29 juin 2018 - 12:49

Bonjour tout le monde !

 

J'ai un Shield Ethernet 2 que je veux utiliser avec mon arduino Uno.

 

Mon problème :

Lorsque je veux tester un code d'exemple de la librairie <Ethernet.h> (l'exemple WebServer), rien ne se passe.

J'ai bien rentré l'adresse mac du Shield. J'ai également changé l''adresse ip pour en utiliser une qui n'est pas utilisé sur mon réseau.

Je fais donc un ping sur cette ip et j'obtient "Impossible de joindre l’hôte de destination." 

En ouvrant mon port série, je me suis aperçu que je restais bloqué juste avant mon server.begin()

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  Serial.println("Before server.begin()");
  server.begin();
  Serial.println("After server.begin()");

  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.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);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        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("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          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(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

D'où pourrait venir cette erreur ?

 

Autre précision, n'ayant pas de sortie ethernet murale, je passe pas mon PC. Je mets un câble qui relie une switch, et de cette switch je vais à mon Shield.

 

Merci d'avance pour vos réponse ! :)


Problème alimentation Arduino Mega 2560

25 juin 2018 - 01:08

Bonjour,

Je fais un projet Arduino contenant un lecteur de carte RFID (le lecteur RC522), un lecteur de carte SD pour jouer de la musique (le MP3-TF-16P), 6 capteurs de proximité infra rouge (des TCRT5000) ainsi que 2 LEDs rgb.

Quand j'alimente l'Arduino avec une alim externe ainsi que l'usb de branché au PC pour lire des informations en série, tout fonctionne parfaitement, mais lorsque je retire l'usb du pc et que je reset l'Arduino, après quelques seconde, le son sortant du haut parleur se met à grésiller.

Serait-ce une manque de puissance de la part de l'Arduino ? Des chutes de tension ? Trop d'informations à traiter "simultanément" ?

Je vous remercie d'avance pour votre aide ! smile.png