当前位置: 首页 > 编程日记 > 正文

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

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

相关文章:

洛谷p1162填涂颜色(dfs写法)

这道题本是放在试炼场bfs里的,但是我觉得dfs好写些 所以就用dfs过了 题目如下 题目描述 由数字0 组成的方阵中,有一任意形状闭合圈,闭合圈由数字1构成,围圈时只走上下左右4个方向。现要求把闭合圈内的所有空间都填写成2.例如&…

Microsoft .NET Framework 4.6.1

适用于操作系统平台:Windows 7 SP1、Windows 8、Windows 8.1、Windows 10、Windows Server 2008 R2 SP1、Windows Server 2012 和 Windows Server 2012 R2 .NET Framework 4.6.1 官方更新介绍页面 http://msdn.microsoft.com/en-us/library/ms171868%28vvs.110%29.a…

VUE还没生效,页面闪屏的问题解决办法 v-cloak

当网络较慢&#xff0c;网页还在加载 Vue.js &#xff0c;而导致 Vue 来不及渲染&#xff0c;这时页面就会显示出 Vue 源代码。我们可以使用 v-cloak 指令来解决这一问题。 html&#xff1a; <div id"app">{{context}} </div>js&#xff1a; <script…

如何使用Python创建,读取,更新和搜索Excel文件

This article will show in detail how to work with Excel files and how to modify specific data with Python.本文将详细显示如何使用Excel文件以及如何使用Python修改特定数据。 First we will learn how to work with CSV files by reading, writing and updating them.…

字符串基本操作

1.已知‘星期一星期二星期三星期四星期五星期六星期日 ’&#xff0c;输入数字&#xff08;1-7&#xff09;&#xff0c;输出相应的‘星期几’ s"星期一星期二星期三星期四星期五星期六星期日" iint(eval(input("请输入1-7的数字:"))) print(s[3*(i-1):3*i…

IOS长按识别二维码失败

IOS长按不识别二维码&#xff0c;出现放大图片的问题解决。 CSS加入样式&#xff1a; touch-callout: none; -webkit-touch-callout: none; -ms-touch-callout: none; -moz-touch-callout: none; 代码&#xff1a; <!DOCTYPE html> <html><head><s…

从svn下载的Mavn项目,到本地后不识别(MyEcplise)

从svn上面现在的mavn的项目到本地不识别的原因 1.首先要确认本机的mavn的环境是否正确。 2.查看本机的Myecplise的mavn的环境配置是否正确 3.在cmd当中执行命令 mvn -Dwtpversion1.0 eclipse:myeclipse &#xff0c;可能svn上面的文件是eclipse建立的&#xff0c;需要进行转化。…

python导入外部包_您会喜欢的10个外部Python软件包

python导入外部包by Adam Goldschmidt亚当戈德施密特(Adam Goldschmidt) 您会喜欢的10个外部Python软件包 (10 External Python packages you are going to love) Python is an experiment in how much freedom programmers need. Too much freedom and nobody can read anoth…

【转修正】sql server行版本控制的隔离级别

在SQL Server标准的已提交读&#xff08;READ COMMITTED&#xff09;隔离级别下&#xff0c;一个读操作会和一个写操作相互阻塞。未提交读&#xff08;READ UNCOMMITTED&#xff09;虽然不会有这种阻塞&#xff0c;但是读操作可能会读到脏数据&#xff0c;这是大部分用户不能接…

【机器学习基石笔记】八、噪声和错误

噪声的来源&#xff1a; 1、noise in y 2、noise in x 在有noise的情况下&#xff0c;vc bound还会work么&#xff1f;&#xff1f;&#xff1f; 之前&#xff0c;x ~ p(x) 现在 y ~ P( y | x ) 在hoeffding的部分&#xff0c;只要 (x, y) 联合分布满足某个分布&#xff0c; 结…

H5用户地址位置选择地点获取经纬度(效果图)

效果图&#xff1a; uni-app <template><view class"flex-v flex-c wrap"><web-view src"https://apis.map.qq.com/tools/locpicker?search1&type1&key7QKBZ-SJ2HF-7TFJS-JL5NE-E6ZD7-SWFW5&referer鏅鸿兘鍚嶇墖"></we…

学习sql注入:猜测数据库_对于SQL的热爱:为什么要学习它以及它将如何帮助您...

学习sql注入:猜测数据库I recently read a great article by the esteemed craigkerstiens describing why he feels SQL is such a valuable skill for developers. This topic really resonated with me. It lined up well with notes I’d already started sketching out fo…

C++入门经典-例6.14-通过指针连接两个字符数组

1&#xff1a;字符数组是一个一维数组&#xff0c;引用字符数组的指针为字符指针&#xff0c;字符指针就是指向字符型内存空间的指针变量。 char *p; char *string"www.mingri.book"; 2&#xff1a;实例&#xff0c;通过指针连接两个字符数组&#xff0c;代码如下&am…

创建一个没有边框的并添加自定义文字的UISegmentedControl

//个性推荐 歌单 主播电台 排行榜NSArray* promoteArray["个性推荐","歌单","主播电台","排行榜"];UISegmentedControl* promoteSgement[[UISegmentedControl alloc]initWithItems:promoteArray];promoteSgement.frameCGRectMake(0, 6…

样式集(一) 通用商品列表样式

