Chapter 11: The Internet of Things

Chapter 11: The Internet of Things

/Chapter 11: The Internet of Things
Chapter 11: The Internet of Things2019-01-23T00:01:31+01:00


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.

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).

Additional Materials (for First Edition)

CGI using C++ on the BeagleBone (Ggicc)

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.

Products Described in the Chapter

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.

Digital Media Resources

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.

Source Code

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:

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.

Some High-Resolution Figures from this Chapter

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.

External Resources

Important Documents

External Web Sites

AM335x ARM A8 Technical Reference Manual

The AM335x Technical Reference Manual (TRM)

BeagleBone Black System Reference Manual

The BeagleBone Black System Reference Manual (SRM)


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.

Recommended Books on the Content in this Chapter


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.


  1. TB January 4, 2015 at 10:23 pm - Reply

    Loc 10515: The link for the TMP35/36/37 data sheet is broken. It isn’t a link.

    • Derek January 4, 2015 at 10:48 pm - Reply

      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.

  2. TB January 4, 2015 at 10:35 pm - Reply

    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?

    • Derek January 4, 2015 at 10:45 pm - Reply

      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.

      • TB January 4, 2015 at 10:59 pm - Reply

        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.

        • TB January 4, 2015 at 11:02 pm - Reply

          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.

    • TB January 4, 2015 at 10:50 pm - Reply

      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.

      • Derek January 4, 2015 at 11:17 pm - Reply

        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.

  3. TB January 4, 2015 at 11:27 pm - Reply

    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…

  4. TB January 5, 2015 at 12:15 am - Reply

    Loc 10585: Simple grammar error. Should be:
    Integrate sensors and use THEM to intercommunicate between devices.

    • Derek January 5, 2015 at 12:26 am - Reply

      Thanks. The “it” refers to the web server, not to the sensors. I could have phrased the point more clearly!

      • TB January 5, 2015 at 12:50 am - Reply

        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.

  5. TB January 5, 2015 at 1:04 am - Reply

    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.

    • TB January 5, 2015 at 1:08 am - Reply

      …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

      • Derek January 5, 2015 at 9:48 am - Reply

        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.

        • TB January 5, 2015 at 1:36 pm - Reply

          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…

  6. TB January 8, 2015 at 1:41 am - Reply

    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.

    • Derek January 8, 2015 at 2:45 am - Reply

      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.

      • TB January 8, 2015 at 9:49 pm - Reply

        I got ThingSpeak to work after playing with it a bit. I posted a link in the Embedded Fun group. Pretty slick!

  7. TB January 8, 2015 at 4:36 am - Reply

    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?

    • Derek January 8, 2015 at 12:11 pm - Reply

      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.

  8. TB January 8, 2015 at 4:54 am - Reply

    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.

    • TB January 8, 2015 at 4:57 am - Reply

      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…

      • Derek January 8, 2015 at 12:14 pm - Reply

        Yes, exactly. I am using a wired adapter eth0 for the static example, rather than wireless. Apologies for the confusion. Derek.

  9. Michael K Johnson January 21, 2015 at 2:35 am - Reply

    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?

    • Derek January 21, 2015 at 9:16 pm - Reply

      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.

  10. Marty Porter February 24, 2015 at 1:13 am - Reply

    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.

    • Derek February 24, 2015 at 1:35 am - Reply

      Hi Marty, I don’t think so. Some chapters seem to have many more questions than others — Chapter 10 is a quiet one! Derek.

    • Derek February 24, 2015 at 1:37 am - Reply

      Hi Marty, I searched and see your question (with my response) — it is on the book main page. Hope it helps, Derek.

  11. Gary Rubin April 9, 2015 at 10:13 pm - Reply

    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!!

  12. Rod April 22, 2015 at 7:10 am - Reply

    External link typo

    Debian network configuration: tiny.cc/ebb109

    should be : tiny.cc/ebb1009


    • Derek April 22, 2015 at 10:17 am - Reply

      Thank Rod, I have set that URL to also point to the same reference. Thanks, Derek.

  13. Rod April 22, 2015 at 8:36 am - Reply

    While I’m at it..

    p396 Listing10.2 …./WebClient/WebClient.c

    should be


    • Derek April 22, 2015 at 10:18 am - Reply

      Thanks Rod, Adding to the list of errata. Kind regards, Derek.

  14. Carl September 16, 2015 at 9:19 pm - Reply

    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,
    Michigan, USA

    • Derek September 18, 2015 at 10:44 pm - Reply

      Thanks Carl, Very useful! Derek.

  15. Andy September 24, 2015 at 10:44 pm - Reply

    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

    • Derek September 27, 2015 at 11:15 pm - Reply

      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.

      • Andy September 30, 2015 at 12:44 pm - Reply

        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 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?

  16. Carl Schell June 5, 2016 at 3:34 am - Reply

    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

    • Derek June 7, 2016 at 3:35 pm - Reply

      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.

  17. Ed Hopton March 1, 2019 at 11:10 pm - Reply

    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!


    • Derek March 6, 2019 at 12:48 pm - Reply

      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.

  18. Ed Hopton March 11, 2019 at 9:25 pm - Reply

    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.


  19. Ed Hopton April 15, 2019 at 8:34 pm - Reply

    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?


Leave A Comment

Exploring BeagleBone

This is the companion site for the book “Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux” by Derek Molloy. The site structures and contains all of the digital media that is described in the book. Each chapter in the book links to an individual web page, which can be accessed using the menu on the top right-hand side of this page when you close this menu. For details of the book itself, click here.

Recent Works

Latest from Derek Molloy YouTube Channel

Oops, something went wrong.