MySQL Forums :: Connector/Arduino :: Read values float from mysql

Advanced Search

Read values float from mysql
Posted by: Denys Oliveira ()
Date: August 18, 2015 07:07AM

I need read a value float from my data base.
I using this code from a example(I changed only the select)
But I could only read the whole of the value and I need the two decimal places

value displayed in serial monitor = 127

necessary value = 127.62

anybody can help me?

* Example: Simple Select Example: Hello, MySQL!
* This code module demonstrates how to create a simple
* database-enabled sketch with selecting data.
#include <SPI.h>
#include <Ethernet.h>
#include <sha1.h>
#include <mysql.h>
/* Setup for Ethernet Library */
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server_addr(192, 168, 0, 103);
/* Setup for the Connector/Arduino */
Connector my_conn; // The Connector/Arduino reference
char user[] = "operador";
char password[] = "secret";
const char QUERY_POP[] =
"SELECT tensao FROM banco.hello WHERE id = (SELECT MAX(id) FROM banco.hello)";
float head_count = 0;
void setup() {
while (!Serial);
if (my_conn.mysql_connect(server_addr, 3306, user, password)){
row_values *row = NULL;
do {
row = my_conn.get_next_row();
// We use the first value returned in the row - population of NYC!
if (row != NULL) {
head_count = atol(row->values[0]);
} while (row != NULL);
Serial.print("ultima tensao = ");
} else {
Serial.println("Connection failed.");
void loop() {

Options: ReplyQuote

Subject Views Written By Posted
Read values float from mysql 1382 Denys Oliveira 08/18/2015 07:07AM
Re: Read values float from mysql 570 Charles Bell 08/20/2015 07:10AM
Re: Read values float from mysql 532 Denys Oliveira 08/20/2015 09:09AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.