devkit

by Jibin Thomas

吉宾·托马斯(Jibin Thomas)

如何使用NodeMCU Devkit和Firebase数据库开始物联网 (How to get started with IoT using NodeMCU Devkit and Firebase database)

“The Internet will disappear. There will be so many IP addresses, so many devices, sensors, things that you are wearing, things that you are interacting with, that you won’t even sense it. It will be part of your presence all the time. Imagine you walk into a room, and the room is dynamic. And with your permission and all of that, you are interacting with the things going on in the room.”

“互联网将会消失。 将会有太多的IP地址,那么多的设备,传感器,您所穿的东西,与之交互的东西,甚至您都不会感觉到。 它将一直是您在场的一部分。 想象一下,走进一个房间,房间是动态的。 在您的允许下,您正在与房间中发生的事情进行互动。”

Nowadays many devices that we use day to day are connected to the internet like Television, smart speakers, refrigerators, etc. These devices extend their primary functions which allows them to interact with other devices on the internet and to be controlled remotely.

如今,我们日常使用的许多设备都已连接到Internet,例如电视,智能扬声器,冰箱等。这些设备扩展了其主要功能,从而使它们可以与Internet上的其他设备进行交互并受到远程控制。

You can build your own IoT devices using some sensors and microcontrollers. There are many development boards that will help you get started with IoT like Arduino, NodeMCU, Raspberry Pi, etc. You can automate your home by building from these devices.

您可以使用一些传感器和微控制器来构建自己的物联网设备。 有许多开发板可以帮助您开始使用IoT,例如Arduino,NodeMCU,Raspberry Pi等。您可以通过使用这些设备进行构建来使您的房屋自动化。

In this post, we will be using NodeMCU devkit and Firebase for turning on and off LED remotely. NodeMCU devkit and Firebase are the best combinations to get started with building some IoT projects. NodeMCU is cheap and has built-in wifi for internet connectivity, and the Firebase free plan is more than enough.

在本文中,我们将使用NodeMCU devkit和Firebase远程打开和关闭LED。 NodeMCU devkit和Firebase是开始构建某些IoT项目的最佳组合。 NodeMCU价格便宜,并且具有内置的wifi以实现Internet连接,而Firebase的免费计划绰绰有余。

搭建开发环境 (Setting up Development Environment)

1. We will be using Arduino IDE for writing code and we will flash the code to the device. Download the latest version of the IDE here.

1.我们将使用Arduino IDE编写代码,并将代码闪存到设备中。 在此处下载最新版本的IDE。

2. Since we are using NodeMCU which is not officially supported by Arduino IDE, we have to add the JSON file of the device. In Arduino IDE add this URL in

2.由于我们使用的是Arduino IDE官方不支持的NodeMCU,因此我们必须添加设备的JSON文件。 在Arduino IDE中将此网址添加到

Open File > Preferences > Additional Board Manager URLs

打开文件>首选项>其他Board Manager URL

http://arduino.esp8266.com/stable/package_esp8266com_index.json

http://arduino.esp8266.com/stable/package_esp8266com_index.json

3. Select your Board from

3.从中选择您的董事会

Tools > Board > NodeMCU 1.o

工具>板> NodeMCU 1.o

4. To use firebase database in NodeMCU you need to download the firebase-arduino library which abstracts the REST API of the firebase. Download firebase-arduino here.

4.要在NodeMCU中使用firebase数据库,您需要下载firebase-arduino库,该库抽象了firebase的REST API。 在此处下载firebase-arduino 。

5. Include the downloaded zip file on Arduino IDE.

5.将下载的zip文件包含在Arduino IDE中。

Sketch > Include library > Add .zip > Select zip file

草图>包含库>添加.zip>选择zip文件

6. You also need to install the ArduinoJson library which can be downloaded from Arduino IDE itself.

6.您还需要安装ArduinoJson库,该库可以从Arduino IDE本身下载。

