Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Photon Internet of things programming starts from scratch

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Christopher Rush

Programming the Photon:Getting Started with the Internet of Things

EISBN:978-0-07-184706-3

Copyright ©2016 by McGraw-Hill Education.

copyright. No part of this publication may be reproduced or disseminated in any way or by any means without the prior written permission of the publisher

Including but not limited to copying, recording, recording, or through any database, information or searchable system.

This authorized translation of simplified Chinese characters is jointly published by McGraw Hill Asia Education Publishing Company and Tsinghua University Press Co., Ltd.

This version is authorized to be sold in Chinese mainland area only and cannot be sold in Hong Kong, Macao Special Administrative region and Taiwan.

The copyright is owned by McGraw Hill Asia Education Publishing Co., Ltd and Tsinghua University Press Co., Ltd.

Copyright contract Registration number of Beijing Municipal copyright Bureau Picture: 01-2018-0333

The cover of this book is affixed with McGraw-Hill Education's anti-counterfeiting label, and those without labels are not allowed to sell it.

Copyright is reserved and infringement must be investigated. Infringement report Tel: 010-62782989 13701121933

Cataloging in publication (CIP) data

Internet of things programming from scratch by Christopher Rush; translated by Guo Junfeng-Beijing:

Tsinghua University Press, original title: Ⅰ ① … Ⅱ ① gram... ② Guo... Ⅲ ① Internet-Application-programming ② Intelligent Technology-Application-Program

Design Ⅳ ① ② Chinese version Library data Core No.

Responsible Editor: Wang Jun and Han Hongzhi

Binding design: Niu Jingmin

Responsible proofreading: Cao Yang

Responsible printing: Li Hongying

Published by Tsinghua University Press

Net address:, address: Beijing Tsinghua University Xueyan Building, Postal Editor: general Manager: Mail purchase: contribution and Reader Service:, quality feedback:, Printer: Beijing Jiashi Printing Co., Ltd.

Sales: national Xinhua Bookstore

Open book: × printed sheet: number of words: thousands of words

Edition times: first edition printing times: year month printing times

Fixed price: yuan

-

Product number: preface to translator

Particle (www.particle.io) provides the most complete open source Internet of things software and hardware in the world.

Component development platform, the company launched its first TI CC3000-based STM since 2013

Since the CORTEX M3 open source development board, Particle has helped development with its strong software support.

Users connect the products to the network and provide Arduino IDE, matching control App and web page editing.

Translation software, application development SDK, JS development library and other support. Its cloud service can be used in mass production.

Particle hardware is connected to the cloud anytime, anywhere, centralized maintenance, and can be updated online.

Components, network access, data security and other functions.

The Photon launched by Particle is a powerful, rich in development resources.

Develop a very easy Wi-Fi Internet of things development module by hand. It is based on ST's Cortex M3.

Kernel microprocessors and BroadCom's Wi-Fi chips can be supplied through USB

Debugging and downloading of electricity and code. Photon is very small in size, but it has powerful processing performance.

With a complete ecosystem and good compatibility, it performs better in complex applications.

Particle also provides browser-based integrated development environment (Web IDE)

It has a very rich library and reference routines that support various applications for the convenience of developers around the world.

Code sharing, very suitable for embedded engineers, web development engineers, Arduino

Enthusiasts and IoT product companies can easily write their own firmware and create their own private network.

Station and mobile phone App.

For beginners, learning Photon does not need to understand its internal hardware structure and sending

Register setting, only know its port function; can not understand hardware knowledge, as long as it can be simplified

C language alone, you can write programs in Photon, as long as the device is powered on, the firmware will

Run.

The book is divided into nine chapters. Chapter 1 provides an overview of microcontrollers, Arduino, and the Internet of things (IoT)

Wait. Chapter 2 discusses several ways to connect the Photon development board to the Particle cloud and start programming

Method and a brief introduction to Particle Web IDE. Chapter 3 describes the use to program Photon

The basic programming terminology of the C language. Chapter 4 discusses how to control light emitting diodes (LED),

Output devices such as relays and buzzer. Chapter 5 programs some input devices, such as switches,

Temperature sensors, etc. Chapter 6 discusses how to use the Particle function to control through Internet.

System, how to get the reading of the temperature device and display it on Web. Chapter 7 introduces Particle defense

Guard plates and available expansion plates show how they can make the project easier to complete without having to design

And test circuit, including relay protection board, voltage stabilizer protection board, JTAG, Arduino protection

Boards, Internet buttons, etc. Chapter 8 describes how to use IFTTT Web services to control Photon

