- Code has been changed slightly to help with long latency issues over wifi and slow connections.
- A new cleanup method was added to cleanup a final OK packet after a stored procedure call with a result.
- Code now compiles without errors for the latest Beta Arduino IDE (const error).
Enjoy!
Mr Chuck, i have problem to run your example program in arduino 1.6.0 can you explain it ?
ReplyDeletemysql_connector.ino: In function 'void do_query(const char*)':
mysql_connector.ino:69:3: error: 'column_names' was not declared in this scope
mysql_connector.ino:69:17: error: 'c' was not declared in this scope
mysql_connector.ino:70:3: error: 'row_values' was not declared in this scope
mysql_connector.ino:70:15: error: 'r' was not declared in this scope
mysql_connector.ino:85:15: error: 'class Connector' has no member named 'get_columns'
mysql_connector.ino:100:17: error: 'class Connector' has no member named 'get_next_row'
mysql_connector.ino:114:15: error: 'class Connector' has no member named 'free_row_buffer'
mysql_connector.ino:122:11: error: 'class Connector' has no member named 'free_columns_buffer'
Error compiling.
You must enable SELECT queries by uncommenting WITH_SELECT in mysql.h.
DeleteI'm sorry Mr Chuck, after i unceomment WITH_SELECT i have problem
DeleteIn file included from C:\Program Files (x86)\Arduino\libraries\sha1\sha1.cpp:3:0:
C:\Program Files (x86)\Arduino\libraries\sha1\sha1.cpp:11:25: error: variable 'sha1InitState' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
uint8_t sha1InitState[] PROGMEM = {
^
Error compiling.
Add const before the statement. You will have to do this in a couple of places.
DeleteCheck that you are using the 1.03 code because this was fixed in that release. What version of the IDE are you using?
DeleteThis comment has been removed by the author.
Deletei am using arduino 1.6.0 , this is link a sample code https://simpan.ugm.ac.id/public.php?service=files&t=c102747b529f281db78b8ac7d58baa5a
Deletei have wearable sensor project, my projenct is sent data sensor in mysql. and i think if i use mysql connector, made me esay
What is your question? I see you deleted the previous post. Please state the nature of your question. Thanks.
DeleteI'M sorry Mr Chuck, i deleted previous question because i try to solve by my self
Deletethe error message :
mysql_connector\mysql.cpp.o: In function `Connector::wait_for_client()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:49: multiple definition of `Connector::Connector()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:49: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::wait_for_client()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:49: multiple definition of `Connector::Connector()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:49: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::mysql_connect(IPAddress, int, char*, char*)':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:299: multiple definition of `Connector::free_columns_buffer()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:299: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::free_row_buffer()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:328: multiple definition of `Connector::free_row_buffer()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:328: first defined here
Deletemysql_connector\mysql.cpp.o: In function `Connector::parse_handshake_packet()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:675: multiple definition of `Connector::parse_handshake_packet()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:675: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::check_ok_packet()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:742: multiple definition of `Connector::check_ok_packet()'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:742: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::get_lcb_len(int)':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:772: multiple definition of `Connector::get_lcb_len(int)'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:772: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::read_string(int*)':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:787: multiple definition of `Connector::read_string(int*)'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:787: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::read_int(int, int)':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:815: multiple definition of `Connector::read_int(int, int)'
mysql.cpp.o:C:\Users\milanola\AppData\Local\Temp\build5859618431298751533.tmp/mysql.cpp:815: first defined here
mysql_connector\mysql.cpp.o: In function `Connector::parse_error_packet()':
C:\Program Files (x86)\Arduino\libraries\mysql_connector/mysql.cpp:714: multiple definition of `Connector::parse_error_packet()'
that messages after i deleted some folder in AppData/Temp/build....
Deletewhat the effect if i delete it ?
This comment has been removed by the author.
ReplyDeletei get the same errors even uncommenting #define WITH_SELECT in mysql.h file
ReplyDeleteIf you edited mysql.h while the IDE was running, you must restart the IDE to pickup the changes. Either that or you have multiple copies of the connector. You need only one located in your Arduino libraries folder.
DeleteThis comment has been removed by the author.
ReplyDeleteHi Chuck, may I congratulate this library, I really like its readability and documentation! There were a few adjustments to it that I made to get it to work properly (some functions weren't returning their associated types etc.) wish I had documented these as I went along so I could be more specific... But still, I didn't think a SQL connection could be possible, so really well done!
ReplyDeleteAnyway, I am only using SELECT queries and require the arduino to query the database every 2 seconds, however it sometimes gets stuck so I have to use the wdt watchdog to restart the program (which is slow). I was just wondering if opening a persistent SQL connection could solve this? And is it possible using the mysql_connector library?
Thanks,
Dan
Hi. Yes, you can use a persistent connection. Place the connect in the setup() and don't call disconnect.
DeleteAs for time outs, yes, that is a possibility with the Arduino. Mostly this is due to memory issues. Be sure you are clearing all of the buffers after each query and that a row returned can fit in the remaining memory space. About 90% of these issues are memory related.
Other than that, consider the Arduino isn't the fastest beastie so even 2 seconds might be too frequent if there is network latency or large result sets to query.
However, I would recommend keeping a watch on memory usage first.
Dear Chuck
ReplyDeleteI am attempting to verify the mysql_connector_basic sketch Example 1.
I have uncommented WITH_SELECT in mysql.h.
I am now getting the following error:
Arduino: 1.6.1 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/Users/tscott/Documents/Arduino/libraries/mysql_connector/mysql.cpp: In member function 'void Connector::show_results()':
/Users/tscott/Documents/Arduino/libraries/mysql_connector/mysql.cpp:237:19: error: 'clear_ok_packet' was not declared in this scope
clear_ok_packet();
^
/Users/tscott/Documents/Arduino/libraries/mysql_connector/mysql.cpp: At global scope:
/Users/tscott/Documents/Arduino/libraries/mysql_connector/mysql.cpp:250:36: error: no 'bool Connector::clear_ok_packet()' member function declared in class 'Connector'
bool Connector::clear_ok_packet() {
^
Error compiling.
********
TIA
Regards
Tim
I do not see that error. Is it possible you modified mysql.h with a different editor while the Arduino IDE was running? If so, you must restart the Arduino IDE to see the changes.
DeleteThe only other thing that may be happening (although unlikely) is you have more than one set of the connector files in you libraries folder.
This can happen if you download the .zip file, copy it to your Libraries folder, unzip it, then discover the name is different and instead of moving and rename, you copy and rename. In this case, you will get strange errors like this. Make sure there is only one copy of the connector folders.
Even less likely - grasping at straws level here - you had an older copy of the connector and mis-copied the new files mixing the old and new code. In this case, and old mysql.h with a new mysql.cpp.
Hello Chuck,
ReplyDeletefirst I want to thank you for the great work really !
I tested alot of things with the connector, and I'm beginning to get it right. But I have a problem when using get_next_row()... it seems to stop my programs (no further lines executed).
Do you have an Idea what I am doing wrong ?
(Even tried the Example 3 as is, same issue!)
Thanks for your help.
Ben
I think it has something to do with EOF_Packet because get_next_row doesn't return NULL when it should be, if this is of any help..
DeletePS . I run Mysql v5.6.21
Dear Chuck,
DeleteI think I found the problem, in mysql.cpp, the get_row_value is declared as Boolean, but it is supposed to return integers (to be able to return EOF_PACKET) . I changed it to "Int" and also did the correction in mysql.h and it works, Now i can run Example_3 without any problem. Maybe you could confirm that what I did is good and won't cause other bug ?
Thank you, and again, your work is unbelievably awesome,
Ben
Hi. Yes, that could do it. I've not run into that problem myself as it compiles and runs smoothly - even example 3.
DeleteRather than change the method to int, I am inclined to change:
else {
return res;
to
else {
return false;
So that the method signature doesn't change. If you want to try that, you can let me know how it works (or not). ;)
Unfortunately it doesn't seem to work well. The get_next_row indeed receives 0 in the variable "res", but when testing if (res != EOF_PACKET) always validates and never returns "NULL"...
DeleteWith this modification, example 3 loops infinitely, executing get_next_row() over and over.
Ok, I will look into it and get back to you.
DeleteHi. Can you please send me your email address so I can send you a file to test with?
Deleted r c h a r l e s b e l l at g m a i l dot c o m
Hi. I have changed the code to remove the ambiguity in the return type, but once again all of the examples work for me before and after the change. I'd like to send you the code so you can test it.
DeleteGood evening! I'm trying to do a select in my database. I have uncommented the WITH_SELECT in the library but the same error persists. Could anyone help me? the error is displayed on the same topic.
ReplyDeleteThank you!
Good evening! I'm trying to do a select in my database. I have uncommented the WITH_SELECT in the library but the same error persists. Could anyone help me? the error is displayed on the same topic.
ReplyDeleteThank you!
I can try. Please post the error as I don't know what you're experiencing. You can read the reference manual on the launchpad site for solutions to common errors. Also, be sure to use the latest version as 1.0.4 has a critical fix for working with the latest versions of MySQL.
DeleteFinally, aside from the actual error message, it would be very helpful to know what Arduino you're using, what version of the connector you have, your platform, whether you are using WiFi or Ethernet, what shield you're using, and version of the Arduino IDE.
Hello
ReplyDeleteim newbie at arudino world, and i dont know english very well, so sorry for that.
sprintf(sqlbuf, "USE brsdb; insert `baris` (`Humidity`, `Temperature`, `DayTime`) VALUES(%d,%d,now())", DHT.humidity, DHT.temperature);
mysql tables are float. DHT.humi and temp are produce float data. When i run this sketch it starts to record values to mysql. But values seem 0 or 16530 etc however serial monitor show 23.4 etc.. i think i should use %f instead of useing %d, but if i use %f, an error appear at arduino serial monitor that says sql sytx error. can you help me to find a way to record decimal values
there is a command called "dtostrf".. should i focus on it?
Yes, the Arduino environment is not float friendly. You must use dtostrf() to convert floats to strings. See the example code in the connector. Note: the latest version is 1.0.4, please download and use that version if don't already have it.
Deletei will make a search for dtostrf(). thank you to quick reply.
DeleteBest Regards