Note: The library version should not be 6.x.x — use the latest 5.x.x

注意:库版本不应为6.xx-使用最新的5.xx

Sketch > Include library > Manage Libraries > Search for ArduinoJson by Benoit Blanchon

草图>包含库>管理库> Benoit Blanchon搜索ArduinoJson

设置Firebase数据库 (Setting up Firebase Database)

7. Create a new firebase project from the console and head towards the database section. Select the firebase real-time database.

7.从控制台创建一个新的firebase项目,然后转到“数据库”部分。 选择Firebase实时数据库。

8. Copy the database secret for authentication from Settings Panel > Service accounts.

8.从设置面板>服务帐户复制数据库密码以进行身份​​验证。

9. Add a led node to the firebase database. This value will decide whether to turn on or off the LED.

9.将一个led节点添加到firebase数据库。 该值将决定是打开还是关闭LED。

配置Arduino IDE和Firebase数据库以协同工作 (Configuring Arduino IDE and firebase database to work together)

Now that all the setup procedures are done let’s start coding.

现在,所有设置过程都已完成,让我们开始编码。

You need to create a macro for your database URL and firebase secret which you had copied in Step 8.

您需要为在步骤8中复制的数据库URL和Firebase机密创建一个宏。

#define FIREBASE_HOST “yourfirebasedatabase.firebaseio.com”

#define FIREBASE_HOST“ yourfirebasedatabase.firebaseio.com”

#define FIREBASE_AUTH “*****”

#define FIREBASE_AUTH“ *****”

For simplicity, we will write a simple code for turning on and off LED remotely

为简单起见,我们将编写一个简单的代码以远程打开和关闭LED

10. The positive of the LED should be connected to the D1 pin and negative pin to the ground pin of NodeMCU.

10. LED的正极应连接到D1引脚,负极应连接到NodeMCU的接地引脚。

11. Upload your code from Arduino IDE.

11.从Arduino IDE上传您的代码。

Sketch > Upload

草图>上传

12. Now try changing the database value to true and false. The led should now start turn on and off. Additionally, you can extend this project by creating a web app that will toggle the LED instead of manually changing the value in the database.

12.现在尝试将数据库值更改为true和false。 LED现在应该开始打开和关闭。 此外,您可以通过创建一个Web应用程序扩展该项目,该应用程序将切换LED,而不是手动更改数据库中的值。

So now that you understand the basics of how to go about connecting NodeMCU to the internet and controlling it remotely, start hacking some new projects with it.

因此,现在您了解了如何将NodeMCU连接到互联网并进行远程控制的基础知识,开始使用它来入侵一些新项目。

翻译自: https://www.freecodecamp.org/news/how-to-get-started-with-iot-using-nodemcu-devkit-and-firebase-database-d43e8a408a88/

devkit

