Powered by Blogger.

Sunday, December 4, 2016

Tag: ,

Lesson 14: Playground-ESP8266 Blocks

Screenshot_12_thumb5

ESP blocks set can be used with any ESP8266 based device including MagicWiFi. Following blocks are available,
  • Digital in
  • Analog In
  • Digital Out
  • PWM (Analog Out)
  • Servo
  • Serial In
  • Serial Out
  • Camera
  • NFC in

This block set enables you to control individual pins of the device from the playground. The functionality of each block is described below:


How to attach a device

Every block has a property called Device ID where you need to specify to which device this block belongs to. This is important because you will be working with multiple devices in a typical IoT project. To control a device (eg: MagicWiFi) via the playground you need to add the device as in Lesson 3 and if you have already done so, attach it to the playground according to the description below.

To attach a device ID for the first time, select 'Add new esp' and click the edit button as shown below. If you have already added the device as in Lesson 3, it will be visible to you in the dropdown and you can select the device from there.

Screenshot_7_thumb2


In the next dialog click the search button which will display all your added devices. Select the device you want to add and click 'Add'. Once you have added a device you can select it from the dropdown in the respective node.

Screenshot_2_thumb4
Screenshot_1_thumb3


Except serial blocks every other block have property called Pin which will identify specific pin of the module.
Note:
  • Pin 2 connected to the LED on ESP module
  • Pin 6-11 not available for the user

1. Digital In

 
FotorCreated_thumb4
 
 
This block will read Input status of a pin. Block need to triggered to get input status. Any input will serve as a trigger. Inject node can be used for this purpose.Input status can be passed to a another block or viewed on the debug window.


  • Configuration:
    • Pin: pin number of the digital pin to read (Required)
    • Name: Any name desired
  • Input
    • Any input. Used as a trigger
  • Output
    • Value of the pin as 1 or 0 in the following format and the pin number as the topic
      • eg: {"payload": 1 , "topic": "2"}
