I’ve primarily been using a mysql database for my home intelligent management system along with some system messages to communicate between Raspberry Pis. This has been a simple enough arrangement but to really get into more of the low power internet of things, I need a way to send messages amongst several hardware platforms. From looking online, MQTT, seems to be a decent IOT protocol that can accomplish my goals for the home intelligent management system.
This post will look at setting up the basics to support MQTT and get the basics working utilizing information available on the internet.
Here’s a great MQTT introduction and tutorial by BaldEngineer.
With the above introduction in mind. I plan on using a Raspberry Pi as the MQTT broker. I’ll likely migrate this function over to my CENTOS box running Apache/mysql but for now, I want to wait become more familiar with MQTT. In addition to using the Raspberry Pi as the broker, it looks like there’s quite a bit of instructions out there for using Mosquitto as the broker code so I’m going to start there.
Guide to installing Mosquitto as a MQTT broker for Raspberry Pi.
After following the guide above, I have confirmed the broker and client are installed and functioning on the Raspberry Pi. Next step, to get the client installed on my Feather Huzzah.
I had to get things setup to use the Arduino IDE for the Feather Huzzah. I followed the Adafruit guide found here. After following the guide, I was able to connect to the Huzzah using the Arduino IDE and successfully uploaded one of the Adafruit sketches to test my Wifi connectivity.
Next I followed the guide found here.
So a key part of HIMS is to send messages to the remote Raspberry Pis. To do this I created some basic python scripts to send messages that the Raspberry Pis are monitoring for.
The biggest issue I had was related to permissions of the files so that I could call them from my PHP code in WordPress.
Ultimately, it appears the security context attributes need to be set correctly along with the permissions. Essentially chcon, and chmod etc need to be set right.
You can see the security context attributes by typing ls -Z
You can see permissions by typing ls -l
In my CENTOS build running SELINUX, they have the httpd_sys_rw_content_t type.
Here’s some info on chcon:
I was having some trouble getting the remote access working for my plex server and realized I had setup the port forwarding incorrectly within my ZyXEL C1000Z modem. I was entering the manual static IP of the server, the starting and ending port of 32,400, the protocol TCP/UDP.
I then left the Remote Port and IP to All Ip Addresses. I applied thinking I was set. Unfortunately, this did not seem to work.
I then enabled the DMZ for my server and tried again and it was fine. I had another router so I set it to bridge mode, disabled the DMZ, reset the manual port forwarding and it still didn’t work.
The fix was making sure to choose Define IP Addresses within step 4. of the Port forwarding page. From there I left the remote Ip address to blank and set the remote port range to be the same as the LAN port range info. That fixed it.
I have a ProForm 590s treadmill that started going full speed when I started it for about 2 seconds then would stop. The console worked fine but the unit did nothing. After spending some time researching on the web. I confirmed that the speed sensor was still good by using a multi-meter and doing a continuity test on the sensor. When the sensor was aligned with the magnet on the motor, it was closed and completed the circuit.
After that, I scoured some boards and found this post:
“Yep, control board has a shorted HexFET and/or kickback diode. The MC2100 usually comes back to life by replacing the IRFP250 with IRFP260 or better, check current limit resistor in series with the HexFET. A good signal from the console will show a red blinking LED on the MC2100, when the controller see’s too much motor current, as in a runaway, or a feedback mismatch, it kills the drive to the motor section but will leave power to the console intact usually. Fitness Remedy in Sun Prairie Wisc repairs all kinds of fitness electronics for fractions of replacement costs. Good Luck, and remember, there are lethal voltages on many motor control boards, so take care troubleshooting. signed….former treadmill control board engineer ;o) ”
I found the IRFP260 on Amazon prime and ordered it. I also tested the IRFP250 with my multi-meter and confirmed it appeared to be bad. This board has some good info on testing a MOSFET in a circuit.
In any case, I swapped out the MOSFET and the treadmill is now working again. I really appreciate everyone who responded to the other boards. $7 fix versus $160 board.
One item to note, when you solder the new MOSFET in place, make sure the hole aligns properly so that the little bolt will line up with the heatsink hole.
Hopefully this will help some others who may be experiencing a similar issue.
I’m looking at taking a road trip and thought it would be handy to have a Plex Media Server available in the car for streaming shows. I already run Plex Media Server on a desktop machine but wanted something small for the car. After looking around on the web I saw people had it working with a Raspberry Pi 2. The Raspberry Pi 3 recently was released and has some advantages over the 2 so I went with that. This is the start of my own guide for getting it setup. I plan on also setting up the PI as a wireless access point using the built in WIFI.
- Loaded Jessie on a 16GB SD Card for now (will probably order a larger one once I get everything setup).
- Performed a sudo apt-get update and upgrade.
- Found this guide that “NedtheNerd” created in the Plex forums (Thanks Ned!) This guide was also helpful with a slightly different take.
Performed some basic testing and was able to stream content to my Ipad plex client and a fire tablet usign VLC viewer at the same time. Streaming two streams seems problematic though so I need to do more testing.
Well, after a ton of troubleshooting I finally figured out why my Raspberry Pi is hanging at a black screen with a cursor after I do a sudo apt-get upgrade.
I’ve been following the guide below on resizing my partition so that it was slightly smaller than the full 16GB of my SD card. I do this so I can make a complete image and back it up without worrying about the slight differences in sizes of SD cards.
Unfortunately, I kept missing the last step of running sudo resize2fs /dev/mmcblk0p2. If you skip this step and reboot prior to this step, the system comes up fine and you wouldn’t think there would be a problem. It was at that point I’d do a sudo apt-get update then a upgrade and reboot. Upon rebooting is when it would halt at the black screen with cursor. I doubt many others will have this problem but figured I’d post something in case it helps someone else.
Why would you want to resize your partition you ask and not simply use the expand file system feature from raspi-config? The reason I discovered, as many others apparently have, is that not all SD cards are created equal and their storage capacity changes over time. Why is this an issue? It becomes an issue if you want to make an image of your SD card and write it to other SD cards. Even if you have the “same” size SD card, lets say 16GB, the actual capacity of the card may vary. Over time, the capacity of the SD card will also decrease as sectors become unusable. So the purpose of re-sizing the partition is to leave some empty space so that the image is slightly smaller and will fit on other SD cards. For example, if my SD card is 16GB, I might size the partition to 15GB or less so that it will work on other 16GB cards.
In any case, if you’re interested in doing this with your running Raspberry Pi from the command line, I created this post in the forum on how to do it based on another site. I tested it and it does work.
The following is a guide to building a Raspberry Pi Sprinkler Timer.
- Get Raspbian Wheezy Installed and working.
- Run sudo apt-get update and upgrade.
- Setup whatever network connectivity you may plan on using, wired, wireless etc. This is not required but it’s nice for changing the settings.
- Build out the hardware: (I’ll provide more here later as this is a rough draft)
- Install your favorite remote desktop app, I use XNC. Make sure remote connectivity is working.
- sudo apt-get install python-imaging
- sudo apt-get install python-imaging-tk
- sudo apt-get install python-mysqldb
1. Install CENTOS 7 with GNOME (From DVD)
2. Setup VNC server for remote access (CENTOS 7 VNC Server Guide)
3. Make sure all internal hard drives are mounting correctly (Used the GNOME Applications/Utilities/Disks)
4. Make sure all USB hard drives are mounting correctly, this make require NTFS support
* Install EPEL repository. Followed this link.
* Installed ntfs-3g ($yum –enablerepo epel install ntfs-3g)
* Make sure the fstab file is set correctly to allow for SELinux /dev/sdd1 /mnt/wd502 ntfs-3g nosuid,nodev,nofail,x gvfs-show,context=system_u:object_r:samba_share_t:s0 0 0
* Utilized the GNOME Applications/Utilities/Disks to setup mount options
5. Setup SAMBA server there’s a pretty good guide Samba Server Setup.
6. Setup Plex Server downloaded from Plex. Guide Plex Server Guide.
7. Setup rync to “mirror” local drives. Used this guide and this also. Make sure to run crontab -e in the instance of the user that is default in CENTOS.
8. Install LAMP, just google there’s tons of easy guides, nothing specific required.
9. Install WordPress, utilized this as guide.
10. Set WordPress permissions appropriately, had to do this to make it work. :
semanage fcontext -a -t httpd_sys_rw_content_t /path/to/php/dir
restorecon -R /path/to/php/dir
The permissions are key for writing in wordpress and I always have issues. Here’s another document that fixed them for me. LINK
So I noticed my refrigerator seemed to make a knocking or hammering noise when a toilet on the other side of the house was flushed. I have a Whirpool side by side refrigerator and Toto toilet. The refrigerator also occasionally makes the noise without flushing the toilet. After scouring the web it sounded like a bad refill valve in the toilet causing a water hammer. I replaced the valve in the toilet and that appears to have fixed it. The toilet itself had a very small knocking going on with the water line once the toilet was almost full but was barely noticeable. However, the noise on the refrigerator side was quite loud. I just wanted to post this in case anyone else ever experiences the same issue.