Itsybitsy M0 Express to esp8266 for wifi

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rlgjr562
 
Posts: 60
Joined: Sun Jan 21, 2018 5:02 pm

Itsybitsy M0 Express to esp8266 for wifi

Post by rlgjr562 »

I am trying to get a Itsybitsy M0 express to talk to a ESP8266. Both are from Adafruit. Reading various Adafruit and Arduino Forums it was said look to the Arduino Zero for example code since they both use the same chip. I found several likely candidates both they use WiFiEsp.h. A bit of example code I found that looks useful below. I cannot get it to compile. Initially I was getting an error that class ringbuffer was already defined. While writing this I updated my board definitions and now I am getting the error:
Arduino: 1.8.5 (Windows 10), Board: "Adafruit ItsyBitsy M0"

Board adafruit_itsybitsy_m0 (platform samd, package adafruit) is unknown

Error compiling for board Adafruit ItsyBitsy M0.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences
.


If there is a better library to use or better example code please point me in to the right direction.

I have spent several weeks looking for the right library. I have found many of the examples and Libraries are for the arduino 328 or Uno or another chip type that does not work with the samd21.

Code: Select all

#include "WiFiEsp.h"

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;    // your network SSID (name) in secrets as #define SECRET_SSID "yourSecret"
char pass[] = SECRET_PASS;    // your network password    in secrets as #define SECRET_PASS "yourPass"

int status = WL_IDLE_STATUS;     // the Wifi radio's status

char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiEspClient client;

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  // you're connected now, so print out the data
  Serial.println("You're connected to the network");
  
  printWifiStatus();

  Serial.println();
  Serial.println("Starting connection to server...");
  // if you get a connection, report back via serial
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("GET /asciilogo.txt HTTP/1.1");
    client.println("Host: arduino.cc");
    client.println("Connection: close");
    client.println();
  }
}

void loop()
{
  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}


void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsybitsy M0 Express to esp8266 for wifi

Post by adafruit_support_mike »

How are you trying to make them communicate.. through Wifi, a wired Serial connection, or something else?

User avatar
rlgjr562
 
Posts: 60
Joined: Sun Jan 21, 2018 5:02 pm

Re: Itsybitsy M0 Express to esp8266 for wifi

Post by rlgjr562 »

I am open to suggestions but my thought was to use the rx/tx on pins 0 & 1 on the Itsybitsy to the tx/rx pins on the ESP8266. I have looked for a library to either provide the serial communication to the ESP8266 or a WiFi library. The last I tried was WiFiEsp but that does not seem to be compatible with the ItsyBitsy M0

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsybitsy M0 Express to esp8266 for wifi

Post by adafruit_support_mike »

A Serial connection will work, but you can only use the ESP8266's TX/RX pins if you don't have the Feather connected to a computer through a USB cable.

The ESP9266 doesn't know how to handle USB itself, so the Feather has a USB-to-Serial converter like the one on an Arduino Uno. Trying to connect another Serial device to those pins while the computer is also connected can damage the chip.

The ESP8266 can run a SoftwareSerial connection on its other GPIO pins though. That would be able to talk to the M0's TX/RX pins.

User avatar
rlgjr562
 
Posts: 60
Joined: Sun Jan 21, 2018 5:02 pm

Re: Itsybitsy M0 Express to esp8266 for wifi

Post by rlgjr562 »

I am using the ESP8266 SMT Module. I think thew actual module shipped is the ESP-12S PID: 2491. The module does not have a USB connection.

When I ordered it I had found something on the Adafruit site that made it seem fairly simple to talk from the ItsyBitsy M0 or other M0 type modules to the ESP Module. but I have not been able to find it again. I was thinking it was one of the Learn articles. Many of the M0 type devices seem to have had the learn articles switched to Circuit Python(this seems to be the current direction, which is ok). I think that is why I am not finding the article though. But I am not stuck on a specific solution, Whether I use AT commands and serial read/write commands or some sort of wifi command I am not picky.


I did get the error that I documented in this fixed and I am back to my original error. This is using the Library WiFiEsp. This is said to be compatible with the SAMD21 chips. But it seems to not be compatible with the ItsyBitsy M0. If there is a better library point me in that direction.

In file included from C:\Users\richard\Documents\Arduino\libraries\WiFiEsp\src/utility/EspDrv.h:26:0,
from C:\Users\richard\Documents\Arduino\libraries\WiFiEsp\src/WiFiEsp.h:30,
from C:\Users\richard\Documents\Arduino\Serial_monitor\Serial_monitor.ino:1:
C:\Users\richard\Documents\Arduino\libraries\WiFiEsp\src/utility/RingBuffer.h:23:7: error: redefinition of 'class RingBuffer'
class RingBuffer
^
In file included from C:\Users\richard\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.1.0\cores\arduino/Uart.h:23:0,
from C:\Users\richard\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.1.0\variants\itsybitsy_m0/variant.h:43,
from C:\Users\richard\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.1.0\cores\arduino/delay.h:27,
from C:\Users\richard\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.1.0\cores\arduino/Arduino.h:81,
from sketch\Serial_monitor.ino.cpp:1:
C:\Users\richard\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.1.0\cores\arduino/RingBuffer.h:30:7: error: previous definition of 'class RingBuffer'
class RingBuffer
^
exit status 1
Error compiling for board Adafruit ItsyBitsy M0.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Itsybitsy M0 Express to esp8266 for wifi

Post by adafruit_support_mike »

CircuitPython is one development environment we're working on, but not to the exclusion of any other way to program the boards.

The AT-command interface will probably be the easiest for you to use if you just want to use the ESP8266 as a Wifi adapter. We're used to programming it directly, so I was thinking about the connection in those terms.

From the error messages above, it looks like the WiFIEsp library has given a class the same name as one from the SAMD21 board support package. Of the two, it would probably be easier to refactor the WiFiEsp library and give that class another name. That should sidestep the problem.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”