Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Save Data to Kintone with an ESP8266

Posted on Aug 31 • Originally published at Kintone.dev This article introduces how to save data to a Kintone App using a NodeMCU ESP8266 device.While the device used in this tutorial is an ESP8266, the concepts apply to most if not all Arduino devices with Wi-Fi capabilities. And similarly, while the Web Database used in this tutorial is Kintone, changing the contents of the HTTP Request will allows for any REST API based web database to be used.The general flow of this tutorial is as follows:First connect the ESP8266 to your computer via USB cable. Note that the quality of cable matters, and a high quality USB cable should be used, or else the cable will only provide power and will fail to transfer data.Download and install the Arduino IDE. After installation, open the IDE to the first sketch.Open the settings menu, and in the Additional Boards Manager URLs option, add the following open source ESP8266 repository URL: https://arduino.esp8266.com/stable/package_esp8266com_index.jsonThis will allow support for various Arduino and other micro-controller devices based on the ESP8266 chip to be downloaded.Next, open the library tab on the left side of the IDE, and search for ESP8266. Install the latest version.Next, ensure that the ESP8266 is connected via USB cable, and in the top menu, select the ESP8266 model to use. If it is not displayed automatically, click on the Select Other Board and Port menu item.Search for ESP8266, and select the model that is being used. In this example, a LoLin board based on NodeMCU is used. This will vary depending on the development board used. Select the port the ESP8266 is connected to.Common port names are usbserial, usbmodem, COM3, or other names that end with (USB), but will depend on the operating system, drivers, and firmware of the development environment.Connecting via a faulty or weak USB cable is the most common reason for failure to connect. Refer to the official Arduino Help Article for more troubleshooting.After confirming the board is connected, the ESP8266 is ready for development.For this example, a simple App with a single Radio button field will be used.Create a new App with the following field settings.Additional fields will not significantly increase the complexity of this tutorial, and only require the JSON object sent via the ESP8266 be modified accordingly (with some exceptions, such as Attachment fields and Tables.)Create an API Token with View records and Add records permissions.Refer to the Generating API Tokens article on the Kintone Help site for more information on API Tokens.The following information will be used to test the POST request from the ESP8266.The App ID can be found in the URL of the App.For example, if the URL of the App is https://example.kintone.com/k/23/, the App ID is 23.The ESP8266 is a popular choice for low-cost IOT, as it has Wi-Fi capabilities, and is able to connect to and broadcast Wi-Fi networks. The Code in this example has three main goals:This tutorial can be downloaded from the Kintone Workshop repository.In this example the user needs only to edit the code regarding Wi-Fi credentials on lines 8 and 9, before compiling and uploading the code to the ESP8266.After copying and pasting the code example into the Arduino IDE, the validity of the code can be checked via the Verify button.Any errors will be output in the output console in the bottom of the editor.If the code is technically sound, it can then be uploaded to the ESP8266.Ensure that the ESP8266 is still connected via USB, and click on the Upload button in the top menu.Upload progress and any errors can be confirmed in the output console in the bottom tab of the Arduino IDE.Once the code is uploaded, information on how to connect to the ESP8266 will be displayed in the Serial Monitor.The serial monitor is a fundamental concept of micro-controller development. For more information, refer to the Using the Serial Monitor tool article in the Arduino documentation.In this example, the serial monitor is used in the code via Serial.println() statements. Those familiar with web development will find it similar to the JavaScript console.log() function. The Serial Monitor can be displayed in the bottom on the Arduino IDE.Developers may noticed erroneous characters appearing in the Serial Monitor. When starting transmissions, a display of a few garbled characters is common and not a cause for concern. If no characters are displayed in the serial monitor, ensure that the baud rate matches the baud rate specified in the code.The IP address on the local network is displayed in the serial monitor.Ensure that the ESP8266, and the computer that will display the ESP8266 web page are connected to the same Wi-Fi network.Accessing the IP Address of the ESP8266 will lead to the root route being executed in code, and displaying the following HTML:Enter the data specified in this article's Information For Later section, choose a color, and click on the Post to Kintone! button.Check the Kintone App to see if a new record has been successfully posted.Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Emanuel Allely - Sep 28 '22 Ollietex - Aug 24 '22 Emanuel Allely - Sep 26 '22 Abby Nduta - Sep 22 '22 Sign up for a Kintone subdomain and get hacking today. A web database for API calls? A sales management app? What will you make? Once suspended, kintonedevprogram will not be able to comment or publish posts until their suspension is removed. Once unsuspended, kintonedevprogram will be able to comment and publish posts again. Once unpublished, all posts by kintonedevprogram will become hidden and only accessible to themselves. If kintonedevprogram is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to sean-kintone. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag kintonedevprogram: kintonedevprogram consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging kintonedevprogram will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Save Data to Kintone with an ESP8266

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×