The circuits on the development board, and how to use the Photon development board to control some Web services

For example, Twitter. Chapter 9 allows readers to perform well according to the flicker and color of RGB LED

Understand what happened to Photon, and then master the technology of troubleshooting equipment.

This book is suitable for electronic enthusiasts, robot enthusiasts and Photon beginners.

It is used as a reference book for the practical activities of electronic science and technology in colleges and universities.

Here I would like to thank the editors Li Yang and Han Hongzhi of Tsinghua University Press.

The translation of this book has invested great enthusiasm and a lot of painstaking efforts. Without your help and drums

Li, it is impossible for this book to be published smoothly. The main chapters of this book were translated by Guo Junfeng and participated in the translation.

And Chen Yan, he Meiying, Chen Hongbo, Xiong Xiaolei, Guan Zhaochang, Pan Hongrong, Cao Hanming, Gao

Juanni and Wang Yan would like to express their thanks here.

With regard to this classic, the translator, with the attitude of "trepidation", in the process of translation

Strive to be "faithful, faithful and elegant", but in view of the limited level of translators, mistakes and mistakes are inevitable.

If you have any comments or suggestions, please do not hesitate to correct them.

Translator

A brief introduction to the author

Christopher Rush has a degree in computer science and has been working at a

The veneer computing department of the electronics company acts as the product manager. Christopher also maintains a

MakerSpace blog (www.rushmakes.com) for popular development boards and attachments

Reviews, tutorials, and user guides, including Raspberry Pi, Arduino, BeagleBone

Wait. Christopher is a book of 30 BeagleBone Black Projects for the Evil Genius

The author of.

Thank you

I want to thank the Mike McCabe and McGraw-Hill Education teams for their support.

Yes, it's a pleasure to work with you again.

I would also like to dedicate this book to my partner Jennifer Wozniak, who, as usual, does not

Encourage and inspire me. Without her by my side, I would lose my way.

Foreword

This book provides a comprehensive introduction to how to program a Particle Photon development board. Particle Photon

Is a true Internet of things device that allows you to write code and use the cloud to create electronic projects.

It can be used as the brain of the project, and Internet can be used to remotely control and collect data.

To expand the function.

Fortunately, the Photon platform uses an Arduino-style programming language and has its own

Its own programming function. This makes it possible to use the vast amount of resources in the field of Arduino, including existing

Projects and examples of.

Why use Photon? The Photon development board was developed by the Particle team in November 2014.

The price is only $19 per month. It is unique, using the Particle cloud to provide a unique

The hardware and software experience can be programmed through Web IDE. Photon development board replaces Particle

Core, which raised more than $500,000 through Kickstarter activities, equipped with Broadcom

BCM43362 Wi-Fi chip, not TI CC3000.

The purpose of this book is to enable readers to start creating their own hardware projects using Particle Photon

Readers do not need to have experience in connecting circuits or programming, but it is best to understand general computing

Machine technology. This book will provide readers with a variety of experiences and a brief introduction to the Photon development board

Multi-functional. This book only introduces the basics of development board programming, which readers can use in future projects.

Expand this knowledge.

If you want to see what readers think of this book, please use www.rushmakes.com or

