[fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Introduction[/fusion_title][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]
This is the chapter web page to support the content in Chapter 11 of the book: Exploring BeagleBone – Tools and Techniques for Building with Embedded Linux. The summary introduction to the chapter is as follows:
This chapter describes how the Beagle boards can be used as a core building block of the Internet of Things (IoT). In this chapter you are introduced to the concepts of network programming, the IoT, and the connection of sensors to the internet. Several different communications architectures are described: The first architecture configures the Beagle board to be a web server that uses various server-side scripting techniques to display sensor data. Next, custom C/C++ code is described that can push sensor data to the internet and to platform as a service (PaaS) offerings, such as ThingSpeak and the Adafruit IO service using MQTT. Finally, a client/server pair for high-speed Transmission Control Protocol (TCP) socket communication is described. The latter part of the chapter introduces some techniques for managing distributed Beagle board sensors, and physical networking topics: setting the Beagle board to have a static IP address; and using Power over Ethernet (PoE) with the Beagle board. By the end of this chapter you should be able to build your own connected embedded IoT devices.
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”3_5″ layout=”3_5″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]
Learning Outcomes
After completing this chapter, you should be able to:
- Install and configure a web server on a Beagle board and use it to display static HTML content.
- Enhance the web server to send dynamic web content that uses CGI scripts and PHP scripts to interface to Beagle board sensors.
- Write the code for a C/C++ client application that can communicate using either HTTP or HTTPS.
- Build a full local MQTT architecture using Mosquitto and Paho.
- Interface to platform as a service (PaaS) offerings, such as ThingSpeak and Adafruit IO, using HTTP and MQTT.
- Use the Linux cron scheduler to structure workflow on the Beagle board.
- Send e-mail messages directly from a Beagle board and utilize them as a trigger for web services such as IFTTT.
- Build a C++ client/server application that can communicate at a high speed and a low overhead between any two TCP devices.
- Manage remote Beagle board devices, using monitoring software and watchdog code, to ensure that deployed services are robust.
- Configure a Beagle board to use static IP addresses, and wire it to utilize Power over Ethernet (PoE).
[/fusion_text][/fusion_builder_column][fusion_builder_column type=”2_5″ layout=”2_5″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text][toc][/fusion_text][fusion_sharing tagline=”Share this page:” tagline_color=”” title=”Exploring BeagleBone: Chapter 1″ link=”http://exploringbeaglebone.com/chapter1/” description=”” pinterest_image=”” icons_boxed=”” icons_boxed_radius=”4px” box_colors=”” icon_colors=”” tooltip_placement=”” backgroundcolor=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” content_align=”left” size=”1″ font_size=”” line_height=”” letter_spacing=”” margin_top=”” margin_bottom=”” text_color=”” style_type=”single solid” sep_color=””]
Additional Materials (for First Edition)
[/fusion_title][fusion_text]
CGI using C++ on the BeagleBone (Ggicc)
[fusion_lightbox] [/fusion_lightbox]
In this chapter I describe how you can build web-based CGI applications that can interface with electronics hardware that is attached to the BeagleBone using Bash scripts that call C/C++ programs. The solution works well for very straightforward applications, but this linked discussion investigates more advanced solutions for applications where there are more complex interactions — for example, the use of web forms to pass data between your web browser and the application that is executing on the BeagleBone. In the linked blog discussion I begin by explaining how you can use a C/C++ program, rather than a CGI script, to display a web page. I then investigate the use of the GNU Cgicc library for more structured and complex interactions. All of the source code for this example is in the Exploring BeagleBone GitHub repository in the chp10/cgicc directory.
[/fusion_text][fusion_separator style_type=”shadow” top_margin=”15″ bottom_margin=”20″ sep_color=”#9b9b9b” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Products Described in the Chapter[/fusion_title][/fusion_builder_column][fusion_builder_column type=”1_3″ layout=”1_3″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text]
[amazon asin=B00GYQXDQW,B003MTTJOY,B003E6493G,B00H28H8DU,B006WWN016,B00BDW6D7I&template=ebbchapters][/fusion_text][/fusion_builder_column][fusion_builder_column type=”2_3″ layout=”2_3″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_text]
A number of different Wi-Fi adapters are described in the chapter, such as those in the figure below. The widget on the left-hand side links to some of these adapters on Amazon, where you can find other products, even health related like the compression socks women that are good for women that practice sports. However, not all of these adapters are confirmed to be working. The adapters that were evaluated in the book that are working well are:
- The TP-LINK 300Mbps Wireless N Mini that uses the RTL8192CU chipset. Two alternatives are presented in this list: the Rosewill Wireless Adapter and the generic 300Mbps Realtek adapter, which both use the same chipset. The two alternatives have not been tested
- The Edimax EW-7811Un that uses the RTL8188CUS chipset. It is listed along with two alternatives: the Wi-Pi Raspberry Pi adapter, and the Plugable USB 2.0 adapter, which both use the same chipset. The two alternatives have not been tested, but the Wi-Pi is known to work well.
- The Asus USB-N10 adapter that uses the RTL8188SU chipset.
[fusion_lightbox] [/fusion_lightbox][/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_separator style_type=”shadow” top_margin=”15″ bottom_margin=”20″ sep_color=”#9b9b9b” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Digital Media Resources[/fusion_title][fusion_text]
Here the digital resources referred to in the chapter web page are provided. There are high-resolution versions of some of the important figures and links to videos, resources and websites that are described in the chapter.
[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Source Code[/fusion_title][fusion_text]All of the source code that is described in this book is available in a public GitHub repository: Derek Molloy Exploring BeagleBone repository.
You can clone this repository on a Linux desktop computer or your BeagleBone using the command:
git clone https://github.com/derekmolloy/exploringBB.git
The code for this chapter can be accessed in the chp10 folder of the cloned repository. The formatted code for the client/server example is provided here for your convenience.[/fusion_text][fusion_separator style_type=”none” top_margin=”15″ bottom_margin=”” sep_color=”” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_tabs design=”” layout=”horizontal” justified=”yes” backgroundcolor=”” inactivecolor=”” bordercolor=”” class=”” id=””][fusion_tab title=”SocketClient.h” icon=””]
[/fusion_tab][fusion_tab title=”SocketClient.cpp” icon=””]
[/fusion_tab][fusion_tab title=”SocketServer.h” icon=””]
[/fusion_tab][fusion_tab title=”SocketServer.cpp” icon=””]
[/fusion_tab][/fusion_tabs][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible” margin_top=”” margin_bottom=”20px” background_color=”rgba(255,255,255,0)”][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_separator style_type=”shadow” sep_color=”#9b9b9b” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Some High-Resolution Figures from this Chapter[/fusion_title][fusion_text]Here are high-resolution images of some of the more complex figures in this chapter, which may help you in wiring the circuits. Please note that you can close this pop-up window by pressing the Escape key.[/fusion_text][fusion_separator style_type=”none” top_margin=”15″ bottom_margin=”” sep_color=”” icon=”” width=”” class=”” id=”” /][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_images picture_size=”fixed” lightbox=”yes” class=”” id=””][fusion_image link=”” linktarget=”_self” image=”http://exploringbeaglebone.com/wp-content/uploads/2014/12/935125-c10f001.png” alt=””/][fusion_image link=”” linktarget=”_self” image=”http://exploringbeaglebone.com/wp-content/uploads/2014/12/935125-c10f014.png” alt=””/][/fusion_images][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”1″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]External Resources[/fusion_title][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_2″ layout=”1_2″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Important Documents[/fusion_title][/fusion_builder_column][fusion_builder_column type=”1_2″ layout=”1_2″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]External Web Sites[/fusion_title][/fusion_builder_column][fusion_builder_column type=”1_4″ layout=”1_4″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_imageframe lightbox=”no” style_type=”dropshadow” bordercolor=”” bordersize=”0px” borderradius=”0″ stylecolor=”” align=”center” link=”http://www.ti.com/product/am3358″ linktarget=”_blank” animation_type=”0″ animation_direction=”down” animation_speed=”0.1″ class=”” id=””] [/fusion_imageframe][fusion_text]
The AM335x Technical Reference Manual (TRM)
[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_4″ layout=”1_4″ last=”no” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_imageframe lightbox=”no” style_type=”dropshadow” bordercolor=”” bordersize=”0px” borderradius=”0″ stylecolor=”” align=”center” link=”https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf?raw=true” linktarget=”_blank” animation_type=”0″ animation_direction=”down” animation_speed=”0.1″ class=”” id=””] [/fusion_imageframe][fusion_text]
The BeagleBone Black System Reference Manual (SRM)
[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_2″ layout=”1_2″ last=”yes” spacing=”yes” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_size=”0px” border_color=”” border_style=”” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” class=”” id=”” min_height=”” hover_type=”none” link=”” border_position=”all”][fusion_separator style_type=”shadow” top_margin=”” bottom_margin=”” sep_color=”” icon=”” width=”” class=”” id=”” /][fusion_text]
- TI SensorTag User Guide: tiny.cc/ebb1003
- Linux socket programming: tiny.cc/ebb1007
- Apache for Debian: tiny.cc/ebb1008
- Debian network confi guration: tiny.cc/ebb109
- Xively REST API: tiny.cc/ebb1010
- The ABCs of PoE: tiny.cc/ebb1011
- TI SensorTag YouTube Video: tiny.cc/ebb1012
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container backgroundcolor=”no” backgroundimage=”” backgroundrepeat=”no-repeat” backgroundposition=”left top” backgroundattachment=”scroll” video_webm=”” video_mp4=”” video_ogv=”” video_preview_image=”” overlay_color=”” video_mute=”yes” video_loop=”yes” fade=”no” bordersize=”0px” bordercolor=”” borderstyle=”” paddingtop=”0px” paddingbottom=”0px” paddingleft=”0px” paddingright=”0px” menu_anchor=”” equal_height_columns=”no” hundred_percent=”no” class=”” id=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Errata[/fusion_title][fusion_text columns=”” column_min_width=”” column_spacing=”” rule_style=”default” rule_size=”” rule_color=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=””]
Second Edition
- None so far
First Edition
- Page 391. There should be a line echo “” after the line echo “Content-type: text/html” in the script that displayed in the center of the page. The code in the GitHub repository is correct.
- Page 396. The title of code Listing 10-2 should be /exploringBB/chp10/WebBrowser/WebBrowser.c not WebClient/WebClient.c. The correct title is used in the description and elsewhere.
[/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_title size=”2″ content_align=”left” style_type=”single solid” sep_color=”” class=”” id=””]Recommended Books on the Content in this Chapter[/fusion_title][fusion_text][amazon asin=0996025510&template=Iframe Image] [amazon asin=1449393578&template=Iframe Image] [amazon asin=0789722410&template=Iframe Image] [amazon asin=0131411551&template=Iframe Image] [amazon asin=0071626751&template=Iframe Image] [amazon asin=1593272200&template=Iframe Image][/fusion_text][/fusion_builder_column][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none” last=”no” hover_type=”none” link=”” border_position=”all”][fusion_sharing tagline=”Share This Story, Choose Your Platform!” tagline_color=”” title=”” link=”” description=”” pinterest_image=”” icons_boxed=”” icons_boxed_radius=”4px” box_colors=”” icon_colors=”” tooltip_placement=”” backgroundcolor=”” class=”” id=”” /][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container][fusion_builder_container hundred_percent=”no” equal_height_columns=”no” menu_anchor=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” background_color=”” background_image=”” background_position=”center center” background_repeat=”no-repeat” fade=”no” background_parallax=”none” parallax_speed=”0.3″ video_mp4=”” video_webm=”” video_ogv=”” video_url=”” video_aspect_ratio=”16:9″ video_loop=”yes” video_mute=”yes” overlay_color=”” video_preview_image=”” border_size=”” border_color=”” border_style=”solid” padding_top=”” padding_bottom=”” padding_left=”” padding_right=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” border_position=”all” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” center_content=”no” last=”no” min_height=”” hover_type=”none” link=””][fusion_text]
Feel free to contact us on Social Media, we were recently able to Buy automatic instagram likes for all our content, this way the posts will grow on popularity.
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]
Loc 10515: The link for the TMP35/36/37 data sheet is broken. It isn’t a link.
It seems to be working here at tiny.cc/ebb1001 I wonder if this is a “.” problem again? Some people are reporting that the period is being added to the URL and messing it up on the Kindle version. I tried creating a parallel set of URLs with periods added, but unfortunately I am not permitted.
Loc 10486: Could you please explain this line of code…
************************************************
float cur_voltage = adc_value * (1.80f / 4096.0f);
************************************************
I certainly understand that the BBB has a 12-bit ADC, hence the 4096. However I am not sure where you’re getting the 1.80f from? Does it have something to do with the conversion from Fahrenheit to Celsius? There’s a 1.8 constant there, but I am not quite sure where the one in your code comes from. What am I missing?
The 1.80 is the 1.8V upper voltage level of the ADC. This calculation results in the exact voltage level on the ADC input.
I’m still not sure that makes sense to me, but I do remember you discussing it in one of the earlier chapters–so I’ll go back and look for it. It would be easier if the search feature worked, but it doesn’t yet. So I’ll have to search manually…but I do remember seeing something about converting the raw ADC data, so it might well be easily explained there. But it’s not jumping out at me right now.
Ah…got it. Location 4466.
The 1.8 volts is divided into 4096 steps, so each integer “step” (adc_value, here) is 1.8/4096 wide. OK, I do remember it now, lol.
Also, in regards to the rest of that block of code to get the temperature (in degreesC), it might be eaiser to solve for the equation of the line and use that in that function. It would seem to remove one line of code (and some math) from that function. Since the voltage output is a linear 0.01v / degC, one can simply express the equation as this:
************************************************
y – 0.75 = 0.01(x – 25)
y = 0.01x – 0.25 + 0.75
y = 0.01x + 0.50 (where y = voltage, and x is degrees C)
so: degC = (voltage – 0.50) / 0.01
************************************************
So I am still not quite sure where the “1.80f” comes from, but your function can simply become…
float getTemperature( int adc_value)
{
float cur_voltage = adc_value * ( 1.80f / 4096.0f);
return ( (cur_voltage – 0.50) / 0.01);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Looking at it again now, I guess it doesn’t simplify the math all that much, as you still have one division–and I’ve added a multiplication operation. It would be interesting to profile each block of code and see which executes faster.
Yes, I haven’t optimized the code in this case as it is not called very often — however, I would hope that compiling this with -O3 would result in the 1.80f/4096.0f being replaced with the resulting constant.
No doubt it would. And you could easily do that yourself of course, with a double. But that’s largely irrelevant, as what you can’t optimize (in this case) is either of the lines of code involved in the replacement of your code with mine. And since I added a multiplication operation, it might be better to simply leave it as the text lists it originally…
Loc 10585: Simple grammar error. Should be:
************************************************
Integrate sensors and use THEM to intercommunicate between devices.
************************************************
Thanks. The “it” refers to the web server, not to the sensors. I could have phrased the point more clearly!
Ah… I noticed a few more of those tiny.cc/ebbXXXX links not being links–and not all of them were following by a period. But the actual link seems to work correctly, once you type it in. Kindle cloud browser doesn’t allow you to copy and paste, but if you type them into the URL bar they generally seem to point at what you want them to. So I’m not worrying about those anymore, given that you’ve said they seem to work for you.
Loc 1652: The index.html write will have to be done as root of course, as root is owner and group for /var/www–and there are no write privileges set for others. So unless you chmod it accordingly, the write will have to be as root.
…same as for /usr/lib/cgi-bin, actually.
Maybe somehow your distro is different than mine? I’m using the latest Debian image from the Beagleboard.org site.
*******************************************
$ uname -a
Linux beaglebone 3.8.13-bone50 #1 SMP Tue May 13 13:24:52 UTC 2014 armv7l GNU/Linux
$ ls -l | grep cgi
drwxr-xr-x 2 root root 4096 Feb 1 2014 cgi-bin
*******************************************
Thanks for that. Yes, you may need to make /var/www and /usr/lib/cgi-bin writable so that a user can add scripts. I don’t actually recall having done that, but I have used so many images that it is possible.
Understood. I just listed these comments here in case someone was having problems and needed a hint as to what might be amiss. It was no problem whatsoever to just run chmod, or create the file(s) as root. And since everyone had read and execute privilege, it runs just fine…
Anyone else try to sign up for an Xively free development account? I did tonight and they are telling me there’s a waiting list for the free accounts, so I was just wondering if anyone knew how long that took. They didn’t give any indication in the email I received.
That’s new and a pity, as it is a great platform to work with. Please let me know how long it takes. Luckily I have covered both Xively and ThingSpeak in the chapter (and fortunately ThingSpeak is open source). I can have a look at alternatives if there are continued access problems. Derek.
I got ThingSpeak to work after playing with it a bit. I posted a link in the Embedded Fun group. Pretty slick!
Loc 11391: In Table 10-3 where you talk about wireless connectivity for the BBB, your table talk about XBee and mentions that is has short range and low throughput. However I wondered if you’ve seen some of the “XBee Pro 900-series” modules? I’ve never used one of those particular units, but this SparkFun link does show what I’ve read about them in the past–that they have impressive range and throughput. I’d like to try one of those things actually, and may do that sooner rather than later–and I was just wondering if you’ve played around with them at all?
************************************************
https://www.sparkfun.com/pages/xbee_guide
Maybe it could be more clear, but the table lists ZigBee as the highest performer in terms of range out of all of the entries in this table (at approx. 100m — the others could be as little as 10m). I have used the the XBee Pro modules (really impressive!) — I built an LED flasher that flashed until it lost a signal and I was able to walk a good distance away from my house. The figures listed in the table are “realistic” values for urban environments. I believe that with line-of-sight that much greater range is possible, but I think the table gives a generalized indicative comparison of the technologies. Jeremy Blum’s book has a full discussion on ZigBee with the Arduino — I would have loved to have covered it too with the BBB — maybe it will be an addendum! Derek.
Loc 11525: Where you talk about configuring the BBB to use a static IP address, your text states…
************************************************
“To allocate a static IP address for the wireless adapter, you can alter the /etc/network/interfaces configuration file to manually specify the address…”
************************************************
Then you give an example entry, where you use “auth eth0.” Shouldn’t that be “auto wlan0,” for instance? Isn’t the “eth0” interface in Linux the first wired Ethernet connection by default? I mean, it’s probably possible to label the wireless interface as eth0, but all the standard convention I’ve seen uses wlanX.
Ah…maybe you referred to the wireless interface, but then just gave the wired interface (eth0) syntax as an example? The comment does mention that it is “The primary network interface,” so maybe you weren’t calling the wireless adapter “eth0” at all…
Yes, exactly. I am using a wired adapter eth0 for the static example, rather than wireless. Apologies for the confusion. Derek.
On page 384, under “A Room Temperature Sensor”, you say “These voltage output levels are within the safe levels for the BBB ADC—the room temperature range is not!”
That’s really confusing. I hope the BBB ADC works within the normal room temperature range; I wasn’t planning to refrigerate my BBB while using the ADC… ☺
Are you trying to say that if the TMP36 reported one volt per degree C, it would exceed 1.8V? (Yes, I rather guess it would!)
Is the main point that this is a rare component that can be powered from 5V and yet provide a safe output without clamping or scaling for a 1.8V-limited ADC?
Hi Michael — Thanks! I should have clarified what I meant more clearly… to get a voltage output of ~0.1V the room temperature would have to be -40 degrees Celsius (which is -40 Fahrenheit), and at ~1.8V the room temperature would have to be +125 degrees Celsius (which is 257 Fahrenheit). According to Gerald Coley, the BeagleBone components have a safe range of ~0-50 degrees Celsius. Regardless, that range is beyond my safe operating room temperature range! Derek.
Derek, Is there a problem with your comments not posting correctly? I notice that the last comments are from Jan 27. I posted since then and saw that you had answered, but the last couple of days I’ve been checking back to see your answer and it has been gone. Is it possible that your message system has lost the comments since Jan. 27? Thanks.
Hi Marty, I don’t think so. Some chapters seem to have many more questions than others — Chapter 10 is a quiet one! Derek.
Hi Marty, I searched and see your question (with my response) — it is on the book main page. Hope it helps, Derek.
I like the DS18B20 vs the TMP36. Maybe because I found it to be cheaper, but it is more advanced. It does require a bit more programming but I used them with great success with the Raspberry Pi, the PIC32MX795F512L, and the Teensy 3.1. Since I picked the BeagleBone Black as my choice for an embedded Linux prototyping platform, I am actively working to use this sensor. Since I have so many of these sensors, both in raw form and in waterproof probe casings, it makes sense for me to do this. If anyone is interested, I’ll post what I do to get the DS18B20 working with the BBB. And as always, thank you Derek! This looks to be an exciting chapter to work through!!
External link typo
Debian network configuration: tiny.cc/ebb109
should be : tiny.cc/ebb1009
Regards
Thank Rod, I have set that URL to also point to the same reference. Thanks, Derek.
While I’m at it..
p396 Listing10.2 …./WebClient/WebClient.c
should be
…/webBrowser/webBrowser.c
Regards
Thanks Rod, Adding to the list of errata. Kind regards, Derek.
Derek –
Your WiFi tutorial in the book was really great and useful. I used it to get the Ralink Technology Corp RT5370 chipset Wireless adapter dongle working. It is the Purple/White one sold many places such as at element14:
Anyhow, since I ran into a few minor obstacles, I thought I’d post them here to help keep your great book and great website up-to-date. You really can’t imagine how helpful your book and site are to me and our team.:
Here are the steps I needed to do to get this working well on my system.
first, I had to add several missing packages to my linux distro: 3.8.13-bone70
1.) sudo apt-get install usbutils ….. (to use lsusb to see my WiFi Dongle info)
2.) sudo apt-get install wireless-tools ….. (to use iwlist wlan0 scan to seach for my network info)
3.) sudo apt-get install wpasupplicant ….. (to use the wpa-conf and other wpa tools)
4.) sudo apt-get install firmware-Ralink ….. (to install the Ralink RT5370 driver)
With these done, getting the rest working was simple with your book as a guide.
My procedures were as follows:
1.) Download the above
2.). cd /etc
3.) wpa_passphrase SELabs myNetworkPassword > /etc/wpa.conf
4.) Open that file and delete the #myNetworkPassword line to remove this comment that announces to the world my wpa password
5.) check my networkl settings and confirm that pairwise and group settings are CCMP & TKIP as you had them in the book
6.) edit my /etc/network/interfaces to add auto wlan0 to have it auto detect at boot, and then exactly as you have it in the book
I also found ethe following websites helpful for this:
1.) http://elinux.org/BBBWiFiConfigs
2.) https://wiki.debian.org/WiFi/HowToUse#wpasupplicant
3.) http://manual.aptosid.com/en/inet-setup-en.htm
simple as that…20-minutes effort and I’m up and running without a network cable to tie me down anymore 🙂
Thanks again for the wonderful book and your great support of it on this site. You have contributed more than you know to the success of myself and many others.
Best Regards,
Carl
Michigan, USA
Thanks Carl, Very useful! Derek.
Hi Derek,
I am still loving this book. Another pair quick questions;
1) I can get wifi access if I run ‘ifup wlan0’ when I log on. I have even added this command to my .profile file, so I have access automatically when I log in.
What do I need to do to activate wlan0 when the BBB boots – but I have yet to log on?
This will allow me to connect using SSH wirelessly.
2) How do I store multiple router credentials ie my home router and office router?
currently I have….
# WiFi Example
auto wlan0
iface wlan0 inet dhcp
wpa-ssid “AndroidAP”
wpa-psk “cccc”
Thank in Advance
Andy
Thanks Andy, it should come up automatically if you add the line
auto wlan0
in the /etc/network/interfaces file — I’m surprised that it doesn’t! (I see that you have done this in the second question) On the multiple credentials, I have had some luck with adding multiple network entries to my /etc/wpa_supplicant/wpa_supplicant.conf with two ID strings. Then in the /etc/network/interfaces file under wlan0 add entries for both network entries. See the network blocks section in: https://www.freebsd.org/cgi/man.cgi?query=wpa_supplicant.conf. Be warned, it can be a frustrating process! Kind regards, Derek.Hi Derek,
I did some more testing last night. I am using an android app called ‘fing’ to monitor local IP address allocation on my home network.
I have added the “ifup wlan0” in my .profile script.
If I boot the device by applying power over the 5vdc jack, I do not get an IP address appearing for the BBB.
If I connect over USB via 192.168.7.2 and login ( which causes the “ifup wlan0” to execute via my .profile script). I see an IP address appear.
Is there some other boot script, which executes prior to login, which I can add the “ifup” command to?
Hi Derek,
I’ve had a problem with WiFi for quite some time that I’ve simply lived with, but found the solution tonight, so I thought I’d share in-case anyone else has the same issue (or in-case I forget in the future!). I have had WiFi Dongle with the Ralink RT5370 chipset working on one dongle for a while…I’ve made many copies of my modified BBB image, and this dongle works on all of the devices I use (~10). Great…BUT…
When I ordered more WiFi dongles with the same chipset, none worked! I tried everything I could to fix, but nothing helped…Until tonight when I stumbled on an old piece of info on a Google Groups forum from 2013.
In it, there was the following suggestion by William Hill: “When a WiFi dongle is plugged in udev detects it and assigns it an interface name “wlan0” .. “wlan1” .. “wlan2″ etc in first come first served order. This interface name is linked to the dongle’s MAC address, so when you clone a system the new wifi dongle doesn’t get assigned the same interface name, and networking breaks. So edit the saved state file /etc/udev/rules.d/70-persistent-net.rules and delete the old entry. ”
I did exactly this and it worked perfectly, and I now can get all my various BBB systems up on Wifi using any of the dongles (provided I follow this step when not working)!
Thanks again for the great book and great site. I have pre-ordered your Exploring Raspberry Pi book and look forward to its’ release!
Carl – Michigan, USA
Thanks Carl, really useful info. Hopefully you enjoy the new book. There is some overlap in content between Exploring Beaglebone and Exploring Raspberry Pi, particularly in the first few chapters. I have made a comparison page available on the Raspberry Pi website at http://exploringrpi.com/comparison/ so you can see what you are getting. Thanks for the support! Derek.
Hi Derek,
I have your Raspberry Pi book and love it. I’m learning quite a lot. I just got the 2nd edition of the Beaglebone book and I skipped ahead to Chapter 11 to see if there was any new information about building Cgicc. I tried to build version 3.2.19 and get an error message about autoheader missing when running make. make fails, saying recipe for config.h.in failed and recipe for all-recursive failed.
I was able to build 3.2.16 successfully using the steps you provided in the RPi book. They look to be the same as those on pg. 508 of the new Beaglebone book aside from the version. Yet I can’t get 3.2.19 to build due the make errors mentioned above.
Any thoughts?
Thanks for any help and for the great books!
Cheers,
Ed
Hi Ed, Thanks for the great feedback. I checked my notes and I had no problem with 3.2.19 on the BB, so I’m at a bit of a loss. Have you tried a “sudo apt install autoconf”. I’m not sure why that should be missing. You should look at beginning the build in a fresh directory also (just in case!). Please send on the full message and I’ll have a look. Derek.
Sorry I didn’t see your reply until just now. I’ll try to reinstall autoconf. I’m assuming it’s already installed because 3.2.16 built successfully.
This was the error message I got when trying to make cgicc-3.2.19:
pi@raspberrypi:~/cgicc/cgicc-3.2.19 $ make
Making all in cgicc
make[1]: Entering directory ‘/home/pi/cgicc/cgicc-3.2.19/cgicc’
(CDPATH=”${ZSH_VERSION+.}:” && cd .. && /bin/bash /home/pi/cgicc/cgicc-3.2.19/support/missing autoheader)
/home/pi/cgicc/cgicc-3.2.19/support/missing: line 81: autoheader: command not found
WARNING: ‘autoheader’ is missing on your system.
You should only need it if you modified ‘acconfig.h’ or
‘configure.ac’ or m4 files included by ‘configure.ac’.
The ‘autoheader’ program is part of the GNU Autoconf package:
It also requires GNU m4 and Perl in order to run:
Makefile:415: recipe for target ‘config.h.in’ failed
make[1]: *** [config.h.in] Error 127
make[1]: Leaving directory ‘/home/pi/cgicc/cgicc-3.2.19/cgicc’
Makefile:482: recipe for target ‘all-recursive’ failed
make: *** [all-recursive] Error 1
I do have 3.2.16 built so it’s not a necessity to build 3.2.19, but I do appreciate you having a look at it.
Cheers,
Ed
Hi again Derek,
I’m still enjoying both Exploring Beaglebone and Exploring Raspberry Pi and continuing to learn a lot. Thank you for these books!
I’m working on the MQTT examples in chapter 11 of the book. I’ve adapted them for my Raspberry Pi. Everything works except the MQTT Subscriber example shown in Listing 11-11 on pgs. 537-539 of Exploring Beaglebone.
My modifications for the RPi are simple: I changed the ADDRESS, CLIENTID and TOPIC to match my publisher program (based on your Listing 11-10). I also commented out the calls to writeGPIO.
The publisher program works great; I’ve been receiving sensor data from it using mosquito_sub for days.
Unfortunately, the subscriber program (Listing 11-11) seems to lose its connection when I publish a message using the publisher program. It prints “Connection lost, cause: (null).” Odd that the connlost() callback was passed a null pointer.
I think the connection may indeed be lost because the subscribe program does not respond to further messages from the publish program. It does end when entering Q, so it doesn’t appear to be crashed or hung.
Any thoughts?
Cheers,
Ed
Hi Ed, I missed this message. Thanks for the feedback! It sounds like a timeout problem. Can you try changing the keepAlive value (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349238) to see if that helps? I think this discussion is important to your problem https://github.com/knolleary/pubsubclient/issues/239. Hope that helps, Derek
2nd Edition, p. 499 (Incorrect abbreviation in Figure) In Figure 11-1 (4) (Beagle board web sensor/actuator using a platform as a service (PaaS)), there are two PocketBeagles with globes to the right and an abbreviation printed on top of the globes. The top abbreviation is MQTT, but the lower abbreviation is MTQQ. I thought perhaps MTQQ was some new-fangled technology I just haven’t heard of, but I can’t find any reference to it, so I am guessing it is a typo for MQTT.
2nd Edition, p. 540 (extraneous character) In the following sentence of the first paragraph (“Interestingly, you can connect your Adafruit IO account to your IFTTT account, whereby you can use an Adafruit IO feed as a trigger for and IFTTT event.”), “as a trigger for and IFTTT event” should be “as a trigger for an IFTTT event”.