Arduino Forum

Topics => Science and Measurement => Topic started by: rahulkp1986 on Mar 24, 2018, 07:41 pm

Title: Send data to mysql through esp8266 and uno
Post by: rahulkp1986 on Mar 24, 2018, 07:41 pm
Hi all
I have a uno which runs that attached code. I have a esp8266 connected to my tx and rx of uno, can anyone help me modify my program so that arduino can directly insert the temperature to mysql database using mysql connector?

Esp8266 is connected to my WiFi router and my pc is also connected to the same WiFi router

My database setup is like this

I have an odbc with connected to mysql database,  connection name is TEMPLOG

Mysql is installed in my pc and it's ip is 192.168.1.50

Mysql is in my pc at address localhost

User name root
Pass: @temp@12

Database has 3 column
I'd ( auto incriment)
Date (system date)
Temperature (where we need to insert data)

Is it possible to insert data directly?

This is my sketch
.

/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices 
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
void setup(void)
{
 // start serial port
 Serial.begin(9600);
 Serial.println("Dallas Temperature IC Control Library Demo");
 // Start up the library
 sensors.begin();
}
void loop(void)
{
 // call sensors.requestTemperatures() to issue a global temperature
 // request to all devices on the bus
/********************************************************************/
 Serial.print(" Requesting temperatures...");
 sensors.requestTemperatures(); // Send the command to get temperature readings
 Serial.println("DONE");
/********************************************************************/
 Serial.print("Temperature is: ");
 Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"? 
   // You can have more than one DS18B20 on the same bus. 
   // 0 refers to the first IC on the wire
   delay(1000);
}
Title: Re: Send data to mysql through esp8266 and uno
Post by: mrphysh on Mar 31, 2018, 02:42 am
I have the same question.   The MySQL database is up and running.  How to put data into a MySQL database.  (I have a Mega 2650.  The application is similar to yours)
Title: Re: Send data to mysql through esp8266 and uno
Post by: wildbill on Mar 31, 2018, 01:14 pm
There are several ways. The most common is to create a web page on a server somewhere. Have your arduino act as web client using a GET request to access the web page. Whatever data you want to pass to the web server is sent as parameters in the GET. Parse the returned web page if desired to get results. Often, this step is ommitted as the only point was to pass IoT data to the database. Then the web server stores the data in the database.

You can do it directly too, see here. (https://www.arduinolibraries.info/libraries/my-sql-connector-arduino)
Title: Re: Send data to mysql through esp8266 and uno
Post by: Hdiouech_Montassar on May 21, 2019, 01:05 pm
Have you attend to send data ??? Can you post the code please ??!!
Title: Re: Send data to mysql through esp8266 and uno
Post by: Idahowalker on May 21, 2019, 05:25 pm
Hi all

I have a uno which runs that attached code. I have a esp8266 connected to my tx and rx of uno
No level shifters? And the ESP8266, a 3.3V device, still continues to work with the 5.0V device?  I use ESP32's and they do not take much more than 5.1V before they act like fuses.