devkit_如何使用NodeMCU Devkit和Firebase数据库开始物联网相关推荐

  1. 孤荷凌寒自学python第五十四天使用python来删除Firebase数据库中的文档

    孤荷凌寒自学python第五十四天使用python来删除Firebase数据库中的文档 (完整学习过程屏幕记录视频地址在文末) 今天继续研究Firebase数据库,利用google免费提供的这个数据库 ...

  2. 如何使用async / await和Firebase数据库编写漂亮的Node.js API

    by Paul Breslin 保罗·布雷斯林(Pau​​l Breslin) 如何使用async / await和Firebase数据库编写漂亮的Node.js API (How to write ...

  3. Flutter进阶—Firebase数据库实例

    如果需要使用Firebase实时数据库.首先我们需要为项目配置Firebase,具体配置方法可以在<Flutter实战一Flutter聊天应用(五)>查看,因为我们只需要使用Firebas ...

  4. 超过10%的 Firebase 数据库易受攻击并暴露数据

     聚焦源代码安全,网罗国内外最新资讯! 编译:代码卫士 尽管多年来一直在警告称不要在未认证的情况下使重要的数据库暴露在网上,但似乎很多 Firebase 管理人员未能理解这些实践的危险性.只需通过一些 ...

  5. NodeMCU 通过MQTT 连接阿里云物联网

    NodeMCU 通过MQTT 连接阿里云物联网 前言: 这是第一个帖子,希望以后所有的东西都能记录在CSDN吧!自己在调试过程中也借鉴了很多人的帖子,这里总结出来,方便以后查阅,也方便他人! 1.No ...

  6. android数据库查找一个字符,Android - 如何在Firebase数据库中对字符串进行简单搜索?_android_开发99编程知识库...

    这个问题可能很旧,但是,有一种文档化方式,如何实现这种方式,很简单,引用 : 要启用云Firestore数据的全文搜索,请使用第三方搜索服务(如Algolia ,考虑一个笔记记录应用程序,其中每个笔记 ...

  7. Esp8266 nodemcu 使用PubSubClient连接阿里云物联网平台

    之前写了一篇微信小程序使用MQTT.js连接阿里云IoT物联网平台,然后很多人问问题的时候顺带会问些硬件的问题,但是自己不会,没法回答.最近有些空闲的时间,自己也挺感兴趣,于是花了一个星期左右的时间看 ...

  8. 基于图数据库的物联网模型(1)-图数据库与模型设计

    物联网的图模型 所谓"物联网"是指规模巨大的设备,传感器将实现联网,通过这些联网设备来收集数据,存储和分析,并且和人员,应用软件产生的数据相互关联,实现处理复杂的事件的最优化.基于 ...

  9. android保持数据库,android – 保持Firebase实时数据库中的数据始终保持同步

    我正在重新使用我的应用程序,它通过从网站获取原始数据来更新它的内部SQLite数据库,而不是官方API. 由于这非常容易出错,我想将数据处理从客户端移到后端服务器中. 我们的想法是每天多次在服务器上运 ...

最新文章

  1. 关于Github(1)
  2. SAP LSMW 导入Open PO单据,系统报错 --- GL account 670100 cannot be used ---
  3. 对我影响最大的3位老师
  4. 深入探究VC —— 编译器cl.exe(1)
  5. python9_Python9-前端基础知识-day47
  6. 前端每日实战:91# 视频演示如何用纯 CSS 创作一个行驶中的火车 loader
  7. p4n 今天与朋友沟通支付云服务普及以及跨境电子商务的光辉前景
  8. editplus 打开大文件_CorelDRAW文件损坏的几种解决方法
  9. 解决print spooler打印服务自动停止的过程记录
  10. 433MHz资讯一点通
  11. 家庭用计算机选购调查报告,【调查报告】计算机选购调查报告.doc
  12. 草稿cfmm~yuyu 22.9.26 Linux
  13. 纬度渐长率算法C语言,关于纬度渐长率.pdf
  14. java servlet验证码_Servlet 实现验证码
  15. 新入职如何快速的熟悉项目
  16. 转:oracle ocp 指南
  17. 7.6 Python 实例12-政府工作报告词云
  18. 使用obs时显示已从服务器,小鹅通OBS
  19. oracle 分组 排名,Oracle数据库之分组查询及排序
  20. [C#] 控制电脑蓝牙与外部蓝牙设备通信

热门文章

  1. oracle 与 client端执行结果不一致_不同模式下Spark应用的执行过程
  2. React 父组件给子组件传值,子组件接收
  3. XDOC Office Server 开源了,Office文档完美转换为PDF
  4. cnblogs不愧为cnblogs
  5. Python3 与 C# 并发编程之~ Net篇
  6. Markdown快速上手
  7. 《Java核心技术 卷Ⅱ 高级特性(原书第10版)》一3.7.5 使用StAX写出XML文档
  8. 你不知道的对称密钥与非对称密钥
  9. HTML中的form表单有一个关键属性 enctype
  10. oracle 导入数据