Once the wireless network is set up, you can find that the original flashing blue light will turn into a breathing light, indicating that the Particle Cloud has been successfully connected.

Step 8: List the current Particle device. The following icon shows the Jarvis-NAS-Photon that has just been set. The 2d0xxxxxxxxxxx037 is the device id. It can be recorded first and will be used later.

$particle list

After setting up the Particle device and NAS, start the serial device and Node-Red.

First, log in to Particle Build, there are two things to do here:

Put in the test source code, test event, function and variable.

Obtain an access token that accesses the relevant API permissions, and then use it in Node-Red.

Let’s first put the original code of the test below into the Photon just set up. The function is mainly to send the LED status through the event, to obtain the control LED status through the function and the current LED status.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

IntledStatus=0;

IntledPin=D7;

// LED function

IntgetLedStatus(Stringcmd);

IntsetLedStatus(Stringcmd);

Voidsetup(){

pinMode(ledPin,OUTPUT);

// Set a variable let user can get LED status.

Particle.variable("ledstatus",ledStatus);

// Set function let user can call it.

Particle.function("getLedStatus",getLedStatus);

Particle.function("setLedStatus",setLedStatus);

}

Voidloop(){

ledStatus=digitalRead(ledPin);

// Publish event to Particle cloud.

Particle.publish("ledstatus",String(ledStatus));

Delay(5000);

}

IntgetLedStatus(Stringcmd){

ledStatus=digitalRead(ledPin);

ReturnledStatus;

}

IntsetLedStatus(Stringcmd){

If(cmd=="true"){

digitalWrite(ledPin,HIGH);

}else{

digitalWrite(ledPin,LOW);

}

}

After attaching the code, you can perform the burning action, as following:

By the way, during the burning process, the LED status of the device will be bright yellow and blue, then flash and connect, and finally converted into a breathing light, indicating successful burning.

Now that the settings on the device have been completed, the next step is to get the access token to access the relevant API permissions, and then use it in Node-Red, as following:

After getting the access token, put this token into the Particle node provided by Node-Red.

First create a new Particle Cloud config, then fill in the relevant information, for example: Name, Device ID, Event

After the completion, as following, fill in the Event name “ledstatus” just set up, and then connect the output node to the Particle node.

The result of the output event….

In addition to obtaining device-related information through web pages, Particle can also obtain status information of current devices through REST API.