Twitter (https://twitter.com/chrisrush85) contacts the author.

Catalogue

Chapter 1 introduction to Photon. one

1.1 Microcontroller. one

1.2What is Photon. two

1.3 Particle Photon and Spark Core.. two

1.4 Internet of things. three

1.5 Particle Clouds.... four

1.6 Photon board. four

1.7 Summary. five

Chapter 2 connection. seven

2.1 the characteristics of the development board. seven

2.2 Connect. eleven

2.2.1 connect to a mobile smart device.. eleven

2.2.3 Connect via USB. fourteen

2.3Use Tinker.... sixteen

2.3.1 Tinker API... eighteen

2.3.2 run both Tinker and script.. twenty

2.4Use Particle Web IDE... twenty-two

2.4.1 Particle applications and libraries. twenty-four

2.4.2 upload the first application. twenty-four

2.4.3 account information. twenty-six

2.4.4 use the library. twenty-six

Firmware of 2.5 Photon board. thirty-one

2.6 Summary. thirty-one

Chapter 3 Particle syntax. thirty-three

3.1 what is programming? thirty-three

3.2 variables. thirty-five

3.2.1 floating point type. thirty-seven

3.2.2 Boolean type. thirty-eight

3.2.3 character type. forty

3.3 Command. forty

3.3.1 if statement. forty

3.3.2 for cycle... forty-two

3.3.3 while cycle. forty-two

3.4 Array. forty-three

3.5 string. forty-four

3.6 Best programming practices. forty-five

3.6.1 indent. forty-six

3.6.2 comment the code. forty-six

3.6.3 blank. forty-seven

3.7 Summary. forty-eight

Chapter 4 output. forty-nine

4.1 Digital output. forty-nine

4.1.1 turn LED on and off... fifty-three

4.1.2 LCD monitor... fifty-six

4.2 Analog output. sixty-two

4.2.1 Pulse width modulation. sixty-three

4.2.2 DAC. sixty-five

4.2.3 Control servo motor. sixty-seven

4.3 Summary. seventy-one

Chapter 5 input. seventy-three

5.1 Digital input. seventy-three

DigitalRead (). seventy-seven

5.2 Analog input. eighty

5.3 Summary. ninety

Chapter 6 Internet of things. ninety-one

6.1 function. ninety-one

6.1.1 controlling LED through Internet. ninety-two

6.1.2 read values through Internet.. one hundred

6.2 Summary. one hundred and fifteen

Chapter 7 programming of Particle protection board. one hundred and seventeen

7. 1 Shield protection board. one hundred and seventeen

7.2 Relay protection panel. one hundred and twenty

7.3 programmer protection board. one hundred and twenty six

7.4 steady voltage protection plate. one hundred and twenty seven

7.5 Internet button. one hundred and twenty eight

7.6 Grove Starter Kit for Photon.. one hundred and twenty nine

7.7 Adafruit Particle NeoPixel kit.. one hundred and thirty

7.8 Summary. one hundred and thirty two

Chapter 8 IFTTT.... one hundred and thirty three

8.1 Overview of IFTTT. one hundred and thirty three

8.2 Sunrise email alert. one hundred and thirty four

8.3 use the Grove module to create Twitter alerts.. one hundred and forty one

8.4 Summary. one hundred and forty seven

Chapter 9 troubleshooting equipment. one hundred and forty nine

9.1 device mode. one hundred and forty nine

9.2 troubleshooting mode. one hundred and fifty one

Photon Internet of things programming starts from scratch

9.3 Summary. one hundred and fifty two

Appendix A tools and tips. one hundred and fifty three

Appendix B Particle Code reference. one hundred and sixty five

Chapter 1

Introduction to Photon

This chapter will learn about microcontrollers such as Arduino and the Internet of things (Internet of Things,IoT)

The relevant knowledge of, etc. Photon board is a new development board, based on its predecessor Core, and

With new hardware and software features, more excellent performance. We will discuss all of these features

And compare the two kinds of development boards.

1.1 Microcontroller

A microcontroller (microcontroller) is basically a computer that can use some form of

The programming language controls multiple inputs and outputs. Microcontrollers come in a variety of shapes and sizes, the most

The popular platform is Arduino. Arduino boards provide low cost for creating small electronic projects.

Easy to use technology, modern common microcontrollers can use universal serial bus (Universal)

Serial Bus,USB) connect to the computer, power the development board, and program the microcontroller

Once the program is uploaded and powered by some kind of mobile battery device, the microcontroller can also go

Get rid of USB and work independently.

Other common microcontrollers are Raspberry Pi and BeagleBone boards. These two kinds of opening

The hair board is more advanced than the standard Arduino board and is connected to the visual display for visualization.

Transform the output with a basic operating system, such as Debian. The characteristics of these development boards are

Many hardware features that provide more storage space, input / output pins, and faster processing speed

Degree, and also has audio / video output, which can raise electronic projects to a higher level. All these

The options are all good, but when you need to connect the project to the Web, you almost certainly need extra hard

Pieces, such as protective panels (shield) or USB dongles (dongle), which significantly increase the cost of the project

Ben-sometimes exceeds the cost of the microcontroller board. Some development boards also include built-in Wi-Fi

Or Bluetooth technology, such as Arduino Yun, but this development board is still expensive, more than $70

Yuan; once electronic hardware and various other costs are added, the project can easily exceed $100.

1.2 what is Photon

Particle Photon is a microcontroller development board, similar to Arduino Nano, but

It is miniaturized and adds some features, such as a built-in Wi-Fi module, so it can

Use Particle Cloud (Particle cloud) to control and program through Internet. Once connected to

On the local Wi-Fi network, you can also use Particle in the iOS or Android operating system

Application, through the smartphone to control the Photon board and programming. How many are the sides of the Photon development board

A pin is used as the input and output of the microcontroller. These universal pins can be connected to the sensor.

