Next we want a cellular gateway to receive the data from the nodes and forward it via GPRS to ThingSpeak and decided to use the A9/A9G modules. I have been testing this out using a NodeMCU ESP32 module connected to the A9 with jumper cables. I have found that if I use the same TX/RX pins as the GPS on the nodes (IO12 and IO15) the pudding board does not start when power is applied but if I use IO16 and IO17, the A9 boots OK but the ESP32 resets everytime it tries to send an AT command to the A9. Now, I have had the A9 connected to my laptop via an FTDI cable and using AI-Thinkers serial tool, I have sent AT commands and received replies so I know the A9 is OK.
This is the info the ESP32 spits out on reboot
Code: Select all
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.
Core 1 register dump:
PC : 0x400d0c8a PS : 0x00060730 A0 : 0x800d0d1a A1 : 0x3ffb1f50
A2 : 0x00000000 A3 : 0x3f400137 A4 : 0x000003e8 A5 : 0x3ffbfe78
A6 : 0x3ffbfe60 A7 : 0x000007e8 A8 : 0x3f4001ed A9 : 0x3ffb1f30
A10 : 0x0000002b A11 : 0x3f400137 A12 : 0x3ffbdbdc A13 : 0x00000010
A14 : 0x00000011 A15 : 0x00000008 SAR : 0x00000018 EXCCAUSE: 0x00000003
EXCVADDR: 0x3f4001ed LBEG : 0x4000c28c LEND : 0x4000c296 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x400d0c8a:0x3ffb1f50 0x400d0d17:0x3ffb1f80 0x400d1496:0x3ffb1fb0 0x400860dd:0x3ffb1fd0
Code: Select all
#define GPRSBAUD 115200
#define GPRSTX 16
#define GPRSRX 17
#define APN NXT17.net //APN for Telit Sim
#define GPRSserial Serial2 //define GPRSserial as ESP32 Serial2
char *response;
void setup()
{
Serial.begin(115200);
Serial.println();
GPRSserial.begin(GPRSBAUD, SERIAL_8N1, GPRSTX, GPRSRX);
delay(2000);
if(sendAT("AT","OK", 1000))
Serial.println(response);
if(sendAT("AT+CREG?","OK", 1000))
Serial.println(response);
}
void loop()
{
}
bool sendAT(char* ATcommand, char* expected, int timeout)
{
uint8_t x=0;
unsigned long LoopStart = millis();
bool Done = false;
bool Good = false;
int i;
response="";
//for(i=0; i<100; i++) response[i]=0;
while( GPRSserial.available())
GPRSserial.read(); // Clear the input buffer
GPRSserial.println(ATcommand); // Send the AT command
do // this loop waits for a response
{
if(GPRSserial.available() != 0)
{
response[x] = GPRSserial.read();
x++;
if (strstr(response, expected) != NULL)
Done = true;
if (strstr(response, "ERROR") != NULL)
{
Done = true;
Good = false;
}
}
}
while((!Done) && ((millis() - LoopStart) < timeout));
return Good;
}
Thanks for any advice, Steve.