iot:tutorial:aws-integration
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
iot:tutorial:aws-integration [2020/06/12 12:25] – 1 atolstov | iot:tutorial:aws-integration [2020/07/06 11:48] – atolstov | ||
---|---|---|---|
Line 232: | Line 232: | ||
{{ iot: | {{ iot: | ||
- | For know, it is WebHMI can post the data from real devices to various | + | For know, it is WebHMI can post the data from real devices to AWS MQTT Client, which allow update to various AWS Thing' |
Line 268: | Line 268: | ||
===== Testing and Next Steps ===== | ===== Testing and Next Steps ===== | ||
+ | ==== Testing ==== | ||
- | Test WebHMI can post to AWS shadow, | + | Okay, so now it is working AWS MQTT communication and tested successfully. |
- | create Actions, apply pols, | + | The next step is to reconfigure MQTT topics from '' |
- | check the DynamoDB update, check Kibana metric created. | + | {{ : |
+ | There is a trigger to run script, by the register' | ||
+ | {{ : | ||
+ | This settings will lead the message to AWS IoT Core Rules processing, and in the end hitting to DynamoDB table. | ||
- | Work with Kibana | + | ==== Setting up trigger script |
+ | There should be a trigger to change the register' | ||
+ | For the testing purpose you can do this manually. | ||
+ | {{ : | ||
+ | After that, check the DynamoDB Table' | ||
+ | |||
+ | {{ : | ||
+ | When you ensure, that data comes to DynamoDB triggered by auxilary WebHMI register change, you can set up the trigger' | ||
+ | |||
+ | As an example there is two practices such as time dependent (oscillator) or quantity depended (decimation) trigger. \\ | ||
+ | \\ | ||
+ | **// | ||
+ | If there is a neccesity to post with predefined frequency, for example 15 second can be done with following script. | ||
+ | |||
+ | <code lua> | ||
+ | a1,a2,a3,a4 = 0,0,0,0 | ||
+ | |||
+ | function TOGGLE(reg) | ||
+ | WriteReg(reg, | ||
+ | end | ||
+ | |||
+ | function main (userId) | ||
+ | |||
+ | if GetReg(" | ||
+ | TOGGLE(" | ||
+ | decimation_counter = 0 | ||
+ | end--if | ||
+ | |||
+ | end--eof | ||
+ | </ | ||
+ | **// | ||
+ | \\ | ||
+ | If there is several target register, such as //counter, counter2, etc.//, but if it changes too often, this code will help to decimate the output trigger signal. | ||
+ | <code lua> | ||
+ | a1,a2,a3,a4 = 0,0,0,0 | ||
+ | |||
+ | decimation_counter = 0; | ||
+ | DECIMATION = 10 | ||
+ | |||
+ | function TOGGLE(reg) | ||
+ | WriteReg(reg, | ||
+ | end | ||
+ | |||
+ | function main (userId) | ||
+ | if decimation_counter> | ||
+ | |||
+ | -- check if target registers changed | ||
+ | flag = a1 ~= GetReg(" | ||
+ | or | ||
+ | a2 ~= GetReg(" | ||
+ | or | ||
+ | a3 ~= GetReg(" | ||
+ | or | ||
+ | a4 ~= GetReg(" | ||
+ | |||
+ | if flag then | ||
+ | decimation_counter = decimation_counter + 1 | ||
+ | end | ||
+ | |||
+ | -- update local variale values for next scan check | ||
+ | a1 = GetReg(" | ||
+ | a2 = GetReg(" | ||
+ | a3 = GetReg(" | ||
+ | a4 = GetReg(" | ||
+ | |||
+ | -- DEBUG trace | ||
+ | DEBUG(" | ||
+ | DEBUG(" | ||
+ | DEBUG(" | ||
+ | DEBUG(" | ||
+ | DEBUG(" | ||
+ | |||
+ | -- decimation_counter for not too often upload to AWS | ||
+ | if decimation_counter >= DECIMATION then | ||
+ | TOGGLE(" | ||
+ | decimation_counter = 0 | ||
+ | end--if decimation_counter | ||
+ | |||
+ | end--eof | ||
+ | </ | ||
+ | |||
+ | ==== Next steps ==== | ||
+ | ==== Create visualisation environment ==== | ||
+ | To use Kibana visualisation firstly you need to run an ElasticSearch engine deployed on virtual machine. | ||
+ | So the idea is to create ElasticSearch Instance with Kibana plugin on-board. | ||
+ | Fortunately, | ||
+ | {{ : | ||
+ | So, crete a new one instance with following settings. | ||
+ | {{ : | ||
+ | Specify domain name and instance type (size, e.g. t2.small). | ||
+ | {{ : | ||
+ | Specify the access policy, the good practice is a public one, but there is should IP resctiction be specified. | ||
+ | {{ : | ||
+ | [[https:// | ||
+ | {{ : | ||
+ | The first line has your current IP. | ||
+ | As a CIDR block you can rewrite you IP as XXX.XXX.XXX.XXX/ | ||
+ | Otherwise, copy your IP to field as is. | ||
+ | \\ | ||
+ | In the end, this will lead your to this settings. Review it and confirm creation if it fine. | ||
+ | {{ : | ||
+ | After the creation, in several minutes it will be endpoint adress created | ||
+ | {{ : | ||
+ | Wait until it would be done. | ||
+ | {{ : | ||
+ | At this moment, you will have access to Kibana plugin, the following link is provided above. | ||
+ | {{ : | ||
+ | ==== Create a DynamoDB to Elasticsearch bridge using Lambda function ==== | ||
+ | |||
+ | |||
+ | |||
+ | < | ||
+ | 0) formulate the payload in JSON and clarify the DDBv2 rule | ||
+ | 1) Create Lambda function, set up destinations, | ||
+ | |||
+ | 2) test function successfully. | ||
+ | |||
+ | 3)check Kibana metric created. | ||
+ | |||
+ | 4) Work with Kibana | ||
iot/tutorial/aws-integration.txt · Last modified: 2021/07/22 07:32 by atolstov