萌新求解esp8266连接mysql问题 求求各位大佬!-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 544|回复: 5

[未解决] 萌新求解esp8266连接mysql问题 求求各位大佬!

[复制链接]
发表于 2022-4-9 23:44 | 显示全部楼层 |阅读模式
使用arduino ide上的Mysql_Connector_Arduino的库示例,成功上传后esp8266一直复位重启。 已测试单纯连接wifi不会重启 ,稳定运行,一旦尝试连接mysql就会重启。
具体代码如下:
#include <ESP8266WiFi.h>         
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

IPAddress server_addr(192, 168, 43, 162);
char user[] = "root";            
char password[] = "root";        

// Sample query
char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";

// WiFi card example
char ssid[] = "qwerq";        
char pass[] = "123456789";   

WiFiClient client;               
MySQL_Connection conn(&client);
MySQL_Cursor* cursor;

void setup()
{
  Serial.begin(115200);
  while (!Serial);
  // Begin WiFi section
  Serial.printf("\nConnecting to %s", ssid);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  // print out info about the connection:
  Serial.println("\nConnected to network");
  Serial.print("My IP address is: ");
  Serial.println(WiFi.localIP());

  Serial.print("Connecting to SQL...  ");
  if (conn.connect(server_addr, 3306, user, password))
    Serial.println("OK.");
  else
    Serial.println("FAILED.");

  // create MySQL cursor object
  cursor = new MySQL_Cursor(&conn);
}

void loop()
{
  if (conn.connected())
    cursor->execute(INSERT_SQL);

  delay(5000);
}


串口打印的信息  (不断重复打印)
...........
Connected to network
My IP address is: 192.168.43.138
Connecting to SQL...  ...trying...

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (28):
epc1=0x40202574 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000049 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffc40 end: 3fffffc0 offset: 0190
3ffffdd0:  3ffed2c4 40220450 3ffed240 3ffef97c  
3ffffde0:  3ffef97c 3ffef5a0 00000001 402025c7  
3ffffdf0:  40210000 00000000 3ffe8624 402025b4  
3ffffe00:  3ffef9c0 3ffeeb2c 3ffef5a0 4020674c  
3ffffe10:  fffffffc 3ffed3bc 00000002 00000000  
3ffffe20:  00000014 3ffef59c 000000ff 3ffee5dc  
3ffffe30:  40206718 3ffe8624 3ffee644 40202f04  
3ffffe40:  3ffef97c 3ffee644 00000000 40202f28  
3ffffe50:  3ffef97c 3ffee644 3ffee644 40203084  
3ffffe60:  3ffeeb2c 00000000 00000000 4020297b  
3ffffe70:  00000000 00000000 40100209 402151b2  
3ffffe80:  00000170 00000170 3ffe8644 401006c3  
3ffffe90:  00000000 4bc6a7f0 4083126e 00000001  
3ffffea0:  3ffefb84 00000020 3ffefb84 401008a2  
3ffffeb0:  3ffee170 00000000 00000000 40100298  
3ffffec0:  00002781 3ffee80c 0000012c 40215c18  
3ffffed0:  0000012f 0000012f 3ffe8644 401006c3  
3ffffee0:  3ffe8624 00000000 3ffef65c 3ffe8624  
3ffffef0:  00000000 00000029 00000020 3ffe8624  
3fffff00:  00000000 00000029 3ffee5dc 40202abe  
3fffff10:  00000004 3ffef97c 3ffee5dc 40202832  
3fffff20:  0000004a 00000100 0001c200 00000003  
3fffff30:  00000001 3ffee71c 3ffee5dc 40202216  
3fffff40:  40206bc8 a42ba8c0 3ffee71c 40202c94  
3fffff50:  3fffff90 00000cea 3ffe8629 3ffe8624  
3fffff60:  00000000 40201f70 3ffee71c 40202f28  
3fffff70:  8a2ba8c0 00ffffff 012ba8c0 3ffee7a8  
3fffff80:  3ffe85d2 3ffee5dc 3ffee71c 40201101  
3fffff90:  40206bc8 a42ba8c0 feefeffe feefeffe  
3fffffa0:  3fffdad0 00000000 3ffee794 40203c28  
3fffffb0:  feefeffe feefeffe 3ffe8640 40100b55  
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

ets Jan  8 2013,rst cause:2, boot mode3,6)

load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00044e00
~ld

Connecting to qwerq.......
Connected to network
My IP address is: 192.168.43.138
Connecting to SQL...  ...trying...


发表于 2022-4-10 21:50 | 显示全部楼层
我是直接连不上,每次都是FAILED
 楼主| 发表于 2022-4-13 09:50 | 显示全部楼层

请问大佬怎么解决这个问题
发表于 2022-4-13 11:47 | 显示全部楼层
螃蟹克 发表于 2022-4-13 09:50
请问大佬怎么解决这个问题

估计库问题了
 楼主| 发表于 2022-4-13 11:55 | 显示全部楼层

是需要更换一个esp8266的库吗?还是更换一个arduino连接mysql的库?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 09:39 , Processed in 0.103520 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表