上图&#xff1a; 上代码&#xff1a; // pages/choosePackage/choosePackage.js Page({data: {list:[1,2,3],},onLoad: function (options) {},nav_upInfo(){wx.navigateTo({url: ../upInfo/upInfo,})}, }) <!--pages/choosePackage/choosePackage.wxml--> <view c…

2019 6月编程语言_今年六月您可以开始学习650项免费的在线编程和计算机科学课程...

2019 6月编程语言Seven years ago, universities like MIT and Stanford first opened up free online courses to the public. Today, more than 900 schools around the world have created thousands of free online courses, popularly known as Massive Open Online Cours…

mybatis分页练手

最近碰到个需求&#xff0c;要做个透明的mybatis分页功能&#xff0c;描述如下&#xff1a;目标&#xff1a;搜索列表的Controller action要和原先保持一样&#xff0c;并且返回的json需要有分页信息&#xff0c;如&#xff1a; ResponseBody RequestMapping(value"/searc…

样式集(二) 信息填写样式模板

上图&#xff1a; 代码&#xff1a; // pages/upInfo/upInfo.js Page({data: {tipsTxt: "请填写正确的业务流水号",showTips: false,showCityList:false,city:"",cityList:["济南市","青岛市","枣庄市","东营市"…

12小时进制的时间输出的编辑代码

关于时间输出的编辑代码个人思考了很久&#xff0c;包括顺序&#xff0c;进位之类的&#xff0c;求完善和纠错 public class yunsuanfu {public static void main(String[] arg){double t2;int h38;int m100;int s100;if(s>60){m(s/60)m;ss%60;}if (m>60){h(m/60)h;mm%6…

c++每调用一次函数+1_每个开发人员都应该知道的一些很棒的现代C ++功能

c每调用一次函数1As a language, C has evolved a lot.作为一种语言&#xff0c;C 已经发展了很多。 Of course this did not happen overnight. There was a time when C lacked dynamism. It was difficult to be fond of the language.当然&#xff0c;这并非一overnight而…

Linux ISCSI配置

一、简介 iSCSI&#xff08;internet SCSI&#xff09;技术由IBM公司研究开发&#xff0c;是一个供硬件设备使用的、可以在IP协议的上层运行的SCSI指令集&#xff0c;这种指令集合可以实现在IP网络上运行SCSI协议&#xff0c;使其能够在诸如高速千兆以太网上进行路由选择。iSCS…

样式集(三)成功页面样式模板

上图&#xff1a; 代码&#xff1a; <!--pages/result/result.wxml--> <view><image class"scc" src"/img/scc.png"></image><view class"resuil">办理成功</view> </view> <view class"btn…

C#中Request.servervariables参数

整理一下&#xff0c;我在asp.net下遍历的Request.servervariables这上集合&#xff0c;得出的所有参数如下&#xff1a; &#xff1a; Request.ServerVariables["ALL_HTTP"] 客户端发送的http所有报头信息 返回例&#xff1a;HTTP_CACHE_CONTROL:max-age0 HTT…

打开浏览器的包 node_如何发布可在浏览器和Node中使用的软件包

打开浏览器的包 nodeWhen you create a package for others to use, you have to consider where your user will use your package. Will they use it in a browser-based environment (or frontend JavaScript)? Will they use it in Node (or backend JavaScript)? Or bot…

存储过程中SELECT与SET对变量赋值

Create proc insert_bookparam1char(10),param2varchar(20),param3money,param4moneyoutputwith encryption---------加密asinsert into book(编号,书名,价格)Values(param1,param2,param3)select param4sum(价格) from bookgo执行例子&#xff1a;declare total_price moneyex…

AngularJs $resource 高大上的数据交互

$resource 创建一个resource对象的工厂函数&#xff0c;可以让你安全的和RESFUL服务端进行数据交互。 需要注入 ngResource 模块。angular-resource[.min].js 默认情况下&#xff0c;末尾斜杠&#xff08;可以引起后端服务器不期望出现的行为&#xff09;将从计算后的URL中剥离…

样式集(四)搜索框样式

上图&#xff1a; 代码&#xff1a; // pages/search/search.js var textPage({data: {input_val:"",list:[]},input_p(e){this.setData({input_val:e.detail.value})},onLoad: function (options) {}, }) <view classpage_row bindtap"suo"><vi…

初步了解React Native的新组件库firstBorn

first-born is a React Native UI Component Framework, which follows the design methodology Atomic Design by Brad Frost.first-born是React Native UI组件框架&#xff0c;它遵循Brad Frost的设计方法Atomic Design 。 Version 1.0.0 was recently published as an npm …

less里面calc() 语法

转载 Less的好处不用说大家都知道&#xff0c;确实让写CSS的人不在痛苦了&#xff0c;最近我在Less里加入calc时确发现了有点问题&#xff0c;我在Less中这么写&#xff1a;  div {  width : calc(100% - 30px);  }  结果Less把这个当成运算式去执行了&#xff0c;结果…

基于XMPP的IOS聊天客户端程序(XMPP服务器架构)

最近看了关于XMPP的框架&#xff0c;以文本聊天为例&#xff0c;需要发送的消息为&#xff1a; <message type"chat" from"kangserver.com" to"testserver.com"> <body>helloWord</body> </message> …