Device (sensor) or button to listen to the outside world; or connect to light emitter (light) or buzzer

(buzzer), perform. There are also some pins for Photon board, motor (motor) or

The output of the equipment is supplied with power. In addition, the Photon board comes with some built-in hardware features, such as

Buttons and light emitting diodes (LED) greatly simplify the configuration of Photon boards:

The ● SETUP button is on the left and the RESET button is on the right. You can use them to set the

The mode of preparation.

● RGB LED is located in the center above the Photon development board module. RGB LED

Specifies the current mode of the Photon development board.

The ● is on the Photon board, and the D7 LED is next to the digital pin 7. When pin 7

When set to HIGH, this number pin opens LED.

1.3 Particle Photon and Spark Core

The Photon board is the successor to Core, and both are developed by Particle. Open these two.

If you compare the hairboards together, you will find that they are very similar in appearance and difficult to distinguish. The main area is the hardware. The Wi-Fi chip used in the Photon board is different from the Core, and the processor speed is different.

Faster, more RAM (random access memory).

The pins on the two development boards are almost the same, so most of the content in this book is also appropriate.

For Core. Several improvements to the Photon board are valuable, such as digital-to-analog converters

(Digital-to-Analog Converter,DAC) and wake-up pin (Wakeup Pin,WKP)

Replaces A6 and A7 on Core.

1.4 Internet of things

The Internet of things is a media term that connects dumb electronic devices to the Internet.

Control these devices through a Web browser, send HTTP requests to the Web server, and

Returns the information to be displayed. Many devices and sensors can be connected to applications:

● household appliances

● weather station

● robot

● air pollution monitoring

● environment sensing

● intelligent logistics

● location tracking

● health monitoring

At present, there are more and more Internet of things devices on the market, such as intelligent thermostat (smart)

Thermostat) or Philips Hue lights (Philips Hue lamp), which allow users to control the home

Heating aspect or mood lighting (mood lighting) in. The great development of the Internet of things has made manufacturers and

Players are more interested in creating their own smart projects, and Photon boards offer this possibility.

And the cost is only $19-the cheapest development board on the market.

With so many vendors and players creating new IoT projects, it is necessary for hardware and

The software creates a simple framework that provides a simple,

Easy-to-use system. So the Particle team built this based on the popular Arduino software.

A system that converts more complex technologies into open source products that are easy to use by every user.

1.5 Particle Cloud

The hardware part of the framework is the Photon board, which is based on the popular Core module.

The financing website Kickstarter gets the money. The Photon board is designed to be backward compatible with Core.

Therefore, most of the content of this book is applicable to Core.

Particle creates a software framework for hardware that allows users to take advantage of other technologies and settings

The device interoperates with the hardware through Internet, and the two elements are easy to work together. Use

The IoT device on the Photon board turns on the consumer device using a relay (relay) or similar circuit; this

When a user visits a web page or mobile application, the setting is turned on or off through a button on it

Ready. When a user clicks a button on a web page, a message or string of data is sent to

Particle cloud service, Particle cloud service, then forward the message to the Photon board and open it.

Ready. If the Photon board is connected to the sensor, the cloud system can work in the opposite order, that is, point

When the button is clicked, it is not the Web service that sends the message to the cloud, but the Photon development board that sends the message.

The information of the sensor is sent to the cloud and then to the Web server, which is displayed on the Web. The whole

The Particle framework makes this work seamless and not too complex for end users

-- users only need to register the Particle Photon board with their Particle cloud account.

1.6 Photon board

The Photon board is small and delicate, as shown in figure 1-1.

The two buttons on the Photon board, SETUP and RESET, configure Wi-Fi credentials in the

Restart the device if needed. In case there is something wrong with the equipment, use them together to perform a complete output

Factory reset operation.

There is a miniature USB port at the top of the development board, which is used to power the development board and, when needed,

Can be connected to the computer for USB programming.

The Photon board has a built-in chip antenna (chip antenna), which is suitable for most rooms.

For applications, the Photon board also has an external slot for connecting Wi-Fi antennas for range expansion.

Spread and directional antennas. The default configuration of Photon board is: it can be used in both chip antenna and external antenna.

Always choose the most reliable method in the case of using. The antenna can also be selected manually on the firmware.

Figure 1-1 Photon board

1.7 Summary

Now we have set sail. The Photon board is a way to create IoT items in the vendor community

Aim and develop excellent equipment for commercial consumer products. The next chapter describes how to set up the Photon board

Start writing the first project.

Purchase address:

Http://product.dangdang.com/25321993.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 298

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report