[{"id":"bc9d8815.652678","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"","payloadType":"none","repeat":"1","crontab":"","once":false,"x":110,"y":100,"wires":[["a579225b.cb11d"]]},{"id":"a579225b.cb11d","type":"ESP Digital In","z":"6e9053f8.02fcdc","name":"","pin":"2","esp":"7708a34e.0e41dc","x":260,"y":100,"wires":[[]]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

2. Digital Out

 
 
FotorCreated2_thumb1

 
This block is used to set a digital output pin to 1 or 0 based on the input. An input of 1 or true will make the configured pin go HIGH and vice versa
  • Configuration
    • Pin: pin number of the Digital pin to write to
    • Name: Any name desired
  • Input
    • Value to be written to the pin. Accepts 1 (true) or 0 (false)
      • eg: {"payload": 1}
[{"id":"bc9d8815.652678","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"1","payloadType":"string","repeat":"1","crontab":"","once":false,"x":90,"y":60,"wires":[["22cd7e7b.05c302"]]},{"id":"22cd7e7b.05c302","type":"ESP Digital Out","z":"6e9053f8.02fcdc","name":"","pin":"2","esp":"7708a34e.0e41dc","x":280,"y":100,"wires":[]},{"id":"a0b73ca.fe2c3c","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"0","payloadType":"string","repeat":"1","crontab":"","once":false,"x":90,"y":140,"wires":[["22cd7e7b.05c302"]]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

3. Analog In

Screenshot_10_thumb2
 
This block will read analog value of the ADC pin of the module. Similar to the digital in block you need to trigger the block to read the value. Any input sent to the block will serve as the trigger.


  • Configuration:
    • Pin: pin number of the analog pin to read (Required)
    • Name: Any name desired
  • Input
    • Any input. Used as a trigger
  • Output
    • Value of the pin from 0 to 1024 and the pin number as the topic with prefix A
      • eg: {"payload": 965, "topic":"A0"}
Notes
  • Only one analog pin available hence pin should be 0 always
  • Input voltage range 0-1 V
  • ADC value range 0-1024
[{"id":"bc9d8815.652678","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"1","payloadType":"none","repeat":"1","crontab":"","once":false,"x":110,"y":60,"wires":[["a3589573.daf568"]]},{"id":"a3589573.daf568","type":"ESP Analog In","z":"6e9053f8.02fcdc","name":"","pin":"0","esp":"7708a34e.0e41dc","x":260,"y":60,"wires":[[]]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

4. PWM (Analog Write)

 

Screenshot_11_thumb2
 
This block outputs PWM signal from the selected pin


  • Configuration:
    • Pin: pin number for the PWM signal (Required)
    • Name: Any name desired
  • Input
    • value from 0 to 100
      • eg: {"payload": 55}
[{"id":"bc9d8815.652678","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"150","payloadType":"string","repeat":"1","crontab":"","once":false,"x":110,"y":60,"wires":[["ff79f939.d135f8"]]},{"id":"ff79f939.d135f8","type":"ESP PWM","z":"6e9053f8.02fcdc","name":"","pin":"2","esp":"7708a34e.0e41dc","x":250,"y":60,"wires":[]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

5. Servo



Screenshot_14_thumb2

This block can be used to control a servo motor with the MagicWiFi module.

  • Configuration:
    • Pin: pin number to which servo motor is attached (Required)
    • Name: Any name desired
  • Input
    • value from 0 to 180 translating from 0 degrees to 180 degrees for servo motor shaft rotation.
      • eg: {"payload" : 120}
[{"id":"bc9d8815.652678","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"0","payloadType":"string","repeat":"1","crontab":"","once":false,"x":110,"y":60,"wires":[["6a6915e5.3af26c"]]},{"id":"6a6915e5.3af26c","type":"ESP Servo","z":"6e9053f8.02fcdc","name":"","pin":"2","esp":"7708a34e.0e41dc","x":260,"y":100,"wires":[]},{"id":"66a4a64a.c67e88","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"90","payloadType":"string","repeat":"1","crontab":"","once":false,"x":110,"y":140,"wires":[["6a6915e5.3af26c"]]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]
6. Serial In
Screenshot_15_thumb2

The Serial In block will output anything written to the RX0 of the MagicWiFi module at 115200 baud. You do not need to trigger the module as the data will be delivered in real time.



  • Configuration:
    • Name: Any name desired
  • Output
    • data read from the serial RX0 pin of the MagicWiFi module and the topic as 0x63 to indicate a serial read
      • eg: {"payload": "Your Serial Data Buffer","topic": 0x63}
[{"id":"aae18e9e.75388","type":"ESP Serial In","z":"6e9053f8.02fcdc","esp":"7708a34e.0e41dc","x":120,"y":180,"wires":[["8ae2f692.93e198"]]},{"id":"8ae2f692.93e198","type":"debug","z":"6e9053f8.02fcdc","name":"","active":true,"console":"false","complete":"false","x":300,"y":180,"wires":[]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

7. Serial Out


Screenshot_16_thumb2

The serial out block will write anything you send to the TX0 of the MagicWiFi module at 115200 baud.
  • Configuration:
    • Name: Any name desired
  • Input
    • data to be written to the serial pin
      • eg:
        • To write a string ==> {"payload": "Your Serial Data to be sent"}
        • To write a byte buffer ==> {"payload": buffername}
[{"id":"be082443.01c698","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"Hello","payloadType":"string","repeat":"","crontab":"","once":false,"x":130,"y":160,"wires":[["b48ac6fe.002a18"]]},{"id":"b48ac6fe.002a18","type":"ESP Serial Out","z":"6e9053f8.02fcdc","x":320,"y":160,"wires":[]}]

8. NFC In



Screenshot_17_thumb2


The NFC In block will display the UID of an NFC card when tapped. To use this module you have to connect the MagicWiFi to a PN532 based NFC reader. The PN532 reader should be configured to communicate via Serial at 115200 baud and connected to the RX0 & TX0 of the MagicWiFi module (TX0 of MagicWiFi to RX0 of PN532 and RX0 of MagicWiFi to TX0 of PN532) and supplied 3.3V power

After connecting properly and powering up a NFC card tap on the PN532 module will be read and the data will be available in real time at the output of this block.

Note: You cannot use the Serial In block while using the NFC In block


  • Configuration:
    • Name: Any name desired
  • Output
    • UID of the NFC card tapped
      • eg: {"payload": [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07],"topic": 0x71}
[{"id":"b117fca3.9792d","type":"ESP NFC In","z":"6e9053f8.02fcdc","esp":"7708a34e.0e41dc","x":220,"y":160,"wires":[["bdafd474.db50d8"]]},{"id":"bdafd474.db50d8","type":"debug","z":"6e9053f8.02fcdc","name":"","active":true,"console":"false","complete":"false","x":390,"y":160,"wires":[]},{"id":"7708a34e.0e41dc","type":"esp","z":"6e9053f8.02fcdc","device":"id14-1475889500675"}]

9. Camera In



Screenshot_19_thumb2

The Camera In block will function when the MagicWiFi is connected to a Serial Camera based on VIMICRO VC0706. On a trigger input it will capture an image and the byte buffer of the JPEG image captured will be available on the output.

You need to connect the VIMICRO VC0706 serial camera to the MagicWiFi ((TX0 of MagicWiFi to RX0 of camera and RX0 of MagicWiFi to TX0 of camera) and supply 5V power.




  • Configuration:
    • Name: Any name desired
  • Input

    • Any value as trigger
    [{"id":"bdafd474.db50d8","type":"debug","z":"6e9053f8.02fcdc","name":"","active":true,"console":"false","complete":"false","x":350,"y":220,"wires":[]},{"id":"dff2b2af.1d8c9","type":"ESP Camera","z":"6e9053f8.02fcdc","name":"","x":200,"y":160,"wires":[["bdafd474.db50d8"]]},{"id":"195c3991.463216","type":"inject","z":"6e9053f8.02fcdc","name":"","topic":"","payload":"","payloadType":"none","repeat":"5","crontab":"","once":false,"x":90,"y":120,"wires":[["dff2b2af.1d8c9"]]}]