Go Down

Topic: Arduino Micro with ESP8266 (Radino) over SPI-UART bridge (Read 366 times) previous topic - next topic


Hello guys,

Hope someone can help me with my problem:
I have following module [1] powered and programmable over USB with Arduino IDE. Using the module (so setting up access point or connect to existing WiFi) works perfectly. Now I would like to send AT commands to the ESP from Arduino IDE using the integrated SPI-UART bridge. Therefore I use this simple code:
Code: [Select]

// Use SPI-library for communication with SC16IS750
#include <SPI.h>

// Include definitions and functions for SC16IS750
// SPI-to-UART-chip
#include "SC16IS750.h"

// Pin definitions of ESP8266
//       Pin-Name   Arduino-Pin-Number
#define  CH_PD      A4
#define  CH_RST     4
#define  GPIO0      9
//       Pin-Name   SC16IS750-GPIO-Number
#define  GPIO2      0

// Define Serial port that should be used for communication
// Valid values:
// USB-UART:       Serial
// Hardware-UART:  Serial1
#define progSerial Serial

// Set baudrate of SPI-UART chip to communicate with ESP8266
// e.g. Firmware Version 9.2.2 uses baudrate 9600 by default, but it can be modified by command AT+CIOBAUD=9600
// older Firmware Versions use baudrate 115200
#define ESP8266_BAUDRATE  9600

 * Setup connections for normal operation of ESP8266 WiFi-Chip
void ESP8266_setNormalOperationMode()
  pinMode(CH_PD, OUTPUT);  // Chip-Enable of ESP8266
  digitalWrite(CH_PD, HIGH);  // HIGH
  pinMode(GPIO0, OUTPUT);  // GPIO0 of ESP8266
  digitalWrite(GPIO0, HIGH);  // HIGH
  // GPIO of SC16 is connected to GPIO2 of ESP8266
  SC16_GPIO_pinMode(GPIO2, SC16_GPIO_OUTPUT);  // GPIO2 of ESP8266
  SC16_GPIO_digitalWrite(GPIO2, 1);  // HIGH
  // Perform RESET of ESP8266
  digitalWrite(CH_RST, LOW);  // Pull RESET of WIFI-Chip
  digitalWrite(CH_RST, HIGH);  // Disable RESET of WIFI-Chip

void setup()
  // When connecting to radino WiFi, always set baudrate to 57600 max.
  // This baudrate does not effect the baudrate of ESP8266 WiFi-Chip
  progSerial.begin(57600);  // Start serial port at baudrate 57600
  progSerial.println("Hello");  // Print a welcome message

  // Init SPI-UART-Module
  // Set Baudrate of SPI-UART-Module
  // Put ESP8266 into normal operation mode
  SC16_flush();  // Clear UART-buffers

 * Connect external UART to ESP8266-UART through SC17IS750 SPI-UART-Chip
 * This enables direct communication with ESP8266 WiFi-Chip
void loop()
  char data = '0';
  progSerial.println("Sending AT command...");
  progSerial.println(SC16_available()); //always 0 :(

The SC16_println() automatically adds ASCII 13 and 10 so the AT command should be terminated correctly. Unfortunately callind SC16_available() always return 0 -> no answer.
What am I doing wrong?

best regards,

[1] http://wiki.in-circuit.de/images/6/69/305000076A_radino_WiFi.pdf


Normally ESPs would be configured to 115200 bauds. Can you give it a try?
Also, there is some setup mismatch - you use normal digitalWrite() and pinMode() for some of the pins and you use SC16_GPIO_.. variants for GPIO2. Don't really know this particular platform, but inconsistency may be the key.


I figured it out a couple minutes ago. Thanks for your help, you were absolutely right :)!


No bother :) ESPs are very notorious and painful devices...

Go Up