AVR send data to mysql

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I try to find solution how using atmega8 need send any data to mysql through internet shield. I tried to find information google, but don't find solution. Maybe could somebody me give way or suggest how need do it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you use an internet shield you would need to have a web app to receive data and store the data to your MySQL DB.

This can be done using MQQT protocol to communicate with a RESTful web application from your Atmel device.

 

Google these termsl:  RESTful Web apI and MQQT

Happy Trails,

Mike

JaxCoder.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mike32217 wrote:
MQQT

* MQTT

 

http://mqtt.org/

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pcwortex wrote:
I tried to find information google, but don't find solution

Don't expect google to give you a canned, ready-to-go solution.

 

In particular, not a solution specific to ATmega8 !

 

(you may get lucky - but don't rely upon it)

 

Instead, you should be able to find out what needs to be done.

 

It is then your job to work out how to do that.

 

As Mike says, the "what" will be in terms of what protocols to use (HTTP, MQTT, etc), and what messages to send over them.

 

EDIT

 

curl is a very useful tool for playing with internet protocols - you can use it to "manually" send messages, and see the replies:

 

https://curl.haxx.se/docs/manpage.html

 

MySQL is very widely used - so it shouldn't be hard to find examples & tutorials showing how the protocols work

 

https://www.mysql.com/

 

https://leadsbridge.com/documentation/mysql/curl/

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Dec 4, 2019 - 06:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The quickest way to find AVR examples is to google "Arduino what your looking for" so in this case "arduino send data to mysql database"

The first hit is a a project on git hub here: https://github.com/ericbenwa/POS...

 

Should get you started!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think, I use PHP write code which take data from URL and send to mysql. Atmega send URL address for example www.ortex.lt/?data1=45&data2=78

 

<?php
$number1=$_GET['data1'];

$number2=$_GET['data2'];
?>

 

I take information this method. Now need from atmega send address with information which need for me, but I don't know how need do it.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A mega8 and ethernet shield is rather constrained and not the most economical solution these days. Sure, it can be done, but there are cheaper/better/faster alternatives. The main problem with the mega8 is the lack of ram - with the ethernet shield you need to manage the tcp stack as well as the data you want to send. The outcome is that you can only send small blocks of data slowly. This may not be a problem to you. As well, there's the Wiznet boards that offload the tcp stack. 

 

Something like the esp32 is well supported and has a 32 bit cpu, wifi and plenty of ram. Protocols like MQTT are well supported.

 

At the PC end, there’s the likes of CodeRed to manage the data. There’s plenty of other open source solutions.

 

I’ve done enterprise level solutions using php and mysql. I’d lean towards NodeJs these days mainly because it’s easier to do socket connections etc.

 

With a mega8 class of processor, I'd suggest using serial to something like a RaspberryPi or wireless router with alternative firmware (openwrt) or straight to the PC. Arduino use a similar solution with their Yun. If you have access to Arduino clone boards, then they have usb serial, so that just plugs straight into a Pi, PC or whatever.

 

Depending on what part of the world you live in constrains what you have available at a price you're willing to pay. In my travels, it has always perplexed me that things that are easy to get in Australia are difficult to get in, say, Egypt where Egypt is less than 6 hours by air to the UK vs 20 hours from Australia! 

 

Currently there's an explosion of wifi enabled consumer stuff like 'smart' lights and switches. I've hacked a few of these and invariably they have a esp8266 board in them. There's plenty of example code, direct hacks etc for these, so maybe in your part of the world these may be cheap and accessible for you (I find them at the local hardware and department stores). Personally, the esp8266 is a bit limited for my liking - the i/o is minimal, however, for some pwm, input, output and serial they are cheap and cheerful. There's also Arduino support, so that gives you an easy entry and plenty of examples.

 

 

This is something I played with MANY years ago:

http://tuxgraphics.org/electroni...

In fact, my garage lighting is based on this. I'm too lazy too update it as it works and has worked for many years.

 

 

 

Last Edited: Wed. Dec 4, 2019 - 10:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For a little clarity, here...

 

You cannot SEND DATA TO MYSQL. Perhaps this is a bit subtle, so let me try to explain.

 

You CAN send data to an application that provides an interface to a mysql database. mysql has no way to receive or send data. The database has to be written to or read from. One analogy might be a hard drive. You cannot just "send data to a hard drive" with a serial port because hard drives do not have direct interfaces with serial ports. Similar with databases. There has to  be software, in-between, the accesses the data via the serial port, and writes it to the database.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually Jim, you can send data to MySql. All you need is a socket connection and send correctly formed messages to it. Of course, not something you'd normally do from a mega8, but not impossible.

I can't say I've interfaced to Mysql at that level, as there's been drivers and connectors to work with it at a higher level. 

 

Maybe I'm being a bit too literal, but your point of that there is a number of steps involved is correct. What those actual steps are, is wide and varied. Hopefully the OP can give us a bit more idea of what they are wanting to achieve.