element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Esp8266 and mySQL
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 5 replies
  • Subscribers 390 subscribers
  • Views 1211 views
  • Users 0 members are here
Related

Esp8266 and mySQL

nicolaoscon96
nicolaoscon96 over 5 years ago

Hello again,

 

To begin with, thanks on the advice that you gave me on my latest post (MySql and Php )... Now am coming back with one more question for my project... I set up my database which incudes (an id (which is auto increasment), username, email, and 2 more which are place0 and place1 (those two are boolean type)). Now my question is how can i connect an esp8266 directly to the database and update the booleans from 0 to 1 and back using a button for each one? Also how can i read the boolean on the esp and turn an led for example? I need to make it to update the values for a selected user...not all of them....for exaple i have users with id 1 , 2, 3...i need to make the updates only on 1 if that one is selected...

 

Thanks very much

Nikolaos Konstantinou

NcCon

  • Sign in to reply
  • Cancel

Top Replies

  • BigG
    BigG over 5 years ago +2
    Nicolas It sometimes helps to list out all your user requirements first before choosing your solution, which according to your posts is a website with php/mysql. I am not sure why you chose that option…
  • BigG
    BigG over 5 years ago in reply to nicolaoscon96 +1
    Short answer, is yes it is possible. Your next step is to think about which localised (as in on home network only) communication protocol to use to meet your requirements. As you well know, web browsers…
Parents
  • BigG
    BigG over 5 years ago

    Nicolas

     

    It sometimes helps to list out all your user requirements first before choosing your solution, which according to your posts is a website with php/mysql. I am not sure why you chose that option but that decision may need to be revisited, if you want to make things easier for yourself.

     

    So from your post I see your requirements as:

     

    1- want to control various things around the house (IoT).

    2- want other people added to the database each one with his/her own credentials (my family for example).

    3- want to connect an esp8266 directly to the database and update the booleans from 0 to 1 and back using a button for each one

    4- want to read the boolean on the esp and turn an led

    5- want to make it to update the values for a selected user...not all of them

     

    It is not clear from your posts where you are hosting your website+database. If we assume it is on a web hosting site outside of your home network then this will lead to one type of simple solution vs. if you are hosting it just locally on your home network.

     

    So, where are you wanting to host the website or the "back-office" server or controller?

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • nicolaoscon96
    nicolaoscon96 over 5 years ago in reply to BigG

    My website and the database are hosted at my house (a small server is running for that) along with the esp(that am planning to install) ...I need the esp to be able to send and receive data from the database. Is this possible?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • nicolaoscon96
    nicolaoscon96 over 5 years ago in reply to BigG

    My website and the database are hosted at my house (a small server is running for that) along with the esp(that am planning to install) ...I need the esp to be able to send and receive data from the database. Is this possible?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • BigG
    BigG over 5 years ago in reply to nicolaoscon96

    Short answer, is yes it is possible.

     

    Your next step is to think about which localised (as in on home network only) communication protocol to use to meet your requirements.

     

    As you well know, web browsers, which would be classed as a "client", use http/https to request information from a web server. The information request is based on an IP address (or via domain name) and then a path or route to a specific web page. Additional parameters can be used by the "client" to GET information from the server or to POST information to the server.

     

    With this method is it not possible for a server to initiate communication with a client. Only a client can initiate communication with a server.

     

    So on a simplified level RESTful methods of requesting and posting information using http/https is not suitable.

     

    So what next. Well, there are ways around this.

     

    Probably the more popular method to use would be to establish an MQTT broker. There are numerous options available. Then you can have your ESP8266 "subscribe" to the broker to listen for requests and can "publish" data to the broker when an event occurs etc.

     

    Another option would be to establish a "web socket". A Websocket allows you to open a bi-directional communication channel, or tunnel, between your ESP8266 and your local server.

     

    If you search online you can find info on how to do. For example, here is one for php+mqtt: 

    https://mosquitto.org/blog/2010/09/mqtt-with-php/

     

    Maybe others can give other suggestions and/or guidance on leading you through this process.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • neilk
    neilk over 5 years ago in reply to nicolaoscon96

    Hi Nicolas

     

    I have system running in which an ESP-8266, operating as an HTTP CLIENT, regularly updates my local server, writing temperature data to a ,csv file via a POST command and a php script on the server.

     

    As @BigG has said, it is not possible for the server to initiate communication with the client, although I think it is possible (I haven't done it) for the client to request data back from the server.

     

    Best wishes

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • neilk
    neilk over 5 years ago in reply to nicolaoscon96

    And I just spotted this:

     

    https://randomnerdtutorials.com/esp32-esp8266-mysql-database-php/

     

    You should find this useful

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube