Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Diy IoT is incredibly fun, and the barrier to entry is pretty low. There are wifi connected arduino boards out there to be had for $10â$20. Much of the time these boards will become packed with sensors and able to monitor their surroundings easily. Examples include temperature, humidity, barmoetric pressure, light and motion. https://www.adafruit.com/category/35 Building further sensor gateways and gathering that data from the âdunios quickly shoots up the learning curve and gets developers quickly frustrated trying to gather from boards and process the data. Using a couple libraries one can quickly and simply get this data pushed into a personal splunk instance. This is done through a simple web post to the Splunk Http Event Collector or âhec.â From there the sky is the limit.
First things first what is an arduino? https://www.arduino.cc/ Arduinos are an entire clarification of microcontoller boards. Some are configured bare bones and others are esp8266 chips with extra memory space and breakouts. The boards used in this explanation are Adafruit âHuzzahâ 8266 breakouts. https://www.adafruit.com/product/2471 These are used because of cost of materials, an arduino Uno board is the entry level board for $20. It is a bare microcontroller which would then require a second âshieldâ in order to bundle a wifi controller onto it. It is much easier to get a simple cheap huzzah. Adafruit has a great community of tutorials and getting started guides to get the Arduino IDE downloaded and configured, and then installing the proper libraries to support the huzzah board. Those libraries are then leveraged for the http and wifi clients. Take a look, get the IDE configured and the boards added here. https://learn.adafruit.com/add-boards-arduino-v164?view=all
Before diving into the Arduino âsketch codeâ, it should be understood the kind of code we are going to see. Arduinos are pretty much a friendlier âC.â Much of the strongly typed language is there, however String is available and the entire compiling and upload process is done through a nice gui. It can also be done through makefiles and the like but the debugger is at least a little bit better in the Arduino IDE. Itâs recommended to start there. A result of the C roots is that working with http requests is going to be a little less than user friendly, but not terrible. The http headers will need to be added and then the content length summed up and finally the entire message bundled up before submitting the http post request. While this isn't the end of the world if someone is not familiar with how http works it could be confusing. Donât worry, take some time read the code, it will all make sense.
Just over 100 lines of code, hopefully that wasât too bad. The majority of the work is broken out into a couple functions. The Loop() function is constantly running because that is how arduino works. Setup() is run once on boot. Then everything else is only run when called. The Loop() gathers up some dummy data and passes it the splunkpost() . If there was a more elaborate data gather needed it could be easily called from the loop and then returned to be sent on to splunkpost(). Splunk post receives all the parameters that were configured at the beginning for the Splunk server, HEC, and some metadata. There is a gotcha in that the http collector is hard coded in the firmware, there are more elegant and configurable ways to do this, however for this purpose it is fine. it should be noted that a rebuild and reflash would be needed if the HEC were to change.
Thats all folks! An arduino connected to wifi network and then sending that data directly into Splunk via HEC. All without the need for anything else, no data gateways no serial bit banging between shields to push the sensors to the wifi board. Just sensor data from a DiY arduino going into the robust awesomeness that is Splunk. From Splunk all the analytics number crunching and alerting can be done. Hopefully this was descriptive enough to the wheels turning and the data flowing.
Links:
- Arduino - Home
- Adafruit HUZZAH ESP8266 Breakout
- Overview | Adding Third Party Boards to the Arduino v1.6.4+ IDE | Adafruit Learning System
- Overview | Adafruit HUZZAH ESP8266 breakout | Adafruit Learning System
- Sensors : Adafruit Industries, Unique & fun DIY electronics and kits
- About the Splunk HTTP Event Collector - Splunk Documentation
Arduino, Meet Splunk was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.