This application allows you to use one command to start sending sensor data (the current temperature in Celsius) to the Devnet Tangle.
To use this demo, you need the following:
- An Enviro Phat sensor board connected to a Raspberry Pi
For help setting up a Raspberry Pi, you can follow these instructions.
For help setting up the Enviro Phat, you can follow the Soldering guide and the Getting started guide.
- Clone this repository
git clone https://github.com/iota-community/raspberrypi-pubsub
- Change into the
raspberrypi-pubsub
directory
cd raspberrypi-pubsub
- Install the dependencies
npm install
- Run the code
node index.js
In the console, you should see that the current temperature in Celcius is sent as a transaction to a node on the Devnet.
Note: To check that your transaction is on the Devnet Tangle, you can copy the value of the hash
field and paste it into the search bar of the Devnet explorer.
The message
field contains the temperature data in trytes. To convert the trytes to ASCII characters, use one of the converter functions in the client libraries.
Learn how to convert data between trytes and ASCII characters.
Starting app
Current temp: 35.4805409354
Sending transaction
Transfer successfully sent
{ hash:
'GTJICLAKCQOANGP9WZRCYIQQIJTQCMPLTAKEFWPXOSOUWALGNBBDYOWTWQSM9MRLEIMVHGMLDALYLH999',
signatureMessageFragment:
'ODGAHDTCADDDTCFDPCHDIDFDTCGADBJCODGAJDPC9DIDTCGADBUAQAGAPCSCSCFDTCGDGDGADBGANBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCKBCBKBNBNBACOBBCBCCBNBKBCCGAQAGAADTCGDGDPCVCTCGADBGAYBNBQBKBRBNBCCMBKBNBNBNBCCMBPBNBZBMBRBNBSBNBPBNBCCMBQBKBNBLBQBKBGCKBICKBBCKBHCKBLBLBDCKBICKBHCKBDCKBMBLBGCKBICKBHCKBQBKB9CNBGAQDLCQD999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999',
address:
'DATA9ADDRESS9DATA9ADDRESS9DATA9ADDRESS9DATA9ADDRESS9DATA9ADDRESS9DATA9ADDRESS9DAT',
value: 0,
obsoleteTag: 'MPA999999999999999999999999',
timestamp: 1558702721,
currentIndex: 0,
lastIndex: 0,
bundle:
'LTIKJHINULXQ9FZ9UE9LZUZYUJTA9PGAZGHUFNKVHVFJVXFAN9HJBXLDJSVYALUVPCT9BJWYJETIYIOHB',
trunkTransaction:
'BIAVEQYFHWWQK9VUM9VSIJFZCKIPNRYXUUBLCHLJGVGTAGJEZWGCIIYXMQYXKWFCBAMAWPKAJTUGFJ999',
branchTransaction:
'BIAVEQYFHWWQK9VUM9VSIJFZCKIPNRYXUUBLCHLJGVGTAGJEZWGCIIYXMQYXKWFCBAMAWPKAJTUGFJ999',
tag: 'MPA999999999999999999999999',
attachmentTimestamp: 1558702724384,
attachmentTimestampLowerBound: 0,
attachmentTimestampUpperBound: 3812798742493,
nonce: 'IDXRJXHLAVHPUJY9ZBWAFFJH9TR'}